Help with some code

Don’t use screenshots. You can copy the text from the command prompt by holding the first mouse button, highlighting the text, pressing Ctrl+C and pasting it right into your message here.

Your problem is this line:

end,"Use Lockpick"}

There can be no code after an end statement. End basically says where a block of code ends.

EDIT: I know my end definition is not right, but I’m trying…

This is what i have at the minute https://pastebin.com/r32vV8Ur

I have tried multiple ways of end without anything with) with }) and still errors

I have tried the mark and ctrl + c but keeps pasting my last image so a screenshot will have to do sorry

I eventually got the code to run with no errors using:

local choice_lockpick = {function(player,choice)
  local user_id = vRP.getUserId(player)
  if user_id ~= nil then
    -- anim and repair
    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
end}

Only issue now is doors dont unlock, is SetVehicleDoorsLocked the right native or should it be unlocked?

https://pastebin.com/tdewKcGW

In the paste in you provided, you missed a “end”.

Basically, make sure that your if statements and function have an “end”. Otherwise, the code doesn’t know when the function/if statements end and the rest of the code begins/continues.

Edit: Nevermind, you fixed that bit :stuck_out_tongue:

1 Like

Like i say i got it to work, only issue i have now is wether i have a lockpick or not when i click lockpick the ped still does the animation and car does not unlock :S

https://pastebin.com/9U2UZyX3

Yea. Are you sure that SetVehicleDoorsLocked exists in the vRP framework? I couldn’t find anything.

If not, you may have to call the native yourself

https://runtime.fivem.net/doc/reference.html#_0xB664292EAECF7FA6

1 Like