Progress bar not working.

04/14/2013 04:10 LordGragen.#1
i was looking at angelius guide and found this about progress bar

[Only registered and activated users can see links. Click Here To Register...]

[Only registered and activated users can see links. Click Here To Register...]

so friend of my helped me build one, but it didnt work so here is how we did and i hope to get answer for

for the npc part we did this for testing

Code:
  case 8:
                                            {
                                                Data gData = new Data("Pick");
                                                gData.UID = client.Entity.UID;
                                                gData.dwParam = 220;
                                                gData.ID = 164;
                                                gData.Facing = Enums.ConquerAngle.East;
                                                gData.EffectTimeout = 2;
                                                break;
                                            }
and for the data.cs part we did this


Code:
 public Data(string effectName)
        {
            Buffer = new byte[45 + effectName.Length];
            WriteUInt16((ushort)Buffer.Length, 0, Buffer);
            WriteUInt16(10010, 2, Buffer);
            StringCount = 1;
            EffectName = effectName;
        }


public Game.Enums.ConquerAngle Facing
        {
            get
            {
                return (Game.Enums.ConquerAngle)Buffer[22];
            }
            set
            {
                WriteUInt32((uint)value, 22, Buffer);
            }
        }

 public uint EffectTimeout
        {
            set
            {
                WriteUInt32(value, 32, Buffer);
            }
        }

        public byte StringCount
        {
            set
            {
                WriteByte(value, 37, Buffer);
            }
        }

        public byte EffectNameLength
        {
            set
            {
                WriteByte(value, 38, Buffer);
            }
        }

        public string EffectName
        {
            set
            {
                WriteString(value, 39, Buffer);
                EffectNameLength = (byte)value.Length;
            }
        }
to be honest i think the code looks fine, but since its not working then of corse its not.
04/14/2013 04:19 littlechris95#2
Try putting:
Quote:
client.Send(gData);
After:
Quote:
gData.EffectTimeout = 2;
04/14/2013 04:54 LordGragen.#3
Quote:
Originally Posted by littlechris95 View Post
Try putting:

After:

i just did and now when i use the case 8 it dc me, not the source just loging me off from the server
04/14/2013 05:02 Super Aids#4
"gData.Facing = Enums.ConquerAngle.East;"
Why do you make it face east? Why not use the direction of your player?
However are you appending "TQServer" to the packet?

Please post a packet dump.
04/14/2013 06:02 LordGragen.#5
you talking about the packet 10010?
04/14/2013 10:53 _DreadNought_#6
Using the packet writer he is, TQServer will indeed be added to the end of the packet.

The packet is incorrect.

The code snippet someone gave you was right, You initialized a packet instance and the variables, but you never actually done anything with it.

so yes, client.send(gData.toArray()); was right.

If you get DC'd - That most likely means the packet is invalid and you need to double check it using a packet sniffer and not relying on packet structures posted by other people (Hard lesson well learned, ty ulti)
04/14/2013 15:14 LordGragen.#7
okay thx will see what i can come up ith
04/14/2013 16:17 teroareboss1#8
public Data(string effectName)
{

Buffer = new byte[46 + effectName.Length];
WriteUInt16((ushort)(Buffer.Length - 8), 0, Buffer);

WriteUInt16(10010, 2, Buffer);
StringCount = 1;
EffectName = effectName;
}
04/14/2013 16:35 LordGragen.#9
Quote:
Originally Posted by teroareboss1 View Post
public Data(string effectName)
{

Buffer = new byte[46 + effectName.Length];
WriteUInt16((ushort)(Buffer.Length - 8), 0, Buffer);

WriteUInt16(10010, 2, Buffer);
StringCount = 1;
EffectName = effectName;
}
thank you, i also fixed that. and added

client.Send(gData.ToArray()); on npc part

now it dont dc anymore but still not showing.
04/14/2013 19:26 urgabel#10
Quote:
Originally Posted by teroareboss1 View Post
Buffer = new byte[46 + effectName.Length];
Could you explain why 46, please?

I think it should be 45, as Angelius posted; if last data before "TQServer" string is EffectName, the total length of the packet would be 39 + effectName.Length + "TQServer".Length - 2 = 45 + efectName.Length
If the packet length (first 2 bytes) also must be included in PacketLength( at offest 2), then replace 45 by 47. Anyway, I cannot see how it could be 46.

Also I wonder why it is not needed to write a timestamp in offset 16...
04/14/2013 21:54 teroareboss1#11
Quote:
Originally Posted by urgabel View Post
Could you explain why 46, please?

I think it should be 45, as Angelius posted; if last data before "TQServer" string is EffectName, the total length of the packet would be 39 + effectName.Length + "TQServer".Length - 2 = 45 + efectName.Length
If the packet length (first 2 bytes) also must be included in PacketLength( at offest 2), then replace 45 by 47. Anyway, I cannot see how it could be 46.

Also I wonder why it is not needed to write a timestamp in offset 16...
yeah,you right is 47. I have not read all of the packet, only the first part.
and I knew that the size is "46" at packet 10010
04/14/2013 21:59 LordGragen.#12
Code:
 public Data(string effectName)
        {
            Buffer = new byte[47 + effectName.Length];
            WriteUInt16((ushort)(Buffer.Length - 8), 0, Buffer);
            WriteUInt16(10010, 2, Buffer);
            StringCount = 1;
            EffectName = effectName;
        }
here we go.
04/14/2013 22:16 teroareboss1#13
the problem is here : gData.Facing = Enums.ConquerAngle.East;

east = 5;

use:
Code:
        public enum BarProgress
        {
                InProgress = 1,
                FullProgress = 2
        }
        public BarProgress ProcesBar { get { return (BarProgress)ReadByte(22); } set { WriteByte((byte)value, 22); } }
04/15/2013 08:12 { Angelius }#14
Quote:
Originally Posted by LordGragen. View Post
Code:
  case 8:
                                            {
                                                Data gData = new Data("Pick");
                                                gData.UID = client.Entity.UID;
                                                gData.dwParam = 220;
                                                gData.ID = 164;
                                                gData.Facing = Enums.ConquerAngle.East;
                                                gData.EffectTimeout = 2;
                                                break;
                                            }
Code:
 public Data(string effectName)
        {
            Buffer = new byte[45 + effectName.Length];
            WriteUInt16((ushort)Buffer.Length, 0, Buffer);
            WriteUInt16(10010, 2, Buffer);
            StringCount = 1;
            EffectName = effectName;
        }
A- You don't have to use the get/set property because you will never have to read any data from that packet.

B- I don't think that a Timeout of 2 seconds will work try 4+

C- I see you are setting ->

gData.UID = client.Entity.UID;
gData.dwParam = 220;
gData.ID = 164;

But you are not really writing those values to the buffer.

So a simple byte array wold do the job perfectly without complicating things, Something like...

PHP Code:
void Sen_Effect(IClient Clientuint data_8ushort Typeushort direction,  uint LoopTimestring EffectName)
    {
        
//38 + 1 + 8 + EffectName.Length = 47 + EffectName.Length
        //Where 38 is the normal 10010 packet length, 1 for the extra byte at offset 38, 8 for the Server Stamp
        
byte[] Packet = new byte[47 EffectName.Length];
        
WriteUInt16(Packet.Length 80Packet);
        
WriteUInt16(100102Packet);
        
WriteUInt32(Client.UID4Packet);
        
WriteUInt32(data_88Packet);
        
WriteUInt16(Type20Packet);
        
WriteUInt16(direction22Packet);
        
WriteUInt32(LoopTime32Packet);
        
WriteByte(137Packet);
        
WriteByte(EffectName.Length38Packet);
        
WriteString(EffectName39Packet);
        
Client.send(Packet); 
    } 
To call it -> Sen_Effect(Client, 220, 164, 1, 5, "Pick");

Good luck.
04/15/2013 11:30 LordGragen.#15
thank you all very very much for all the help.

very grateful.

now i can start my garden system.