- 2
- 0
- Версия MoonLoader
- Другое
мне интересно могу ли я сделать этот код с синхронизацией например samp_create_sync_data sync_type copy_from_player или так чтобы эта точная функция выполнялась без того чтобы я мог видеть что происходит возможно ли это и если да то как
Lua:
local carid = nil
function teleportPlayer(x, y, z)
lua_thread.create(function()
if isCharInAnyCar(playerPed) then
setCharCoordinates(playerPed, x, y, z)
else
if carid and tonumber(carid) then
local carHandle = select(2, sampGetCarHandleBySampVehicleId(tonumber(carid)))
if carHandle and doesVehicleExist(carHandle) then
clearCharTasksImmediately(PLAYER_PED)
wait(100)
warpCharIntoCar(PLAYER_PED, carHandle)
setCharCoordinates(PLAYER_PED, x, y, z)
printStringNow('~g~Without Warning', 1000)
else
printStringNow('~r~With Warning', 1000)
end
else
printStringNow('~r~With Warning', 1000)
end
end
end)
end
function CarsStreamCalculate()
lua_thread.create(function()
while true do
wait(100)
local target_x, target_y, target_z = getCharCoordinates(PLAYER_PED)
local CarID = nil
local MaxDistance = 30
for _, veh in ipairs(getAllVehicles()) do
local x, y, z = getCarCoordinates(veh)
local dist = getDistanceBetweenCoords3d(target_x, target_y, target_z, x, y, z)
if dist < MaxDistance then
local result, vehid = sampGetVehicleIdByCarHandle(veh)
if result then
MaxDistance = dist
CarID = vehid
end
end
end
if CarID then
carid = CarID
else
carid = nil
end
end
end)
end