RTV after x amount of rounds?

I think I’ve seen on some servers (I can’t find them now or I’d ask the owners) where they have Rock The Vote installed, but it also automatically pops up every x rounds. Currently I use Simple Mapvote to take care of that for me, but RTV seems a lot cleaner. Does anyone know how they get it to automatically run every x rounds?

It depends what gamemode you’re running. I would assume they just add to a number every time the gamemode’s round hook is called, and if it’s above or equal to that number, they run the map vote function.

Makes sense. Can you tell me how I can check when TTT’s round hook is called? I should easily be able to figure it out from there.

local num = 0

hook.Add( “TTTEndRound”, “Rock the Vote Start”, function()

num = num + 1

if num >= 5 then
	MsgN( "We've ended 5 rounds!" )

end )[/lua]

Okay, so hook.Add() calls the function whenever the hook is called. Thanks, man.

Also, does num++ work in Lua, or do I need to specify num + 1?


local RTV.CurRounds
hook.Add( "TTTEndRound", "Rock the Vote Start", function()
    RTV.CurRounds = RTV.CurRounds + 1
    if num >= RTV.Rounds - 1 and not GetGlobalBool("In_Voting") then
end )

RTV is a global table, you can’t store a local variable inside it. Meaning, you will get an error on line 1.

Where are you getting num from, and what’s the point of RTV.CurRounds if you’re not even doing any checking on it? You also should set a variable to 0 if you’re going to be adding to it. You can’t add to a nil value, which that local variable will be if not specified.

[lua]local Change_At = 5
local Current = 0
local Has_Voted = false

hook.Add( “TTTEndRound”, “Rock the Vote Start”, function()

Current = Current + 1

if Current >= Change_At and not GetGlobalBool("In_Voting") and not Has_Voted then
    Has_Voted = true
elseif Has_Voted and Current > Change_At then -- Already started a vote.
	Current = 1
	Has_Voted = false

end )[/lua]

I assume “Extend Current Map” is still an option in your version, so this way if it’s picked, it’ll start another vote after another 5 rounds.

Wow. I forgot about changing that num. I just noticed right before I saw this

A few of those you just mentioned are done in RTV.Start(), such as setting Has_Voted and the elseif.

Has_Voted is a local variable I created in the script, it’s only for that hook.

I meant In_Voting which gets set in RTV.Start()

Anyway, it’s working perfectly now. Thanks a lot, buddy.