So… I’m developing this client script that should trigger a job.
To trigger it:
- Player is on a vehicle
- Player is near the location
- Player is near another player too
I’m trying to keep the script as simple as I can, but this doesn’t seem to work… What am I doing wrong? (thank you, this is one of my first scripts, I’m still learning)
client.lua
onJob = 0
function ToggleJob(jobid)
if jobid = 1 then -- START JOB
showLoadingPromt("Loading work: Demolition Derby", 5000, 3)
Wait(5000)
DrawMissionText('Drive around and crash in other players', 10000)
onJob = jobid
elseif jobid = 0
onJob = jobid
end
end
function DrawMissionText(m_text, showtime)
ClearPrints()
SetTextEntry_2("STRING")
AddTextComponentString(m_text)
DrawSubtitleTimed(showtime, 1)
end
AddEventHandler(function()
if onJob = 0 then
if IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then
if GetDistanceBetweenCoords(1618, 2158, 77, GetEntityCoords(GetPlayerPed(-1)), true) < 10.0001 then
if GetDistanceBetweenCoords(GetEntityCoords(GetNearestPlayerToEntity(GetPlayerPed(-1))), GetEntityCoords(GetPlayerPed(-1)), false) < 10.0001 then
ToggleJob(1)
Wait (5000)
DrawMissionText('Drive around and crash in other players', 10000)
else
DrawMissionText('You need more players to start a Demo-Derby', 5000)
end
end
end
elseif onJob = 1 then
if not IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then
ToggleJob(0)
elseif GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), 1618, 2158, 77, true) > 10.0001 then
DrawMissionText('... Leaving the Demo-Derby ...', 5000)
ToggleJob(0)
end
end
end)