Jump to content

Something wrong :/


Baseplate

Recommended Posts

Posted

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) 

Posted (edited)

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

If I helped you, please click the like button on the right ;) Thanks!

Posted
Thanks for the reply, I already made the Column, I'll test it and i'll be right back

Check my code again by the way.

If I helped you, please click the like button on the right ;) Thanks!

Posted

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.

That's to save the wanted levels on death

Posted

Oh, cool. I didn't know about that issue since haven't been working with wanted levels lately :P Thanks for the info.

If I helped you, please click the like button on the right ;) Thanks!

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...