Help adding wanted levels to players initiating/finishing a crime - QBCORE

Could anyone help me out with modifying the qb-policejob or crime scripts to give wanted levels to players who initiate crime resources? I saw this done fairly easily with a couple lines of code and attempted to copy and tweak it but the main issue is that it was done for an ESX policejob script, not QBCORE.

Any help is appreciated, thank you!

This is the link to the post I am referring to above: [SOLVED] Adding AI wanted level to ESX

needs to be converted from esx native to qbcore otherwise just throw errors you need to know the resemblance to make the qb changes

Hey :slightly_smiling_face:

Let’s take the ‘qb-storerobbery’ resource that comes with the basic QB package.
You could do the following for example :

  1. Change the '[qb]/qb-storerobbery/config.lua" line 6 to ‘0’ (it will make it easier for us) :

  2. In ‘[qb]/qb-storerobbery/server/main.lua’ lets add the following around line 104, it will allow us to get the count of cops server side before sending the NPC cavalerie :
    image

  3. Then lets modify the ‘callCops’ event that you find in the server file too (same as above), we just check the number or cops and if its too low we send NPC cops to the criminal (see the 2 line with the blue dot to configure the minimum cops and the wanted level) :

I didn’t test the code, I’ll let you do it. Let me know if you are having issues :wink:

1 Like

thats an interesting way of doing it :slight_smile:

Thank you I will take a look momentarily. Could the code be further simplified to abandon reliance on cops on duty overall? Like a bypass to checking for cops online and straight to a callcops event for npc cops?

Thank you!

You mean that only the NPC cop need to be called (not the player cops) ?

Yes, also I gave it a try, I will show you how I had entered the code to see if I had a misplacement or error. Attempted a store robbery but did not trigger a wanted level, but could be from my own error. Here is what my main.lua looks like:

Yes if that would be easier. I posted my attempt underneath, I feel like my placement of step 2 may be incorrect, what do you see? Thanks!

1 Like

Weird, the code looks good on the screen you sent me.
Was there any player cops on the server when you try by any chance ?

You implemented the 2nd step as intended, no issues here.
I didn’t understand, there was player coops ? Because if so it won’t work, for the NPC cops to be called there must be less than 2 player coops connected on the server.

Its just me in the server testing, and yeah I’m looking closely to see what it may be

Maybe creating a line of code that ignores player cops in the equation and is a simple get wanted level function? It sounds simpler but unsure if it would be implemented directly into the copscalled argument.

1 Like

oh my goodness you know what, its very possible the code is completely fine but that the wanted system is disabled somewhere in the server files. I spent all night looking for where that line of code or config was but could not find it. I have a feeling that could be why.

Ah !!! Happy that it came to you now, so I didn’t have to look for an error if there wasn’t ! ^^
But unfortunatly i’m not sure that the issue comes from the wanted system being disable, I can see a client Native SetMaxWantedLevel() that could eventually be used to do that (maybe it’s somewhere in another of your scripts). I must admit that I don’t know, maybe do some simple testing (create a blank script and just try to set a wanted level to your player)

I will try to look around, my server is using the standard qbcore populated template from txadmin, so I’m certain its somewhere in a resource script. I will let you know if I find it. Thanks

u already solve it?

I think I found what you and I are looking for;

try looking in …/resources/[qb]/qb-smallresouces/client/ignore

Hope this helped!

1 Like

it doesn’t work for me .
Maybe someone can find the solution