Gamemode Round Creation

I need a round system for my gamemode, preferably 20 kills a round and rounds last for 10 minutes. After 3 rounds I would like a voting system.

How could I start this?(THIS IS NOT A FRETTA GAMEMODE)

you would start by using the search button becouse NO ONE WILL MAKE THIS FOR YOU

How do you know? Do you know everything?

its not like you can come and say HELLO EVERYONE I WANT X SCRIPT THANK YOU and expect someone to just come and make it

you better go learn some lua

What kind of a voting system?

You think add a check statement to the Think hook for the 20 kills stuff.
You can also use timers to handle the round time.
There should be a global variable for the rounds, and after each round it will increase by one.
During the increase code you can check for if it is over 3 (your round limit).

[lua]
currentRound = 0;

function roundEndStuff()
currentRound = currentRound + 1;

 if (currentRound > 3) then
      -- Map voting stuff here.
 end;

end;
[/lua]

As for the voting you can use some simple panels.

Map voting.

[editline]16th February 2012[/editline]

Thank you, what kind of function could I make so there has to be at least 1 person on each team before the round start?

[lua]round = {}

– Variables
round.Break = 30 – 30 second breaks
round.Time = 300 – 5 minute rounds

– Read Variables
round.TimeLeft = -1
round.Breaking = false

function round.Broadcast(Text)
for k, v in pairs(player.GetAll()) do
v:ConCommand(“play buttons/button17.wav”)
v:ChatPrint(Text)
end
end

function round.Begin()
– Your code
– (Anything that may need to happen when the round begins)

round.Broadcast("Round starting! Round ends in " .. round.Time .. " seconds!")
round.TimeLeft = round.Time

end

function round.End()
– Your code
– (Anything that may need to happen when the round ends)

round.Broadcast("Round over! Next round in " .. round.Break .. " seconds!")
round.TimeLeft = round.Break

end

function round.Handle()
if (round.TimeLeft == -1) then – Start the first round
round.Begin()
return
end

round.TimeLeft = round.TimeLeft - 1

if (round.TimeLeft == 0) then
	if (round.Breaking) then
		round.Begin()
		round.Breaking = false
	else
		round.End()
		round.Breaking = true
	end
end

end
timer.Create(“round.Handle”, 1, 0, round.Handle)[/lua]

Thanks but I found one already :slight_smile:

You could’ve at least edited the op saying that you found one instead of wasting this guys time…

Lmfao… this was after I tried using his and it didn’t work out for my gamemode so thats why I said thank you still to be nice and not be an ass.

So obviously you can’t use this because of the functions it uses, but here you get the general concept

[lua]
if ( !SERVER ) then return; end;

Unreal.round = {};
Unreal.round.cache = Unreal.util.cache:Open();

–===================================================================–
– Set the round so people can spawn while it goes.
–===================================================================–
function Unreal.round:SetSpawnable( bSpawnable )
self.cache:Push( “Spawnable”, bSpawnable );
end;

–===================================================================–
– Get if it is spawnable.
–===================================================================–
function Unreal.round:GetSpawnable()
return self.cache:Pull( “Spawnable” ) or false;
end;

–===================================================================–
– Start the round, but don’t let it start if another round is in progress.
–===================================================================–
function Unreal.round:Start( duration, rounddelay)
if ( self.cache:Pull(“InProgress”) ) then return; end;

if ( self.cache:Pull("RoundDelayTime") ) then
	if ( self.cache:Pull("LastRoundEnd") + self.cache:Pull("RoundDelayTime") > CurTime() ) then return; end;
end;

self.cache:Push( "StartTime", CurTime() );
self.cache:Push( "InProgress", true );

if ( duration ) then
	self.cache:Push( "RoundDuration", duration );
	
	timer.Simple( duration, function()
		if ( rounddelay ) then
			self:End(rounddelay);
		else
			self:End();
		end;
	end);
end;

self:OnRoundStart();

end;

–===================================================================–
– End a round.
–===================================================================–
function Unreal.round:End(delay)
if ( !self.cache:Pull(“InProgress”) ) then return; end;

self.cache:Push( "RoundDelayTime", false );

if ( delay ) then
	self.cache:Push( "RoundDelayTime", delay );
end;

self.cache:Push( "LastRoundEnd", CurTime() );
self.cache:Push( "StartTime", 0 );
self.cache:Push( "InProgress", false );

self:OnRoundEnd();

end;

–===================================================================–
– Called when a round just starts.
–===================================================================–
function Unreal.round:OnRoundStart()

self:SetSpawnable( true );
self:SetRespawnTime( 3 );
for _,v in pairs( player.GetAll() ) do
	if ( v.group and v.class ) then
		Unreal.hooks.PlayerTeamSpawn(v)
	end;
end;

end;

–===================================================================–
– Set the respawn delay on a time.
–===================================================================–
function Unreal.round:SetRespawnTime( time )
self.cache:Push( “PlayerRespawnTimer”, time );
end;

–===================================================================–
– Called when a round ends.
–===================================================================–
function Unreal.round:OnRoundEnd()
print(“Round just ended!”);
end;

–===================================================================–
– Add a callback for the spawn.
–===================================================================–
Unreal.callback:Set( “RoundPlayerCanSpawn”, function(player)
if ( !player.group ) then return false; end;
if ( !player.class ) then return false; end;
if ( !Unreal.round:GetSpawnable() ) then return false; end;
if ( !Unreal.round.cache:Pull(“InProgress”) ) then return; end;

if ( player.DeathTime and Unreal.round.cache:Pull( "PlayerRespawnTimer" ) ) then

	if ( CurTime() - player.DeathTime >= Unreal.round.cache:Pull("PlayerRespawnTimer") ) then
		return true;
	else
		return false;
	end;
else
	return true;
end;

return false;

end);
[/lua]

Thanks again but a friend made me a system that’s 50 lines simpler :slight_smile:

In other words; you didn’t learn anything and you’ll ask a similar question in 2 - 3 days.