Hi guys!
I want to check if the players are inside a specific vehicle (like a truck “Phantom”), otherwise: vRPclient.notify (player, {"~ r ~ You can’t complete this mission with this car."})
The code is this:
local step = {
text = "",
onenter = function(player, area)
for idname,amount in pairs(trash_items) do
if amount > 0 then -- check if not done
if vRP.tryGetInventoryItem({user_id,idname,amount,true}) then
local reward = v.items[idname][3]*amount
vRP.giveMoney({user_id,reward})
vRPclient.notify(player,{glang.money.received({reward})})
todo = todo-1
trash_items[idname] = 0
if todo == 0 then -- all received, finish mission
vRP.nextMissionStep({player})
end
end
end
end
end
end,
position = v.positions[math.random(1,#v.positions)]
}
Error running call reference function for resource vrp_basic_mission: citizen:/scripting/lua/scheduler.lua:351: server.lua:663: attempt to call a nil value (global 'GetVehiclePedIsIn')
Just tested.
I have to use it (take it from client script):
function vRPmt.isPlayerInVehicleModel(model)
if (IsVehicleModel(GetVehiclePedIsUsing(GetPlayerPed(-1)), GetHashKey(model))) then -- just a function you can use to see if your player is in a taxi or any other car model (use the tunnel)
return true
else
return false
end
end
“just a function you can use to see if your player is in a taxi or any other car model (use the tunnel)”
local step = {
text = "",
onenter = function(player, area)
if vRPclient.isPlayerInVehicleModel("Phantom") then
for idname,amount in pairs(trash_items) do
if amount > 0 then -- check if not done
if vRP.tryGetInventoryItem({user_id,idname,amount,true}) then
local reward = v.items[idname][3]*amount
vRP.giveMoney({user_id,reward})
vRPclient.notify(player,{glang.money.received({reward})})
todo = todo-1
trash_items[idname] = 0
if todo == 0 then -- all received, finish mission
vRP.nextMissionStep({player})
end
end
end
end
else
vRPclient.notify(player,{"~r~Wrong Vehicle!"})
end
end,
position = v.positions[math.random(1,#v.positions)]
}
When i pass on checkpoint without a vehicle, server send me a notify “Wrong Vehicle!” and nothing happens! So it’s good! But the same happens if i stay in a vehicle (“Phantom” in this case)
Passing values from and to the client in vRP (outside the vRP resource) should look something like this (At least in 0.5):
local step = {
text = "",
onenter = function(player, area)
vRPclient.isPlayerInVehicleModel(player, {"phantom"}, function(in_vehicle)
if in_vehicle then
for idname, amount in pairs(trash_items) do
if amount > 0 then -- check if not done
if vRP.tryGetInventoryItem({user_id, idname, amount, true}) then
local reward = v.items[idname][3] * amount
vRP.giveMoney({user_id, reward})
vRPclient.notify(player, {glang.money.received({reward})})
todo = todo - 1
trash_items[idname] = 0
if todo == 0 then -- all received, finish mission
vRP.nextMissionStep({player})
end
end
end
end
else
vRPclient.notify(player, {"~r~Wrong Vehicle!"})
end
end)
end,
position = v.positions[math.random(1, #v.positions)]
}
At first, thank you so much!
But i have a problem with your fix. When i pass on checkpoint without a vehicle, a server send me a nitify “Wrong Vehicle!” so it’s good! But the same happens with a car model “Phantom”. The same message “Wrong Vehicle!” The good thing is that the mission remain not completed.