hello guys
i’m trying to figure out how to create a car repairer job but i cant find anything that can help me or something aldready create? and on the same topic our personnal car keep despawning as soon as you leave them and same didn’t find something about it !
If someone can help me on this or juste give me some idea on where to start working on it could be nice !
Thank you
Hello, the answer is simple
function of my menu TowTruck
function FixVeh()
Citizen.CreateThread(function()
local ply = GetPlayerPed(-1)
local plyCoords = GetEntityCoords(ply, 0)
--GetClosestVehicle(x,y,z,distance dectection, 0 = tous les vehicules, Flag 70 = tous les veicules sauf police a tester? https://pastebin.com/kghNFkRi)
veh = GetClosestVehicle(plyCoords["x"], plyCoords["y"], plyCoords["z"], 5.001, 0, 70)
if(DoesEntityExist(veh)) then
RequestAnimDict("amb@world_human_vehicle_mechanic@male@base")
TaskPlayAnim(GetPlayerPed(-1), "amb@world_human_vehicle_mechanic@male@base", "base", 8.0, -8, -1, 0, 0, 0, 0, 0)
Citizen.Wait(60000)
SetVehicleFixed(veh)
ClearPedTasksImmediately(GetPlayerPed(-1))
drawNotification("Le véhicule est ~g~réparé~w~.")
else
drawNotification("~r~Aucun véhicule proche de vous.")
end
end)
end
I am trying to use it for paramedics can heal the players but it doesn´t work :S
function GetPlayers()
local players = {}
for i = 0, 31 do
if NetworkIsPlayerActive(i) then
table.insert(players, i)
end
end
return players
end
function GetClosestPlayer()
local players = GetPlayers()
local closestDistance = -1
local closestPlayer = -1
local ply = GetPlayerPed(-1)
local plyCoords = GetEntityCoords(ply, 0)
for index,value in ipairs(players) do
local target = GetPlayerPed(value)
if(target ~= ply) then
local targetCoords = GetEntityCoords(GetPlayerPed(value), 0)
local distance = GetDistanceBetweenCoords(targetCoords["x"], targetCoords["y"], targetCoords["z"], plyCoords["x"], plyCoords["y"], plyCoords["z"], true)
if(closestDistance == -1 or closestDistance > distance) then
closestPlayer = value
closestDistance = distance
end
end
end
return closestPlayer, closestDistance
end
RegisterNetEvent('paramedic:heal')
AddEventHandler('paramedic:heal', function()
Citizen.CreateThread(function()
target, distance = GetClosestPlayer()
if(distance ~= -1 and distance < 3) then
SetEntityHealth(target, 200)
else
TriggerEvent('chatMessage', 'System', {255, 0, 0}, "Not one near to you !")
end
end)
end)