local h = require('samp.events')
local tp = false
function main()
repeat wait(1) until isSampAvailable()
sampAddChatMessage('Incar Teleport For Arz by f0Re3t Loaded | Ver.: 0.0.1', -1)
sampRegisterChatCommand('iarztp', arztp)
while true do
wait(0)
end
end
function h.onSendPlayerSync()
if tp then return false end
end
function h.onSendVehicleSync()
if tp then return false end
end
function arztp(arg)
if tp then return end
if not isCharInAnyCar(PLAYER_PED) then return sampAddChatMessage('[ArzTp] Телепорт работает только с машины || Для ног юзай другой тп', -1) end
local res, x, y, z = getTargetBlipCoordinates()
if not res then return sampAddChatMessage('[ArzTp] Ебни метку на карте куда хочешь попасть', -1) end
requestCollision(x, y)
loadScene(x, y, z)
tp = true
lua_thread.create(tp_proccess_started, storeCarCharIsInNoSave(PLAYER_PED), x, y, getGroundZFor3dCoord(x, y, 999.0))
end
function tp_proccess_started(hand, x, y, z)
local res, veh = sampGetVehicleIdByCarHandle(hand)
if not res then
tp = false
sampAddChatMessage('[ArzTp] Невалидный кар || Процесс телепорта отменен', -1)
return
end
lockPlayerControl(true)
sampAddChatMessage('[ArzTp] Начинаем процесс телепорта', -1)
local cx, cy, cz = getCharCoordinates(PLAYER_PED)
sendOnfootSync(cx, cy, cz, veh)
setCharCoordinates(PLAYER_PED, x, y, z)
sampSendEnterVehicle(veh, true)
sendOnfootSync(x, y, z, veh)
wait(1000)
sendIncarSync(x, y, z)
sendOnfootSync(x, y, z, veh)
sampSendEnterVehicle(veh, true)
wait(1000)
sendIncarSync(x, y, z)
warpCharIntoCar(PLAYER_PED, hand)
tp = false
sampAddChatMessage('[ArzTp] Вы успешно были телепортированы', -1)
lockPlayerControl(false)
end
function sendIncarSync(x, y, z, sx, sy, sz)
local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
local data = allocateMemory(63)
sampStorePlayerIncarData(myId, data)
setStructFloatElement(data, 24, x, false)
setStructFloatElement(data, 28, y, false)
setStructFloatElement(data, 32, z, false)
setStructFloatElement(data, 36, 0.01, false)
setStructFloatElement(data, 40, 0.02, false)
setStructFloatElement(data, 44, 0.03, false)
setStructElement(data, 52, 1, getCharHealth(PLAYER_PED), false)
setStructElement(data, 53, 1, getCharArmour(PLAYER_PED), false)
sampSendIncarData(data)
freeMemory(data)
end
function sendOnfootSync(x, y, z, veh)
local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
local data = allocateMemory(68)
sampStorePlayerOnfootData(myId, data)
setStructElement(data, 37, 1, 3, false)
setStructFloatElement(data, 6, x, false)
setStructFloatElement(data, 10, y, false)
setStructFloatElement(data, 14, z, false)
setStructElement(data, 62, 2, veh, false)
sampSendOnfootData(data)
freeMemory(data)
end
function sendPassengerSync(x, y, z)
local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
local data = allocateMemory(63)
sampStorePlayerPassengerData(myId, data)
setStructFloatElement(data, 12, x, false)
setStructFloatElement(data, 16, y, false)
setStructFloatElement(data, 20, z, false)
sampSendPassengerData(data)
freeMemory(data)
end