Jump to content

wanted level checker ERROR help please?


Recommended Posts

i have this command on my server where you can type /wanted and you will be able to see the wanted level. but recently for some reason it hasnt been working...

i get this two errors when ever i enter in /wanted

ERROR: Client triggered serverside event PlayerChatting, but event is not added serverside

ERROR: Client triggered serverside event PlayerNotChatting, but event is not added serverside

heres the code if someone needs it

addEventHandler ("onResourceStart", getRootElement(),  
function() 
   
end) 
  
addEventHandler ("onPickupUse", getRootElement(),  
function (playerWhoUses) 
  if (source == copPickup) and (getPlayerWantedLevel (playerWhoUses) == 0) then 
    giveWeapon (playerWhoUses, 3, 1, true) 
    setPlayerNametagText (playerWhoUses, "[COP]" .. getPlayerName (playerWhoUses)) 
    setElementData (playerWhoUses, "job", "police") 
    outputChatBox ( "* " .. getPlayerName(playerWhoUses) .. " is a cop now!", getRootElement(), 0, 0, 255, false) 
    outputChatBox ("Arrest wanted people by hitting them with your nightstick!", playerWhoUses, 0, 0, 255, false) 
    outputChatBox ("Use /wanted to get the wanted list.", playerWhoUses, 0, 0, 255, false) 
  elseif not (getPlayerWantedLevel (playerWhoUses) == 0) and (source == copPickup) then 
    outputChatBox ("You can't become cop with this wanted level!", playerWhoUses, 0, 0, 255, false) 
  end 
end) 
  
addCommandHandler ("wanted",  
function (thePlayer, command) 
  if (getPlayerCount() > 1) then 
    local players = getElementsByType ("player") 
    outputChatBox ("---", thePlayer, 0, 0, 255, false) 
    outputChatBox ("Wanted list.", thePlayer, 0, 0, 255, false) 
    for i,v in ipairs (players) do 
      local level = getPlayerWantedLevel (v) 
      if (level > 0) then 
        outputChatBox (getPlayerName (v) .. " - " .. level, thePlayer, 0, 0, 255, false) 
      end 
    end 
    outputChatBox ("---", thePlayer, 0, 0, 255, false) 
  else 
    outputChatBox ("Theres nobody wanted.", thePlayer, 0, 0, 255, false) 
  end 
end) 
  
  

there was also a point where it used to only work if you had a nightstick, then it worked if you didnt have it, then over time it just stopped working... id like it to work where anybody can type /wanted and see whos wanted.

Link to comment
What you are saying could mean you have many resources with same command, because this is a server side and you are saying it's not triggering a client side event. i recommend looking at every script your server is running.

i dont think so... i tried it with my old gamemode with all my old resources and it didnt work. it used to work just fine before...

well i deleted the upper half of the script and i dont get any errors anymore... all though when i get a wanted star and enter in /wanted it still says no one is wanted.

heres what it looks like now.

addCommandHandler ("wanted",  
function (thePlayer, command) 
  if (getPlayerCount() > 1) then 
    local players = getElementsByType ("player") 
    outputChatBox ("---", thePlayer, 0, 0, 255, false) 
    outputChatBox ("Wanted list.", thePlayer, 0, 0, 255, false) 
    for i,v in ipairs (players) do 
      local level = getPlayerWantedLevel (v) 
      if (level > 0) then 
        outputChatBox (getPlayerName (v) .. " - " .. level, thePlayer, 0, 0, 255, false) 
      end 
    end 
    outputChatBox ("---", thePlayer, 0, 0, 255, false) 
  else 
    outputChatBox ("Theres nobody wanted.", thePlayer, 0, 0, 255, false) 
  end 
end) 
  

im kind of thinking maybe it only shows other players wanted lvls except yours... hmmm

edit: it only shows when other players are are in the server...

Link to comment
  • Moderators
edit: it only shows when other players are are in the server...

Of course, in this line:

if (getPlayerCount() > 1) then 

It means that if there are more than 1 player in the server then blablabla

If you are a cop, you can't get any wanted star ( except by a command ).

If there are nobody in the server, so Theres nobody wanted ( in the server ).

So don't touch it, it works fine :wink:

Link to comment
edit: it only shows when other players are are in the server...

Of course, in this line:

if (getPlayerCount() > 1) then 

It means that if there are more than 1 player in the server then blablabla

If you are a cop, you can't get any wanted star ( except by a command ).

If there are nobody in the server, so Theres nobody wanted ( in the server ).

So don't touch it, it works fine :wink:

well actually cops get wanted when they kill a wanted player and non wanted players, the only place they dont get a star in is when they enter a police vehicle pretty much. its something to do with the edited legal systems i have im pretty sure.. im going to have it fixed so that when a non wanted player or wanted player kills a wanted player they dont get any stars.

(wanted count: 6.... lol)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...