- 443
- 655
Описание: Хук как в Samp.Lua (onSendPlayerSync).
Пример использования:
Lua:
local playerSync = {
read = function(bs, size)
local bs = bitStreamInit(bs, size)
local data = {}
data.packetId = bitStreamReadByte(bs)
data.leftRightKeys = bitStreamReadWord(bs)
data.upDownKeys = bitStreamReadWord(bs)
data.keysData = bitStreamReadWord(bs)
data.position = {}
data.position.x = bitStreamReadFloat(bs)
data.position.y = bitStreamReadFloat(bs)
data.position.z = bitStreamReadFloat(bs)
data.quaternion = {}
data.quaternion[1] = bitStreamReadFloat(bs)
data.quaternion[2] = bitStreamReadFloat(bs)
data.quaternion[3] = bitStreamReadFloat(bs)
data.quaternion[4] = bitStreamReadFloat(bs)
data.health = bitStreamReadByte(bs)
data.armor = bitStreamReadByte(bs)
data.weapon = bitStreamReadByte(bs)
data.specialAction = bitStreamReadByte(bs)
data.moveSpeed = {}
data.moveSpeed.x = bitStreamReadFloat(bs)
data.moveSpeed.y = bitStreamReadFloat(bs)
data.moveSpeed.z = bitStreamReadFloat(bs)
data.surfingOffsets = {}
data.surfingOffsets.x = bitStreamReadFloat(bs)
data.surfingOffsets.y = bitStreamReadFloat(bs)
data.surfingOffsets.z = bitStreamReadFloat(bs)
data.surfingVehicleId = bitStreamReadWord(bs)
data.animationId = bitStreamReadWord(bs)
data.animationFlags = bitStreamReadWord(bs)
return data
end,
write = function(bs, data,size)
local bs = bitStreamInit(bs, size)
bitStreamSetWriteOffset(bs, 0)
bitStreamWriteByte(bs,data.packetId)
bitStreamWriteWord(bs,data.leftRightKeys)
bitStreamWriteWord(bs,data.upDownKeys)
bitStreamWriteWord(bs,data.keysData)
bitStreamWriteWord(bs,data.keys)
bitStreamSetWriteOffset(bs, 7)
bitStreamWriteFloat(bs,data.position.x)
bitStreamWriteFloat(bs,data.position.y)
bitStreamWriteFloat(bs,data.position.z)
bitStreamWriteFloat(bs,data.quaternion[1])
bitStreamWriteFloat(bs,data.quaternion[2])
bitStreamWriteFloat(bs, data.quaternion[3])
bitStreamWriteFloat(bs,data.quaternion[4])
bitStreamWriteByte(bs,data.health)
bitStreamWriteByte(bs,data.armor)
bitStreamWriteByte(bs,data.weapon)
bitStreamWriteByte(bs,data.specialAction)
bitStreamWriteFloat(bs,data.moveSpeed.x)
bitStreamWriteFloat(bs,data.moveSpeed.y)
bitStreamWriteFloat(bs,data.moveSpeed.z)
bitStreamWriteFloat(bs,data.surfingOffsets.x)
bitStreamWriteFloat(bs,data.surfingOffsets.y)
bitStreamWriteFloat(bs,data.surfingOffsets.z)
bitStreamWriteWord(bs,data.surfingVehicleId)
bitStreamWriteWord(bs,data.animationId)
bitStreamWriteWord(bs,data.animationFlags)
end
}
function onSendPacket(pId, bs, size)
if pId == 207 then
if type(onSendPlayerSync) == 'function' then
local data = playerSync.read(bs,size)
local result = onSendPlayerSync(data)
if result == nil then
playerSync.write(bs,data,size)
elseif result == false then
return false
else
playerSync.write(bs,result,size)
end
end
end
end
Lua:
function onSendPlayerSync(data)
data.health = 75
return data
end