Just for practice I wanted to make a command that would set me as admin and then return me to moderator a few rounds later. I can’t seem to figure out how to check how many rounds have passed. I know you have to do something with TTTEndRound, but I can’t seem to count the rounds passed.
round end or start:
[lua]rounds = rounds+1 or 0[/lua]
in the command:
[lua]endround = rounds+5 – 5 is the amount of rounds to wait
(set yourself to admin)[/lua]
[lua]if (rounds == endround) then (set yourself to mod) end[/lua]
Any idea why this won’t count the rounds then set it back?
CurrentTTTRound = 0
function ulx.modme( calling_ply )
calling_ply._OldRank = calling_ply:GetUserGroup()
endround = CurrentTTTRound + 2
for k, v in ipairs(player.GetAll()) do if v:IsAdmin() or v:IsUserGroup( "moderator" ) then ULib.tsayError( calling_ply, "There is already an Admin or Moderator online." ) return end end RunConsoleCommand( "ulx", "adduserid", calling_ply:SteamID(), "moderator" ) if (rounds == endround) then RunConsoleCommand( "ulx", "adduserid", calling_ply:SteamID(), calling_ply._OldRank ) return end
ulx.fancyLogAdmin( calling_ply, “#A is now an Moderator for the next 2 rounds” )
local modme = ulx.command( CATEGORY_NAME, “ulx modme”, ulx.modme, “!modme” )
modme:defaultAccess( ULib.ACCESS_ADMIN )
modme:help( “Gives you moderator for 2 rounds.” )
rounds = CurrentTTTRound + 1 or 0
hook.Add( “TTTEndRound”, “CountRoundsForMM”, countRounds )
I’m not sure how ULX works but shouldn’t you be checking if the player needs to be set back to the old rank in the countRound function?