• Question about how to count how many rounds have passed.
    4 replies, posted
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] round check: [lua]if (rounds == endround) then (set yourself to mod) end[/lua] (pseudocode)
[QUOTE=RonanZer0;50068423]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] round check: [lua]if (rounds == endround) then (set yourself to mod) end[/lua] (pseudocode)[/QUOTE] Thank you!
[QUOTE=RonanZer0;50068423] -snip- [/QUOTE] Any idea why this won't count the rounds then set it back? [lua] 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" ) end local modme = ulx.command( CATEGORY_NAME, "ulx modme", ulx.modme, "!modme" ) modme:defaultAccess( ULib.ACCESS_ADMIN ) modme:help( "Gives you moderator for 2 rounds." ) function countRounds() rounds = CurrentTTTRound + 1 or 0 end hook.Add( "TTTEndRound", "CountRoundsForMM", countRounds ) [/lua]
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?
Sorry, you need to Log In to post a reply to this thread.