Advertisement
Guest User

Untitled

a guest
Mar 27th, 2016
1,303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. --[[
  2. Example code for Packet Analyzer by urShadow
  3. http://cheat-master.ru/forum/160-573503-1
  4. http://blast.hk/threads/12130
  5. http://rghost.ru/8JqZTvgY7
  6. --]]
  7.  
  8. -- Example 1: reading outcoming RPC "Chat" with message
  9.  
  10. function OnSendRPC(ID, BS)         
  11.     if ID == 101 then --chat message   
  12.         local len = BS:ReadUInt8()
  13.         local str = BS:ReadString(len)         
  14.         Log(string.format("Sending chat message '%s'", str))
  15.     end  
  16.     return true
  17. end
  18.  
  19. -- Example 2: reading outcoming packet with bullet data
  20.  
  21. --[[
  22. struct stBulletData
  23. {
  24.     uint8_t     byteType;
  25.     uint16_t    sTargetID;
  26.     float       fOrigin[3];
  27.     float       fTarget[3];
  28.     float       fCenter[3];
  29.     uint8_t     byteWeaponID;
  30. };
  31. --]]
  32.  
  33. function ReadBulletData(BS)
  34.     local struct =
  35.     {
  36.         byteType = BS:ReadUInt8(),
  37.         targetID = BS:ReadUInt16(),
  38.         origin =
  39.         {
  40.             [0] = BS:ReadFloat(),
  41.             [1] = BS:ReadFloat(),
  42.             [2] = BS:ReadFloat()
  43.         },
  44.         target =
  45.         {
  46.             [0] = BS:ReadFloat(),
  47.             [1] = BS:ReadFloat(),
  48.             [2] = BS:ReadFloat()
  49.         },
  50.         center =
  51.         {
  52.             [0] = BS:ReadFloat(),
  53.             [1] = BS:ReadFloat(),
  54.             [2] = BS:ReadFloat()
  55.         },
  56.         weaponID = BS:ReadUInt8()
  57.     }
  58.     return struct
  59. end
  60.  
  61. function OnSendPacket(ID, BS)          
  62.     if ID == 206 then -- bulet sync
  63.         BS:IgnoreBits(8) -- packetid
  64.         local bullet = ReadBulletData(BS)
  65.         Log(bullet.center[0])
  66.         Log(bullet.weaponID)
  67.     end
  68.     return true
  69. end
  70.  
  71. -- Example 3: sending RPC
  72.  
  73. function SendChat(message)
  74.         local bs = BitStream.new()
  75.         bs:WriteUInt8(Strlen(message))
  76.         bs:WriteString(message)
  77.         bs:RPC(101) -- send rpc chat
  78. end
  79.  
  80. function OnSendRPC(ID, BS)         
  81.     if ID == 26 then -- rpc enter vehicle
  82.         SendChat("I enter in the vehicle")     
  83.     elseif ID == 154 then -- rpc exit vehicle
  84.         SendChat("I exit from the vehicle")
  85.     end
  86.     return true
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement