Adding wanted level to player after store robbery

Just trying to add a wanted level to the player after they hold up a store. I’m not exactly sure what the code would look like for that, can anyone help me? (Working in esx with the esx_holdup and esx_advancedholdup)

Sort of got it working. It doesn’t set the level when you commit the robbery but if you commit a small crime it immediately goes up to 3 (which is what I specified in the code)

SetPlayerWantedLevel(xPlayer.source, 3, false)
SetPlayerWantedLevelNow(xPlayer.source, false)

So basically the first line works but the second doesn’t. I get this error:

[ script:esx_holdup] SCRIPT ERROR: @esx_holdup/server/main.lua:52: attempt to call a nil value (global 'SetPlayerWantedLevelNow')

Hi,

Have you tried using
SetFakeWantedLevel( fakeWantedLevel --[[ integer ]] )?

This sets the Wanted level just visually. I’m guessing thats what you want to achieve here.

Native Reference: SetFakeWantedLevel - FiveM Natives @ Cfx.re Docs

1 Like

Thanks for the response :slight_smile:

I’m actually trying to do the real wanted level with AI police since my human police force is lacking right now lol

You are calling the natives from a server side resource, which does not have access to the SetPlayerWantedLevelNow native


A more clear picture showing the server natives, as far as I’m aware every server native is within the CFX namespace, you may find a CFX copy of a client native, which is meant to be used server side, but the server does not have access to every native.