[Help ]vrp script help

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

you forgot this part at the top and you have to write a dependency and “@vrp/lib/utils.lua” (server script) in the __resource.lua

local Tunnel = module(“vrp”, “lib/Tunnel”)
local Proxy = module(“vrp”, “lib/Proxy”)

vRP = Proxy.getInterface(“vRP”)
vRPclient = Tunnel.getInterface(“vRP”,“CHOOSE A NAME”)

No actually its never going to work like that, you’re mixing Client and Server.

ok. I found this whilst searching through the forums and tweaked it a little to try and get it to work with vRP lol :flushed:

Any help to get this working would be great!

I can try to make the script working but at the moment all it does (if it worked) would be making the flatbed3 undriveable for mechanic xD

i did think that lol

Basically what I want is to make it so that you have to be set as mechanic to use the vehicle if you could get that working that would be fantastic then i would just use that as a template for all other jobs/vehicles

Thank you very much for helping me :grin:

I’ll try. I can’t promise that it will work but I will try my best xD

ok let me know what, if anything you come up with lol

I will :slight_smile:
20 Charrrrsssss

@csg123 just wondering if you have had the time to have a look or sort this at all yet?

Or anyone else able to help me out with this?