# Turn system

How do I make a turn system for a gamemode? I mean like, Now is my turn and in like say 30 seconds it’s the second player’s turn. And then the 3rd one etc etc and it comes back to the first one.

you could just make a timer and after a certain amount of seconds make it print: 1st players turn! Except if you do decide to do it like that, then you will have to decide how many players are going to play…otherwise you could get the amount of players from the server and have it print off of that

[EDITLINE] 12:42 PM [/EDITLINE]
500th post

But I need everyone else to be frozen and then only that player is not. And the total ammount of players I’m using is 8.

Ohh…I don’t know how to freeze the other players

I do. **[Player.Freeze

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.Freeze)** But I still don’t know how to do the actual turning.

This is for 2 players.
NOTE: haven’t tested this yet
[lua]
local turn = true
local TurnTime = 30 //Turn length in seconds
local GameLength = 600 //Game time limit in sceonds
timer.Create(“TurnTimer”,TurnTime,Gamelength/30,
function()
if (turn) then // if turn is true that means it was just team 1s turn
turn = false //set the turn to false for team 2
Team2Turn() //call your 2nd team function
else
Team1Turn() //call you 1st team function
turn = true //set it to true for team 1
end
end)
function Team1Turn()// Function for when its team 1s turn
for _,ply in pairs(team.GetPlayers(1)) do
ply:Freeze( false )
end
for _,ply in pairs(team.GetPlayers(2)) do
ply:Freeze( true )
end
end

function Team2Turn()// Function for when its team 2s turn
for _,ply in pairs(team.GetPlayers(1)) do
ply:Freeze( true )
end
for _,ply in pairs(team.GetPlayers(2)) do
ply:Freeze( false )
end
end
[/lua]