 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
| Author |
Message |
CWO
Joined: 04 Feb 2006 Posts: 684 Location: Chicago, IL USA
|
Posted: Mon Nov 06, 2006 5:44 am Post subject: |
|
|
Basically the client has this all hardcoded. You can use the 0xBF packet to send these 32-bit numbers.
http://packets.polserver.com/index.php?op=showpacket&packet=0xBF
On login, you'd use 0xBF with the first subcommand which initializes the buffer for movement. You can send 6 32-bit numbers to the client. When the client requests to move with packet 0x02, appended onto the end of it is going to be either one of these 32 bit numbers or 0.
http://packets.polserver.com/index.php?op=showpacket&packet=0x02
When one of these moves goes through, you evaluate this number to see if you are going to send 0x21 (denied) or 0x22 (accept) (POL automatically accepts of course so in a packethook, you'd block the initial move request and send deny to the client if needed)
http://packets.polserver.com/index.php?op=showpacket&packet=0x21
http://packets.polserver.com/index.php?op=showpacket&packet=0x22
Now what I had was an outside script (checking a prop on the character to see if it was going and if not, start_script for each character) that at regular intervals, would send out 0xBF with the second subcommand which sends one more key to the client for every successful move they made. So basically, this makes the client receive keys at a regular interval as its moving so it should never run out of keys unless of course, you're running too fast or you're running beyond the lag buffer (smoothwalk). But the client does help the server a lot in that situation if you decide to use it because if it ever requests a move and its out of keys to send, it just sends 0. I say though that you SHOULD check if any non-zero was actually sent to the client in case someone mods their packets to send anything other than 0 which would break the whole system if the server wasn't checking.
This was the code I used but apparently, it was a bit laggy to use..
antispeed.src
| Code: |
use uo;
use os;
use polsys;
use unicode;
use util;
program AntiSpeedHack()
return 1;
endprogram
exported function HandleSpeedHackers(character, byref packet)
var direction := packet.GetInt8(1);
if ((character.facing != direction) && (character.facing != (direction - 128) ))
//Changed facing, send a new key since this isn't really a move
var newkey := RandomInt(0x4000000000000)+1;
var packet := CreatePacket(0xBF, 9);
packet.SetInt16(1,0x0009);
packet.SetInt16(3,0x0002);
packet.SetInt32(5,newkey);
packet.SendPacket(character);
return 0;
endif
var shackcheck := packet.GetInt32(3);
var sstack := GetObjProperty(character, "#shackstack");
var moves := CInt(GetObjProperty(character, "#moves"));
if(shackcheck && shackcheck in sstack && moves < 6)
var newstack := array;
foreach num in sstack
if (num != shackcheck)
newstack.append(num);
endif
endforeach
SetObjProperty(character, "#moves", moves+1);
SetObjProperty(character, "#shackstack", newstack);
if (!GetObjProperty(character, "#movepid"))
Start_Script("antispeedhelper", character);
endif
else
SendSysMessage(character, "Too fast");
SetObjProperty(character, "#shackwarning", GetObjProperty(character, "#shackwarning")+2);
var reject := CreatePacket(0x21, 8);
reject.SetInt8(1, packet.GetInt8(2));
reject.SetInt16(2, character.x);
reject.SetInt16(4, character.y);
reject.SetInt8(6, direction);
reject.SetInt8(7, character.z);
reject.SendPacket(character);
return 1;
endif
return 0;
endfunction
|
antispeedhelper.src
| Code: |
use uo;
use os;
use polsys;
use file;
use util;
var packet, newkey, shackwarning;
program antispeed(who)
SetObjProperty(who, "#movepid", GetPid());
while(GetObjProperty(who, "#moves"))
if (GetEquipmentByLayer(who, 25))
sleepms(80);
else
sleepms(160);
endif
newkey := RandomInt(0x4000000000000)+1;
packet := CreatePacket(0xBF, 9);
packet.SetInt16(1,0x0009);
packet.SetInt16(3,0x0002);
packet.SetInt32(5,newkey);
packet.SendPacket(who);
shackwarning := CInt(GetObjProperty(who, "#shackwarning"));
SetObjProperty(who, "#moves", CInt(GetObjProperty(who, "#moves")-1));
var shackstack := GetObjProperty(who, "#shackstack");
shackstack.append(newkey);
SetObjProperty(who, "#shackstack", shackstack)
if (shackwarning)
SetObjProperty(who, "#shackwarning", shackwarning-1);
if (shackwarning > 5)
Print(who.name + " is getting excessive speedhack warnings!");
SetObjProperty(who, "#shackwarning", CInt(0));
endif
endif
endwhile
SetObjProperty(who, "#shackwarning", CInt(0));
EraseObjProperty(who, "#movepid");
endprogram |
login.src and reconnect.src
| Code: | SetObjProperty(who, "#moves", CInt(0));
SetObjProperty(who, "#shackwarning", CInt(0));
EraseObjProperty(who, "#movepid");
var shackstack := array;
shackstack[1] := RandomInt(0x4000000000000)+1;
shackstack[2] := RandomInt(0x4000000000000)+1;
shackstack[3] := RandomInt(0x4000000000000)+1;
shackstack[4] := RandomInt(0x4000000000000)+1;
shackstack[5] := RandomInt(0x4000000000000)+1;
shackstack[6] := RandomInt(0x4000000000000)+1;
var shstack := CreatePacket(0xBF, 29);
shstack.SetInt16(1,0x001D);
shstack.SetInt16(3,0x0001);
shstack.SetInt32(5, shackstack[1]);
shstack.SetInt32(9, shackstack[2]);
shstack.SetInt32(13, shackstack[3]);
shstack.SetInt32(17, shackstack[4]);
shstack.SetInt32(21, shackstack[5]);
shstack.SetInt32(25, shackstack[6]);
shstack.SendPacket(who);
SetObjProperty(who, "#shackstack", shackstack); |
Last edited by CWO on Wed Nov 08, 2006 5:20 am; edited 1 time in total |
|
 |
|
|
 |
 |
|