Whizz Posted December 10, 2023 Share Posted December 10, 2023 (edited) 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 December 10, 2023 by Commonist Link to comment
Mkl Posted December 12, 2023 Share Posted December 12, 2023 (edited) 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 December 12, 2023 by Mkl 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now