Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
- Версия MoonLoader
- Другое
Код:
[ML] (error) test2.lua: D:\GTA San Andreas\moonloader\test2.lua:71: undeclared or implicit tag 'BulletSyncData'
stack traceback:
[C]: in function 'new'
D:\GTA San Andreas\moonloader\test2.lua:71: in function 'samp_create_sync_data'
D:\GTA San Andreas\moonloader\test2.lua:29: in function <D:\GTA San Andreas\moonloader\test2.lua:27>
[ML] (error) test2.lua: Script died due to an error. (0DE6EEC4)
Код:
local samp = require("samp.events")
local act = false
local posx
local posy
local posz
function main()
repeat wait(0) until isSampAvailable()
sampRegisterChatCommand('bull',lol)
while true do
wait(0)
end
end
function samp.onSendMapMarker(position)
sampAddChatMessage('Position is ' .. position.x .. ' '.. position.y .. ' ' .. position.z,-1)
posx = position.x
posy = position.y
posz = position.z
end
function lol(qwerty)
act = not act
if act then sampAddChatMessage("Включено",-1)
else sampAddChatMessage('Выключено',-1)
end
if not qwerty:match("%d+") then return sampAddChatMessage("/bull ID",-1) end
local _ , ped = sampGetCharHandleBySampPlayerId(qwerty)
if not _ then return sampAddChatMessage('Игрок не найден',-1) end
lua_thread.create(function()
while act do wait(0)
local data = samp_create_sync_data('bullet')
local currentW = getCurrentCharWeapon(PLAYER_PED)
data.targetType = 1
data.targetId = qwerty
data.weaponId = currentW
data.send()
printStringNow('Sent',1000)
wait(2000)
end
end)
end
function samp.onSendBulletSync(data)
if act then return false end
end
--function samp.onSendPlayerSync(data)
-- if act then
-- return false
-- end
--end
function samp.onSetInterior(interior)
sampAddChatMessage('Смена интерьера на ' .. interior,-1)
end
function samp_create_sync_data(sync_type, copy_from_player)
local ffi = require 'ffi'
local sampfuncs = require 'sampfuncs'
-- from SAMP.Lua
local raknet = require 'samp.raknet'
--require 'samp.synchronization'
copy_from_player = copy_from_player or true
local sync_traits = {
player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
}
local sync_info = sync_traits[sync_type]
local data_type = 'struct ' .. sync_info[1]
local data = ffi.new(data_type, {})
local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
-- copy player's sync data to the allocated memory
if copy_from_player then
local copy_func = sync_info[3]
if copy_func then
local _, player_id
if copy_from_player == true then
_, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
else
player_id = tonumber(copy_from_player)
end
copy_func(player_id, raw_data_ptr)
end
end
-- function to send packet
local func_send = function()
local bs = raknetNewBitStream()
raknetBitStreamWriteInt8(bs, sync_info[2])
raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
raknetDeleteBitStream(bs)
end
-- metatable to access sync data and 'send' function
local mt = {
__index = function(t, index)
return data[index]
end,
__newindex = function(t, index, value)
data[index] = value
end
}
return setmetatable({send = func_send}, mt)
end
Последнее редактирование: