Basically i am trying to implement lockpicks, i have added them to the store and menu however i cant get this bit of code right, i have used a part of the repair vehicle function and tried to adapt it for lockpicks but keep getting errors in the console, could anyone point me in the right direction please
I havent posted in the vrp section as theres hundreds of unanswered questions there already
The code im trying
local Tunnel = module("vrp", "lib/Tunnel")
local Proxy = module("vrp", "lib/Proxy")
vRP = Proxy.getInterface("vRP")
vRPclient = Tunnel.getInterface("vRP","vRP_static_menus")
local Lang = module("vrp", "lib/Lang")
local cfg = module("vrp", "cfg/base")
local lang = Lang.new(module("vrp", "cfg/lang/"..cfg.lang) or {})
--unlock vehicle
local choice_lockpick = {function(player,choice)
local user_id = vRP.getUserId({player})
if user_id ~= nil then
if vRP.tryGetInventoryItem(user_id,"lockpick",1,true) then
vRPclient.playAnim(player,{false,{task="WORLD_HUMAN_WELDING"},false})
SetTimeout(15000, function()
vRPclient.SetVehicleDoorsLocked(player,{7})
vRPclient.stopAnim(player,{false})
end
end
end}
-- REGISTER MAIN MENU CHOICES
vRP.registerMenuBuilder({"main", function(add, data)
local user_id = vRP.getUserId({data.player})
if user_id ~= nil then
local choices = {}
if vRP.hasPermission({user_id,"player.lockpick"}) then
choices["lockpick"] = choice_lockpick
end
add(choices)
end
end})
What about this? I had to go through and reformat the text because it wasn’t properly indented. I think this should work, if not I’m missing something extremely obvious…
local choice_lockpick = {function(player,choice)
local user_id = vRP.getUserId({player})
if user_id ~= nil then
if vRP.tryGetInventoryItem(user_id,"lockpick",1,true) then
vRPclient.playAnim(player,{false,{task="WORLD_HUMAN_WELDING"},false})
SetTimeout(15000, function()
vRPclient.SetVehicleDoorsLocked(player,{7})
vRPclient.stopAnim(player,{false})
)
end
end
end}
Why is the function wrapped in braces? Someone correct me if wrong but, doesn’t that make “choice_lockpick” an array with one element in it (the function)?
Is where the error is at. You don’t “end” the function or close the SetTimeout call.
Yes im still getting my ahead around it to be honest but appreciate the reply could you possibly show me how it should look so then i will no for next time