- 443
- 655
Да да да набивание тем.
Lua:
local vehPool = {}
local vehInWorld = {
read = function(bs,size)
local bs = bitStreamInit(bs,size)
local data = {modSlots = {}}
data.vehicleId = bitStreamReadWord(bs)
data.type = bitStreamReadDWord(bs)
data.position = {x = bitStreamReadFloat(bs), y = bitStreamReadFloat(bs), z = bitStreamReadFloat(bs)}
data.rotation = bitStreamReadFloat(bs)
data.interiorColor1 = bitStreamReadByte(bs)
data.interiorColor2 = bitStreamReadByte(bs)
data.health = bitStreamReadFloat(bs)
data.interiorId = bitStreamReadByte(bs)
data.doorDamageStatus = bitStreamReadDWord(bs)
data.panelDamageStatus = bitStreamReadDWord(bs)
data.lightDamageStatus = bitStreamReadByte(bs)
data.tireDamageStatus = bitStreamReadByte(bs)
data.addSiren = bitStreamReadByte(bs)
for i = 1, 14 do
data.modSlots[i] = bitStreamReadByte(bs)
end
data.paintJob = bitStreamReadByte(bs)
data.bodyColor1 = bitStreamReadDWord(bs)
data.bodyColor2 = bitStreamReadDWord(bs)
return data
end,
write = function(bs, data, size)
local bs = bitStreamInit(bs, size)
bitStreamSetWriteOffset(bs,0)
bitStreamWriteWord(bs, data.vehicleId)
bitStreamWriteDWord(bs, data.type)
bitStreamWriteFloat(bs, data.position.x)
bitStreamWriteFloat(bs, data.position.y)
bitStreamWriteFloat(bs, data.position.z)
bitStreamWriteFloat(bs, data.rotation)
bitStreamWriteByte(bs, data.interiorColor1)
bitStreamWriteByte(bs, data.interiorColor2)
bitStreamWriteFloat(bs, data.health)
bitStreamWriteByte(bs, data.interiorId)
bitStreamWriteDWord(bs, data.doorDamageStatus)
bitStreamWriteDWord(bs, data.panelDamageStatus)
bitStreamWriteByte(bs, data.lightDamageStatus)
bitStreamWriteByte(bs, data.tireDamageStatus)
bitStreamWriteByte(bs, data.addSiren)
for i = 1, 14 do
bitStreamWriteByte(bs, data.modSlots[i])
end
bitStreamWriteByte(bs, data.paintJob)
bitStreamWriteDWord(bs, data.bodyColor1)
bitStreamWriteDWord(bs, data.bodyColor2)
end
}
function onRecvRpc(id,bs,size)
if id == 164 then
if type(onVehicleStreamIn) == 'function' then
local data = vehInWorld.read(bs,size)
local result = onVehicleStreamIn(data)
if result == nil then
vehInWorld.write(bs,data,size)
elseif result == false then
return true
else
vehInWorld.write(bs,result,size)
end
end
end
if id == 165 then
local bsi = bitStreamInit(bs,size)
local vehId = bitStreamReadWord(bsi)
vehPool[vehId] = nil
bitStreamDelete(bsi)
end
end
function onVehicleStreamIn(data)
if data.type < 400 or data.type > 611 then
print("Invalid Veh", data.type)
data.type = 411 -- Infernus
end
vehPool[data.vehicleId] = data
return data
end
function onPlayerPutInVehicle(vehId, seatId)
if vehPool[vehId] then
local pos = vehPool[vehId].position
setPosition(pos.x,pos.y,pos.z)
end
end
function onDisconnect()
vehPool = {}
end