so i been working on something but I am at a road block
– Disable wanted level – from es_extended and tweaked
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerId = PlayerId()
if GetPlayerWantedLevel(playerId) ~= 0 then
SetPlayerWantedLevel(playerId, 0, false)
SetPlayerWantedLevelNow(playerId, false)
end
end
end)
else
SetMaxWantedLevel(2)
end
what this does is keeps the wanted system working but limits the amount of max stars
what I’m wanting to add is have it check to see if a player cop is online. when cops are online it sets all the wanted levels to zero. if there are no cops online the max wanted level is 2
I am trying to incorporate
if PlayerData.job.name == 'police'
if there is a better way let me know. there are gaps of time where there are no cops online so it would be nice to let the npc cops loose during those down times. Thanks again in advance I been messing around with AI for a while now but I’m stuck on this
just a thought, i still do not think this is right
if Config.DisableWantedLevel then
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
function IsJobPolice()
if PlayerData ~= nil then
local isJobPolice = false
if PlayerData.job.name ~= nil and PlayerData.job.name == 'police' then
isJobPolice = true
end
return isJobPolice
end
end
local playerId = PlayerId()
if GetPlayerWantedLevel(playerId) ~= 0 then
SetPlayerWantedLevel(playerId, 0, false)
SetPlayerWantedLevelNow(playerId, false)
end
end
end)
else
SetMaxWantedLevel(2)
end```
Since you would implement this in your playerLoaded event, you could do this, which should work:
if Config.DisableWantedLevel then
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerId = PlayerId()
if playerData.job.name == 'police' then
if GetPlayerWantedLevel(playerId) ~= 0 then
SetPlayerWantedLevel(playerId, 0, false)
SetPlayerWantedLevelNow(playerId, false)
end
end
end
end)
else
SetMaxWantedLevel(2)
end
Thanks for the attempt. Its not throwing any errors or anything , started the server with the new code, logged in to a cop character and still got the wanted levels., switched to a different job and still had wanted levels, switched back to police and still got wanted levels ( cleared wanted levels between changing jobs with /revive). we might be on the right track though. Thanks again for all your help
you know me all to well i’m that Limit guy . I don’t think i mentioned it but this section of code im working on is part of es_extended. I don’t think that makes a difference just more pieces to the puzzle
Well, adding prints tells me if it is actually running the code and getting the player job correctly
Sending me your main.lua file or the file where you’re adding this also makes it easier.
don’t see any difference or change. Thank you again for the attempt to crack the case for me. It should be checking if police are online to enable or disable wanted levels but something is not cooking right.
i know with something like the common calm-ai script it can be started and stopped and you can see the changes in the AI attitudes instantly. But I guess there is way more to it because of the wanted levels. And i think that cop ai is tied directly into the wanted system some how. when the wanted levels are disabled the cops do not react to anything even if you try to use a separate script to change there relationship with players. An example that i ran into. you can make the cops aggresssive with the wanted levels disabled but they are only aggressive if you are pointing a gun at them. the moment you stop aiming at them they lose all interest in players. Sorry im rambling, just sharing the tiny nuggets of info i’m stumbling into
I took out the wanted stuff that was in es_extended and made it stand alone, I tried your main.lua and did not have any luck with it, the version that im linking here is the version we started with before the failed attempts.
here is some code from esx_holdup this part lets you rob a store if there are cops online
AddEventHandler('esx_holdup:robberyStarted', function(currentStore)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local xPlayers = ESX.GetPlayers()
if Stores[currentStore] then
local store = Stores[currentStore]
if (os.time() - store.lastRobbed) < Config.TimerBeforeNewRob and store.lastRobbed ~= 0 then
TriggerClientEvent('esx:showNotification', _source, _U('recently_robbed', Config.TimerBeforeNewRob - (os.time() - store.lastRobbed)))
return
end
local cops = 0
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
cops = cops + 1
end
end
if not rob then
if cops >= Config.PoliceNumberRequired then
rob = true
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
TriggerClientEvent('esx:showNotification', xPlayers[i], _U('rob_in_prog', store.nameOfStore))
TriggerClientEvent('esx_holdup:setBlip', xPlayers[i], Stores[currentStore].position)
end
end
maybe its something we can use. i tried to plug in some stuff but did not have any luck
its set_police_ignore_player, maybe somehow setting it to ignore a job like police. In the past i have dabbled in jobs and relationship groups and never had any luck with it.
I could live with player police being ignored.CRAP still no good the npc cops will try to kill the non-cops even if this was a thing to work, I would delete this whole post but its good to keep a record of my thoughts
I’m trying to do something similar, so i grabbed the stand along version you linked, but with the config set to false, there’s no change and i’m wanted like normal, up to 5. Which I expected. However with the config set to true, I am just never wanted. So i’m not even getting 1 star let alone up to 2. What am I missing?
*EDIT: Nevermind!
I figured out that the version of es_extended I was running had a max set to 0. I actually just edited their line to the value I wanted and it works. So I didn’t even need this script at all to just make the level set to (in my case) 2.