packet.SetInt16

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Harley
Forum Regular
Posts: 360
Joined: Sat Mar 18, 2006 1:41 am

packet.SetInt16

Post by Harley »

Hi guys! I use StatHook from last Distro SVN.
There is some difficult in function Send_ResistInfos() in sendstat.inc
!!!.jpg
Like you see, fire resistances -7936
But, there isn't FireProtection on character!

Code: Select all

         var resistances := GetObjProtections( character );

         var fire := CInt( resistances["FireProtection"] );
         if( fire > 0 )
                  packet.SetInt16( 70, fire );
         else
                  packet.SetInt16( 70, 0x10000 + fire );
         endif

         var cold := CInt( resistances["WaterProtection"] );
         if( cold > 0 )
                  packet.SetInt16( 72, cold);
         else
                  packet.SetInt16( 72, 0x10000 + cold );
         endif
This error only at Fire Protection!
I have delete 0x10000 from packet.SetInt16( 70, 0x10000 + fire );
packet.SetInt16( 70, fire );
And all was right, but I can't understand, what cause in 0x10000 ?
Remind, this error only in Fire Protection!

Thanks, with best regards!
RusseL
Forum Regular
Posts: 375
Joined: Fri Feb 20, 2009 8:30 pm

Re: packet.SetInt16

Post by RusseL »

Resistances
Resistances can be negatives. Easiest method for handling this correctly is, if a negative is to be sent is: 0x10000+amount
http://docs.polserver.com/packets/index.php?Packet=0x11
:|
Harley
Forum Regular
Posts: 360
Joined: Sat Mar 18, 2006 1:41 am

Re: packet.SetInt16

Post by Harley »

RusseL, unfortunately, do not understand in packets.. But, I have removed 0x10000 and now it's ok)
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: packet.SetInt16

Post by Turley »

The bug is the if clause:
If (res > 0)
It should be instead:
If (res >= 0)
Post Reply