I am using the vrp framework and I’m trying to create a script to make it so you cant use certain vehicles unless you are set to the correct job i.e police can only use police cars, mechanic can only use flatbeds etc…
I have come up with this so far but its not working:
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local ped = GetPlayerPed(-1)
local user_id = vRP.getUserId({source})
if vRP.hasGroup({user_id, "mechanic"}) then
if IsPedInAnyVehicle(ped) then
local car = GetVehiclePedIsIn(GetPlayerPed(-1), false)
if IsVehicleModel(car, GetHashKey("flatbed3",_r)) then
if ( GetPedInVehicleSeat(car, -1)) then
SetVehicleUndriveable(GetVehiclePedIsUsing(ped), true)
Vehpos= GetEntityCoords(car, true)
local xnew = Vehpos.x+2
local ynew = Vehpos.y+2
SetEntityCoords(GetPlayerPed(-1), xnew, ynew, Vehpos.z)
drawNotification("~r~You must be a Mechanic to drive this vehicle")
end
end
end
end
end
end)
The error i get is this:
Error resuming coroutine: client.lua:5: attempt to index a nil value (global ‘vRP’)
I would appreciate anyone’s help tweaking this to get it working
Thanks in advance


