local h = require('samp.events')
local tp = false
local valid_car_for_tp = {
408, 456, 430, 446, 452, 453, 454, 472, 473, 478, 484, 493, 554, 543, 595, 422, 605, 600, 567
}
function main()
repeat wait(1) until isSampAvailable()
sampAddChatMessage('Teleport For Arz by f0Re3t Loaded | Ver.: 0.0.3', -1)
sampRegisterChatCommand('arztp', arztp)
while true do
wait(0)
end
end
function h.onSendPlayerSync()
if tp then return false end
end
function h.onSendPassengerSync()
if tp then return false end
end
function arztp(arg)
if tp then return end
if isCharInAnyCar(PLAYER_PED) then return sampAddChatMessage('[ArzTp] Телепорт работает только с ног', -1) end
local res, x, y, z = getTargetBlipCoordinates()
if not res then return sampAddChatMessage('[ArzTp] Ебни метку на карте куда хочешь попасть', -1) end
arg = tonumber(arg)
if arg ~= nil then
requestCollision(x, y)
loadScene(x, y, z)
tp = true
lua_thread.create(tp_proccess_started, arg, x, y, getGroundZFor3dCoord(x, y, 999.0))
return
end
local veh = FindVehicleForTp()
if veh == -1 then return sampAddChatMessage('[ArzTp] Нет машины в стриме для телепорта, либо кар далеко || Юзай /arztp [ид кара]', -1) end
requestCollision(x, y)
loadScene(x, y, z)
tp = true
lua_thread.create(tp_proccess_started, veh, x, y, getGroundZFor3dCoord(x, y, 999.0))
end
function tp_proccess_started(veh, x, y, z)
local res, hand = sampGetCarHandleBySampVehicleId(veh)
if not res then
tp = false
sampAddChatMessage('[ArzTp] Невалидный ид кара || Процесс телепорта отменен', -1)
return
end
lockPlayerControl(true)
sampAddChatMessage('[ArzTp] Начинаем процесс телепорта', -1)
local cx, cy, cz = getCharCoordinates(PLAYER_PED)
wait(1500)
sendOnfootSync(cx, cy, cz, veh)
setCharCoordinates(PLAYER_PED, x, y, z)
sampSendEnterVehicle(veh, true)
sendOnfootSync(x, y, z, veh)
wait(1000)
sendPassengerSync(x, y, z)
sendOnfootSync(x, y, z, 0)
tp = false
sampAddChatMessage('[ArzTp] Вы успешно были телепортированы', -1)
lockPlayerControl(false)
end
function FindVehicleForTp()
local x, y, z = getCharCoordinates(PLAYER_PED)
for i = 0, 2000 do
local res, veh = sampGetCarHandleBySampVehicleId(i)
if res then
local cx, cy, cz = getCarCoordinates(veh)
if getDistanceBetweenCoords3d(x, y, z, cx, cy, cz) < 80.0 then
-- for j = 1, #valid_car_for_tp do
-- if isCarModel(veh, valid_car_for_tp[j]) then
return i
-- end
-- end
end
end
end
return -1
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)
setStructElement(data, 2, 1, 1, false)
sampSendPassengerData(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