Jump to content

Something wrong :/


Baseplate

Recommended Posts

Well here is my code for now, I want it to make someone have a wanted star when he kills someone and it outputs it on Scoreboard at WL Column

Script:

function wanted( ammo, attacker, weapon, bodypart ) 
if (attacker) and (attacker ~=source) then 
   setPlayerWantedLevel ( attacker, getPlayerWantedLevel( attacker )+1 ) 
else 
local wanted = getPlayerWantedLevel( source ) 
setTimer(setPlayerWantedLevel, 60, 1, source, wanted) 
   end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), wanted ) 
  
function showScoreWanted ( ammo, attacker, weapon, bodypart ) 
  if (attacker) and (attacker ~=source) then 
 local wanted = getPlayerWantedLevel ( attacker ) 
   setElementData(attacker, "WL", tostring(wanted)) 
end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), showScoreWanted) 

Link to comment
  • MTA Team

You need to have the column set in the script as well ;)

Sorry for the new structure. I just like to do all scripts with my own layout style :P

Server-side

exports.scoreboard:scoreboardAddColumn("Wanted level") 
  
addEventHandler("onPlayerWasted", root, 
    function(ammo, attacker, weapon, bodypart) 
        if (attacker) and (attacker ~= source) then 
            setPlayerWantedLevel(attacker, getPlayerWantedLevel(attacker)+1) 
            setElementData(attacker, "Wanted level", tostring(getPlayerWantedLevel(attacker))) 
        else 
            setTimer(setPlayerWantedLevel, 60, 1, source, getPlayerWantedLevel(source)) 
        end 
    end 
) 

EDIT:

However, why do you use this even if you don't need it necessarily?

setTimer(setPlayerWantedLevel, 60, 1, source, getPlayerWantedLevel(source)) 

It sets the same wanted level as the player has, doesn't make sense to me.

Edited by Guest
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...