Jump to content

[HELP] Scoreboard


Commonist

Recommended Posts

Hi Everyone. 

I want to change the status of the player by changing her team.

This is my code:

exports.scoreboard:addScoreboardColumn('status')
 
function setTeam()
    if getPlayerTeam(source) == getTeamFromName("theTeam") then
    setElementData( source,"status", "theTeam")
end
end
addEventHandler("onPlayerLogin", root, setTeam)

 

What is the problem?
Thank you for your help

Edited by Commonist
Link to comment

HI,

If I understand well you want to create a new column "team" and update it when a player change his team.

The idea that come to my mind is to create a custom event "onPlayerChangeTeam" by overriding the setPlayerTeam function.

addEvent("onPlayerChangeTeam", false)

_setPlayerTeam = setPlayerTeam -- we save the original function

-- override
setPlayerTeam = function(thePlayer, theTeam)
    _setPlayerTeam(thePlayer, theTeam)
    triggerEvent("onPlayerChangeTeam", thePlayer, theTeam) -- a new event "onPlayerChangeTeam" 
end

addEventHandler("onPlayerChangeTeam", root, function(theTeam)
    -- function to update the column 
     setElementData(source,"status", "theTeam")
end)

Untested code

But it depends on what you are trying to do. This idea is that, when the setPlayerTeam function is used in your code, the scoreboard is updated but I maybe missunderstand what you want

Cya,

 

Edited by Mkl
  • Thanks 1
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...