Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 23:43

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Playing a sound by command (lotf)

Discussion on Playing a sound by command (lotf) within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2015
Posts: 5
Received Thanks: 0
Playing a sound by command (lotf)

ive viewed a few other threads:
im still running into issues with the command. i know im doing something wrong. in one of the threads korvacs said you have to send 2 strings to play music. so i have
Code:
string[] Strings = new string[2];
                                            Strings[0] = "sound/blast.wav";
                                            Strings[1] = "1";
not sure how to fully do the command though. especially calling the string[]:
Code:
 if (Splitter[0] == "/sound")
                                        {
                                            string[] Strings = new string[2];
                                            Strings[0] = "sound/blast.wav";
                                            Strings[1] = "1";
                                            SendPacket(General.MyPackets.String(MyChar.UID, 20, ?)));
                                        }
heres the string packet:
Code:
public byte[] String(long CharId, byte Type, string name)
        {
            ushort PacketType = 1015;
            byte[] Packet = new byte[13 + name.Length];

            fixed (byte* p = Packet)
            {
                *((ushort*)p) = (ushort)Packet.Length;
                *((ushort*)(p + 2)) = (ushort)PacketType;
                *((uint*)(p + 4)) = (uint)CharId;

                *(p + 8) = Type;
                *(p + 9) = 1;
                *(p + 10) = (byte)name.Length;

                for (int i = 0; i < name.Length; i++)
                {
                    *(p + 11 + i) = Convert.ToByte(name[i]);
                }
            }

            return Packet;
        }
anyone know how to successfully do this?
zipquick is offline  
Old 08/19/2015, 11:55   #2
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
Code:
public unsafe byte[] String(long CharId, byte Type, params string[] data)
{
    ushort PacketType = 1015;
    int length = 0;
    foreach (var str in data)
        length += str.Length + 1;
    byte[] Packet = new byte[13 + length];

    fixed(byte* p = Packet)
    {

        *((ushort*)p) = (ushort)Packet.Length;
        *((ushort*)(p + 2)) = (ushort)PacketType;
        *((uint*)(p + 4)) = (uint)CharId;

        *(p + 8) = Type;
        *(p + 9) = (byte)data.Length;
        int offset = 10;
        foreach (var str in data)
        {
            var encoded = System.Text.Encoding.Default.GetBytes(str);
            *(p + offset++) = (byte)encoded.Length;

            //this
            for (int i = 0; i < encoded.Length; i++)
                *(p + offset++) = encoded[i];
            //or that
            //Buffer.BlockCopy(encoded, 0, Packet, offset, encoded.Length);
            //offset += encoded.Length;
        }
    }
    return Packet;
}
Then you can do
Code:
if (Splitter[0] == "/sound")
{
    string[] Strings = new string[2];
    Strings[0] = "sound/blast.wav";
    Strings[1] = "1";
    SendPacket(General.MyPackets.String(MyChar.UID, 20, Strings)));
}
-impulse- is offline  
Old 08/19/2015, 12:06   #3
 
elite*gold: 0
Join Date: Aug 2015
Posts: 5
Received Thanks: 0
Quote:
Originally Posted by -impulse- View Post
Code:
public unsafe byte[] String(long CharId, byte Type, params string[] data)
{
    ushort PacketType = 1015;
    int length = 0;
    foreach (var str in data)
        length += str.Length + 1;
    byte[] Packet = new byte[13 + length];

    fixed(byte* p = Packet)
    {

        *((ushort*)p) = (ushort)Packet.Length;
        *((ushort*)(p + 2)) = (ushort)PacketType;
        *((uint*)(p + 4)) = (uint)CharId;

        *(p + 8) = Type;
        *(p + 9) = (byte)data.Length;
        int offset = 10;
        foreach (var str in data)
        {
            var encoded = System.Text.Encoding.Default.GetBytes(str);
            *(p + offset++) = (byte)encoded.Length;

            //this
            for (int i = 0; i < encoded.Length; i++)
                *(p + offset++) = encoded[i];
            //or that
            //Buffer.BlockCopy(encoded, 0, Packet, offset, encoded.Length);
            //offset += encoded.Length;
        }
    }
    return Packet;
}
Then you can do
Code:
if (Splitter[0] == "/sound")
{
    string[] Strings = new string[2];
    Strings[0] = "sound/blast.wav";
    Strings[1] = "1";
    SendPacket(General.MyPackets.String(MyChar.UID, 20, Strings)));
}
thanks for the reply. still not working though for some reason. im not sure what is wrong. i type the command but nothing plays
zipquick is offline  
Old 08/19/2015, 15:28   #4
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
You've actually updated the packet structure with his? Cause in yours you were telling the client that only 1 string was coming... It's a list of strings

# of strings

for # of strings
string length
string data

Your original packet structure was hardcoded to only send 1 string.
pro4never is offline  
Old 08/19/2015, 15:42   #5
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
Quote:
Originally Posted by pro4never View Post
You've actually updated the packet structure with his? Cause in yours you were telling the client that only 1 string was coming... It's a list of strings

# of strings

for # of strings
string length
string data

Your original packet structure was hardcoded to only send 1 string.
I updated the code to work with multiple strings, checked it for syntax errors only though.

Edit:
Try this code
Code:
public unsafe byte[] String(long CharId, byte Type, params string[] data)
{
    ushort PacketType = 1015;
    int length = 0;
    foreach (var str in data)
        length += str.Length + 1;
    byte[] Packet = new byte[13 + length];

    fixed(byte* p = Packet)
    {

        *((ushort*)p) = (ushort)Packet.Length;
        *((ushort*)(p + 2)) = (ushort)PacketType;
        *((uint*)(p + 4)) = (uint)CharId;

        *(p + 8) = Type;
        *(p + 9) = (byte)data.Length;
        int offset = 10;
        foreach (var str in data)
        {
            var encoded = System.Text.Encoding.Default.GetBytes(str);
            *(p + offset) = (byte)encoded.Length;
            Buffer.BlockCopy(encoded, 0, Packet, offset + 1, encoded.Length);
            offset += encoded.Length + 1;
        }
    }
    return Packet;
}
-impulse- is offline  
Old 08/19/2015, 17:11   #6
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Quote:
Originally Posted by -impulse- View Post
I updated the code to work with multiple strings, checked it for syntax errors only though.

Yes, that's why I asked if he updated to using your packet structures as if he used just the 1 portion of your code and didn't notice you modified the structure then he'd be screwed.
pro4never is offline  
Old 08/19/2015, 19:47   #7
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
Quote:
Originally Posted by pro4never View Post
Yes, that's why I asked if he updated to using your packet structures as if he used just the 1 portion of your code and didn't notice you modified the structure then he'd be screwed.
You would have much more work to do if you were to do that than a simple copy paste.

He has yet to respond to my last update.
-impulse- is offline  
Old 08/20/2015, 00:20   #8
 
elite*gold: 0
Join Date: Aug 2015
Posts: 5
Received Thanks: 0
Quote:
Originally Posted by -impulse- View Post
You would have much more work to do if you were to do that than a simple copy paste.

He has yet to respond to my last update.
the updated code didn't work either sadly. i looked to cofture for a reference but still couldnt figure it out. do you know what the problem could be
zipquick is offline  
Old 08/20/2015, 00:24   #9
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
I don't. You should test the packet with some other data. For spouse name or guild ally or something. Check if it works.
-impulse- is offline  
Reply

Tags
c#, command, conquer online, sound, string


Similar Threads Similar Threads
i earn while playing tetris , surfing or playing
06/01/2012 - Facebook - 1 Replies
Hello ePVP members i am here to help you earn money online while playing or surfing this business is called "paid to click":cool: Things you need: Computer or laptop (keyboard and mouse) Internet connection brain All you need to do is to click all advertisements
Playing a sound. like @play
06/29/2010 - CO2 Private Server - 0 Replies
so, for this im gonna use as an command example say I had a @play command and I wanted it to play FirstBlood.wav becuase I want to use it for events like firstkill I could play that sound for everybody on that map like if (Map == 1005) FirstKill Play"/sound/FirstBlood.wav ?



All times are GMT +1. The time now is 23:44.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.