Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Example code for Packet Analyzer by urShadow
- http://cheat-master.ru/forum/160-573503-1
- http://blast.hk/threads/12130
- http://rghost.ru/8JqZTvgY7
- --]]
- -- Example 1: reading outcoming RPC "Chat" with message
- function OnSendRPC(ID, BS)
- if ID == 101 then --chat message
- local len = BS:ReadUInt8()
- local str = BS:ReadString(len)
- Log(string.format("Sending chat message '%s'", str))
- end
- return true
- end
- -- Example 2: reading outcoming packet with bullet data
- --[[
- struct stBulletData
- {
- uint8_t byteType;
- uint16_t sTargetID;
- float fOrigin[3];
- float fTarget[3];
- float fCenter[3];
- uint8_t byteWeaponID;
- };
- --]]
- function ReadBulletData(BS)
- local struct =
- {
- byteType = BS:ReadUInt8(),
- targetID = BS:ReadUInt16(),
- origin =
- {
- [0] = BS:ReadFloat(),
- [1] = BS:ReadFloat(),
- [2] = BS:ReadFloat()
- },
- target =
- {
- [0] = BS:ReadFloat(),
- [1] = BS:ReadFloat(),
- [2] = BS:ReadFloat()
- },
- center =
- {
- [0] = BS:ReadFloat(),
- [1] = BS:ReadFloat(),
- [2] = BS:ReadFloat()
- },
- weaponID = BS:ReadUInt8()
- }
- return struct
- end
- function OnSendPacket(ID, BS)
- if ID == 206 then -- bulet sync
- BS:IgnoreBits(8) -- packetid
- local bullet = ReadBulletData(BS)
- Log(bullet.center[0])
- Log(bullet.weaponID)
- end
- return true
- end
- -- Example 3: sending RPC
- function SendChat(message)
- local bs = BitStream.new()
- bs:WriteUInt8(Strlen(message))
- bs:WriteString(message)
- bs:RPC(101) -- send rpc chat
- end
- function OnSendRPC(ID, BS)
- if ID == 26 then -- rpc enter vehicle
- SendChat("I enter in the vehicle")
- elseif ID == 154 then -- rpc exit vehicle
- SendChat("I exit from the vehicle")
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement