Well I wondered if anyone could point me out on how I could add a round based respawn system in my gamemode?
Note that my gamemode is getting pretty complete, and I just really wondered on how to do that, as for now, I was just sticking with insta respawn and random spawnpoints.
With time.
Also, when someone die, he stay dead until the next round.
I tryed some things quite a while ago, but none ended working.
I know this would be easy on fretta, but I'm not using fretta.
Thanks.
(Also, my respawn point are alway random, and they don't respect my code.
[CODE]function GM:GetSpawnPoints()
combine_spawns = {}
table.Add(combine_spawns, ents.FindByClass("info_player_counterterrorist"))
table.Add(combine_spawns, ents.FindByClass("info_player_combine"))
table.Add(combine_spawns, ents.FindByClass("info_player_deathmatch"))
table.Add(combine_spawns, ents.FindByClass("info_player_axis"))
rebel_spawns = {}
table.Add(rebel_spawns, ents.FindByClass("info_player_terrorist"))
table.Add(rebel_spawns, ents.FindByClass("info_player_rebel"))
table.Add(rebel_spawns, ents.FindByClass("info_player_deathmatch"))
table.Add(rebel_spawns, ents.FindByClass("info_player_allies"))
end[/CODE]
Like someone in the rebel team, will end up respawning on the other team spawn, etc.)
Ok for the timer just make variable with the start round time then use a timer and take away 1 from it every second.
for checking if team has no players left use
[b][url=http://wiki.garrysmod.com/?title=Team.GetPlayers]Team.GetPlayers [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
and to check if they are alive use
[b][url=http://wiki.garrysmod.com/?title=Player.Alive]Player.Alive [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Mhmh, an exemple would be greatly apreciated, as I'm really a novice in lua. Better with sweps, gamemode are sometime a pain to code.
If your asking me to code it for you its not going to happen
I'm not asking directly to you, I'm asking for someone that has a lil time to make a snippet of code just to show me how I would do so. I know some people are helpful here.
The best way to learn is by doing it your self
[QUOTE=|King Flawless|;21213384]The best way to learn is by doing it your self[/QUOTE]
Actualy, no. Not everyone learn by error and try, I did that so many time for that damn timer and all, never got anything to work, so I'm asking on how to get it to work.
Well then find a gamemode doing what you want to do and rip the code because thats clearly what you want to do
Not what I want, I just want the basic on how to do so, and a bit explained.
Wow king Flawless why cant you just help him learn? I would if i was more advanced at lua, he doesnt want it completely done just a basic outline and he can do the rest
I'm not familiar with gamemodes, but wouldn't you just do something like this?
[lua]
function BlockingPlayerRespawn()
hook.Add( "PlayerSpawn", "BlockedPlayerRespawn", function()
return false end )
timer.Simple(600, function()
for k,v in pairs(player.GetAll()) do
v:Kill()
v:ChatPrint("This Round has ended")
end
timer.Simple(10, function()
hook.Remove("PlayerSpawn", "BlockedPlayerRespawn")
end)
end)
end
[/lua]
When this is executed it stops players respawning , then 10 minutes later it kills everyone and 10 seconds after this it allows everyone to spawn. I don't know if this would work properly, as I am not familiar with gamemodes, but I guess you can figure out how to adapt it.
[QUOTE=sintwins;21228238]I'm not familiar with gamemodes, but wouldn't you just do something like this?
[lua]
function BlockingPlayerRespawn()
hook.Add( "PlayerSpawn", "BlockedPlayerRespawn", function()
return false end )
timer.Simple(600, function()
for k,v in pairs(player.GetAll()) do
v:Kill()
v:ChatPrint("This Round has ended")
end
timer.Simple(10, function()
hook.Remove("PlayerSpawn", "BlockedPlayerRespawn")
end)
end)
end
[/lua]
When this is executed it stops players respawning , then 10 minutes later it kills everyone and 10 seconds after this it allows everyone to spawn. I don't know if this would work properly, as I am not familiar with gamemodes, but I guess you can figure out how to adapt it.[/QUOTE]
Ooh yes I think I could easily make this fit into a gamemode, exactly what I was lookin' for! A good base to work on and manage to learn out on how I could have done it.
Thanks alot!
I wondered something too, does it start again once player respawn? I'm unsure about where I could call it so it repeat, but I'll try somethings.
This will give players 10 seconds to respawn and then start again.
[lua]
function BlockingPlayerRespawn()
hook.Add( "PlayerSpawn", "BlockedPlayerRespawn", function()
return false end )
timer.Simple(600, function()
for k,v in pairs(player.GetAll()) do
v:Kill()
v:ChatPrint("This Round has ended")
end
timer.Simple(10, function()
hook.Remove("PlayerSpawn", "BlockedPlayerRespawn")
timer.Simple(10, function()
BlockingPlayerRespawn()
end)
end)
end)
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.