when a player leaves the server, the team in which he was a member remains in the tab
how to make it so that when ALL team members exit, its name is removed from the tab?below is a snippet of code that might help you
local inPlayerTeam ={}
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),function()
executeSQLQuery("CREATE TABLE IF NOT EXISTS tab_team(name TEXT, login TEXT, level NUMERIC, r NUMERIC, g NUMERIC, b NUMERIC)")local res = executeSQLQuery("SELECT * FROM tab_team WHERE level = ?",1)if#res >0thenfor _, t in ipairs(res)do
createTeam(t.name, t.r, t.g, t.b)endend
outputDebugString("Create "..(#res).." teams")end)
addEventHandler('onClientRender', root,function()for i, team in ipairs(getElementsByType('team'))dolocal players = getPlayersInTeam(team)if(#players ==0)then
destroyElement(team)
endendend)
addEventHandler("onResourceStop", getResourceRootElement(getThisResource()),function()for _, t in ipairs(getElementsByType("team"))
destroyElement(t)
outputDebugString("All teams are removed")end)
addEventHandler("onPlayerLogin", getRootElement(),function(_, account)local login = getAccountName(account)
setElementData(source,"tab_team:login", login)local res = executeSQLQuery("SELECT name FROM tab_team WHERE login = ?", login)if#res >0then
setPlayerTeam(source, getTeamFromName(res[1].name))endend)
addEventHandler("onPlayerQuit", getRootElement(),function()if inPlayerTeam[source]then
inPlayerTeam[source]= destroyElement(team)
endend)
Question
beamer
good afternoon! help me please!
when a player leaves the server, the team in which he was a member remains in the tab
how to make it so that when ALL team members exit, its name is removed from the tab? below is a snippet of code that might help you
Link to comment
1 answer to this question
Recommended Posts