Force dead until everyone in a team is dead?

Sorry about all those question, but those are just things I can’t seem to figure with my restrained lua knowelge.
But as far as I know, it’s the newbie board, isn’t it? Heh.

So anyway, here’s my question.
On a standar gamemode, how would it be possible to make it like:
Team A has 6 players
Team B has 6 players

Team A kill one player in the team B, the killed player, have to sit down for the time until every one on a team is dead.

Team A kills everyone on the Team B. Everyone spawns back at their spawns. With a few seconds freeze time.

If possible, keep the match to a laps of 180 seconds?

This is probably the thing I’ve been looking for since… october 2009?

Also, I just want the function I could use, I want to make this systems if possible, I know I could use timers, but those, Ahh I alway end up messing everything with. Exemples are good too, but I don’t want to have a full code, as it’s for learning, and I want to be proud of what I’d end up with for my gamemode.

Making an AirSoft Game Mode are we? Should be a blast especially if your entire game mode has as much effort as that Derma menu (the one i sent you a PM about) did in it. Unfortunately I do not have an answer to your question, best of luck though.

you would probably have to make a bool that activites on player death and later you would have to create a function that controls if the teams are dead and if they are then you should trigger the bolean. But well, that’s just a logical explaination how i would try to archive that goal. But in reality i just don’t know how to code that either

PlayerDeath and PlayerDeathThink.

It would be awesome if one of the “lua-masters” would give us some support? :slight_smile:

[lua]function BlockingPlayerRespawn()
hook.Add( “PlayerSpawn”, “BlockedPlayerRespawn”, function()
return false end )
timer.Simple(150, function()
for k,v in pairs(player.GetAll()) do
SetGlobalInt(“time”,FW_ROUNDEND)
v:Kill()
v:PrintMessage( HUD_PRINTCENTER, “Round just ended!” )
end
timer.Simple(10, function()
hook.Remove(“PlayerSpawn”, “BlockedPlayerRespawn”)
timer.Simple(10, function()
BlockingPlayerRespawn()
end)
end)
end)
end

hook.Add(“BlockingPlayerRespawn” ,“Rounds”, BlockingPlayerRespawn)[/lua]

I had something like that(Someone had made it for me here), but I never managed to make it work the way I want in the OP.

Take a look at This

I’m not going to stick my gamemode in fretta… It’s not supposed to be a fretta gamemode.

You could borrow the round code from Fretta and implement a similar system.

True, I’ll look onto it. Looks a bit overcomplicated tho.

Edit: I’m sure someone has a very simple round thing like I want laying around, but the fretta one looks like to be a bit too complicated to implement in a base gamemode.

use editline tags… [EDITLINE]Time Here[ /EDITLINE]

**[Player.Spectate

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.Spectate)**

And maybe used with
**[Gamemode.PlayerSpawn

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.PlayerSpawn)**

In theory making them spectators prevents spawning, and you can use the NONE flag to take them out of spectator and spawn them. I wouldn’t know much about the spectator function though since I’ve never used it.

Edit: It’s not restricted to Fretta either, so go nuts.

I have more trouble with Timers and all that jazz for the round system then the death thing, but yet, I want this one to be with the timers.

Anything about them in particular?

Like, on how I could stick all the things together to make it so

Let say -> Round start
A timer of 150 seconds is started from the curtime(), so then after the 150 secs has elapsed, it display the winning team splash, then kills everyone left. And spawn everyone back to their spawns. And again, start the timer. Always.
And togled by a console cmd.
Ooh also, end the timer whenever everyone in a team is dead. And do what’s listed above after the elapsed time.

But yea… I’m really bad when it’s about messing with timers and those things.

Id like to spend more time on this but i have class tomorrow, this is how i would start setting up a round system :

[lua]
function playerDies( victim, weapon, killer )
victim:SetPData(“Dead”, “true”)// when they die sets player data to tell server they are dead
end

hook.Add( “PlayerDeath”, “playerDeathTest”, playerDies )

function playerRespawn( ply )
if ply:GetPData(“Dead”) != “true” then
Msg( “The player, " … ply:GetName() … " has spawned.” )
else
ply:Spectate( OBS_MODE_ROAMING )// if they are dead they spectate
return false;
end
end
hook.Add( “PlayerSpawn”, “playerRespawnTest”, playerRespawn )

nextcheck = 0
gameendtime = 0
roundstage = 0
function Roundtimer()
if (CurTime() >= nextcheck) then
if GetConVarNumber(“Roundson”) == 1 then
if roundstage == 0 then
gameendtime = CurTime() + 20 //150 in your case
roundstage = 1
elseif roundstage == 1 then
Msg("Time left : " … math.Round(gameendtime - CurTime()) … "
")

// just something to see if i was seting pdata right
for k, v in ipairs(player.GetAll()) do 
if v:GetPData("Dead") == "true" then
Msg(v:Name().. " is dead... not big surprise  ")
end
end

if (CurTime() >= gameendtime) then// round is over
Msg("The Round Is Over
")
roundstage = 2// get ready to reset it
end
else
if (CurTime() >= (gameendtime + 5)) then// wait a littel bit
Msg("The Round Restarting
")

// reset code here

for k, v in ipairs(player.GetAll()) do
if v:SetPData(“Dead”) == “false” then// they are no longer dead
// make the player spawn here
end
end
roundstage = 0 // next round
end
end
nextcheck = CurTime() + 0.5 // the tick rate for the think
end
end
end
hook.Add(“Think”, “timerround”, Roundtimer)

CreateConVar(“Roundson”, “0”)// consol command 1 for on, never do 2
[/lua]

sorry for my formatting, I’m a sloppy coder and in a rush right now, I’ll post the final code if i keep working on this, Good luck, hope this helped!

It look good up to now, but I have a bit of trouble with that.

For exemple:
Player spawn in Spectate mode, Yes I had made it fluid with my current code.
Player doesn’t respawn after the round has ended. Even tho I made it call the spawn function.
When roundson is set to 0, it act like if it was there, like player still doesn’t respawn.

But still, thanks alots. I’m tired too atm, maybe that’s why. But I’ll keep it down for now and wait till tomorow.

There is no spawn function for players. If you are calling entity:Spawn() or PlayerSpawn, that’s a very bad idea. If you aren’t already, use spectate\unspectate.
If you are putting them in spectate and then later trying to spawn them, that won’t work until you take them out of spectator first.

Got it so it unspec the player, but ehmm, whenever he unspec, he just spawn back where he was without his loadout and the weapons menu.

Are you setting the mode to none in Spectate() or are you using the Unspectate() function?