• Round system?
    5 replies, posted
Hello there, I am making a Jail break Game mode, NON FRETTA. (I understand with fretta its simple and easy to make a round system, how ever i do NOT want to use fretta, Please dont ask why, I just dont like it, so please dont post anything about fretta cause i will just ignore it). Anyway, I wanted to make a round system, where if 1 team have no players in it, then the round will restart after 5 seconds, I was looking at another game mode, and altered there round system , and created this; [code][lua]-- Round system function GM:Think() for _, ply in pairs( player.GetAll() ) do ply:AFK() if ply:IsAFK() then if ply:Team() != 5 then ply:SetTeam( 5 ) ply:Spawn() end end end if team.NumPlayers( 1) > 0 then if team.NumPlayers( 3 ) > 0 then local alive = false for _, ply in pairs( team.GetPlayers( 3 ) ) do if ply:Alive() then alive = true break end end if !alive and RESTARTING < 0 then RESTARTING = CurTime() + 5 for _, ply in pairs( player.GetAll() ) do ply:ChatPrint( "The Guards have slayed all the prisoners, New round in 5 seconds." ) end elseif alive then alive = false for _, ply in pairs( team.GetPlayers( 1 ) ) do if ply:Alive() then alive = true break end end if !alive and RESTARTING < 0 then RESTARTING = CurTime() + 5 for _, ply in pairs( player.GetAll() ) do ply:ChatPrint( "The Prisoners have rebelled! New round in 5 seconds." ) end end end else local alive = false for _, ply in pairs( team.GetPlayers( 3 ) ) do if ply:Alive() then alive = true break end end if alive and RESTARTING < 0 then RESTARTING = CurTime() + 5 for _, ply in pairs( player.GetAll() ) do ply:ChatPrint( "The Prisoners have rebelled! New round in 5 seconds." ) end end end end self:NewRound() end function GM:NewRound() RESTARTING = RESTARTING or -1 if !(RESTARTING > 0 and CurTime() > RESTARTING) then return end RESTARTING = -1 self:NewDeath() umsg.Start( "newround", player.GetAll() ) umsg.End() end[/lua][/code] But that didnt work, Basically I am wondering how to make a round system, because when i start the game mode (for testing) a menu pops up, asking me which team i would like to choose, Guard | Spectate | Prisoner And if you select Guard | Prisoner, You move to the Dead (Gaurd / prisoner) team, and so therefore i wasnt sure how to get the round system working, I would like a simple round system, where if 1 team has no players, then It will say the other team wins, and a new round will commence in 5 seconds, 1 thing i got confused over is that, if i managed to get a round system, is that when you first join and select a team to join, you will be on the dead side of that team, well if your the first player then surley it would just be stuck, Thats what i was getting confused over. Im sorry if this post has made you confused reading it, I know its odd but if you suffer from TL;DR then its this Im having trouble making a round system where if 1 team has no players on it, then it says the opposite team has won and a new round will commence in 5 seconds, When you join the server a menu will pop up asking u which team to join, when you select a team you join the dead version of that team, so Guard -> Dead Guard. I would also liek the round system to work for the first player who joins the server etc. as they will be in the dead team. Some information Guard Team = 1 Dead Guard Team = 2 Prisoner Team = 3 Dead Prisoner Team = 4 Spectator Team = 5 Thankyou for reading, Take care.
I litterally wrote this on the spot. Check for lua errors in-game. I didn't bother writing RoundRestart. And I don't know how scoring works in your game, so I just overid garry's team.AddScore to check if someone should win(hits winning score or not enough players). [lua] WinningScore = 25 NextRoundTime = 5 isResetting = false function RoundRestart() //All your round restart setup code goes here end function team.AddScore(team, points)//overwrite AddScore to do our check local teamscore = team.GetScore(team)//get the team's score team.SetScore(team, teamscore + points)//add points to it CheckScore()//check to see if someone won. end function checkTeams( ply )//Someone left CheckScore()//Check to see if someone should win end function CheckScore() if isResetting then return end//Has a winning team been declared? local someoneWon = false//By default, no one won if #team.GetPlayers(1) == 0 or team.GetScore(3) >= WinningScore then//No one is a guard or did a team win? team.SetScore (3, WinningScore)//Make prisoners win instantly for k,v in pairs ( player.GetAll( ) ) do v:PrintMessage( HUD_PRINTTALK, "Prisoners win! Round will restart in " .. NextRoundTime .. " seconds." " )//A win message end someoneWon = true elseif #team.GetPlayers(3) == 0 or team.GetScore(1) >= WinningScore then team.SetScore (1, WinningScore)//Make guards win instantly for k,v in pairs ( player.GetAll( ) ) do v:PrintMessage( HUD_PRINTTALK, "Guards win! Round will restart in " .. NextRoundTime .. " seconds." )//Ditto end someoneWon = true end if someoneWon then isResetting = true//Round is pending reset, wining team declared. timer.Simple(NextRoundTime, function() RoundRestart()//This obviously doesn't exist, go write it. isResetting = false//Round is no longer pending reset end) end end hook.Add( "PlayerDisconnected", "team_checking_hook", checkTeams ) [/lua] Sidenote: Not sure why you want to create a completely new team for dead people... You can just prevent people from spawning(counterstrike does it just fine)
Hey Gryphian, Thanks so much for making me a round system, I changed the text of the messages and went to fire up this beauty, but there was a extra " i removed, then there wasnt enough "<eof>" so i added the rightammount in, now its not working it says, [gamemodes\jailbreak\gamemode\init.lua:277] '<eof>' expected near 'end' [cpp] Here is the code; [lua]-- ROUND SYSTEM <3 WinningScore = 25 NextRoundTime = 5 isResetting = false function RoundRestart() if ply:Team()== ( 2 ) then ply:SetTeam( 1 ) elseif ply:Team()== ( 4 ) then ply:SetTeam( 3 ) end function team.AddScore(team, points)//overwrite AddScore to do our check local teamscore = team.GetScore(team)//get the team's score team.SetScore(team, teamscore + points)//add points to it CheckScore()//check to see if someone won. end function checkTeams( ply )//Someone left CheckScore()//Check to see if someone should win end function CheckScore() if isResetting then return end//Has a winning team been declared? local someoneWon = false//By default, no one won if #team.GetPlayers(1) == 0 or team.GetScore(3) >= WinningScore then//No one is a guard or did a team win? team.SetScore (3, WinningScore)//Make prisoners win instantly for k,v in pairs ( player.GetAll( ) ) do v:PrintMessage( HUD_PRINTTALK, "The Prisoners have rebelled against the Guards! The round will restart in " .. NextRoundTime .. " seconds." )//A win message end someoneWon = true elseif #team.GetPlayers(3) == 0 or team.GetScore(1) >= WinningScore then team.SetScore (1, WinningScore)//Make guards win instantly for k,v in pairs ( player.GetAll( ) ) do v:PrintMessage( HUD_PRINTTALK, "The Guards have slain all the Prisoners! The round will restart in " .. NextRoundTime .. " seconds." )//Ditto end someoneWon = true end if someoneWon then isResetting = true//Round is pending reset, wining team declared. timer.Simple(NextRoundTime, function() RoundRestart()//This obviously doesn't exist, go write it. isResetting = false//Round is no longer pending reset end) end end end end // THIS IS LINE 277 end end hook.Add( "PlayerDisconnected", "team_checking_hook", checkTeams )[/lua]
It's honestly no problem. How come there are so many "ends" ? Not sure how those got in there, but also you forget an end up top in RoundRestart() Fixed and tested: [lua] -- ROUND SYSTEM <3 WinningScore = 25 NextRoundTime = 5 isResetting = false function RoundRestart() if ply:Team()== ( 2 ) then ply:SetTeam( 1 ) elseif ply:Team()== ( 4 ) then ply:SetTeam( 3 ) end end function team.AddScore(team, points)//overwrite AddScore to do our check local teamscore = team.GetScore(team)//get the team's score team.SetScore(team, teamscore + points)//add points to it CheckScore()//check to see if someone won. end function checkTeams( ply )//Someone left CheckScore()//Check to see if someone should win end function CheckScore() if isResetting then return end//Has a winning team been declared? local someoneWon = false//By default, no one won if #team.GetPlayers(1) == 0 or team.GetScore(3) >= WinningScore then//No one is a guard or did a team win? team.SetScore (3, WinningScore)//Make prisoners win instantly for k,v in pairs ( player.GetAll( ) ) do v:PrintMessage( HUD_PRINTTALK, "The Prisoners have rebelled against the Guards! The round will restart in " .. NextRoundTime .. " seconds." )//A win message end someoneWon = true elseif #team.GetPlayers(3) == 0 or team.GetScore(1) >= WinningScore then team.SetScore (1, WinningScore)//Make guards win instantly for k,v in pairs ( player.GetAll( ) ) do v:PrintMessage( HUD_PRINTTALK, "The Guards have slain all the Prisoners! The round will restart in " .. NextRoundTime .. " seconds." )//Ditto end someoneWon = true end if someoneWon then isResetting = true//Round is pending reset, wining team declared. timer.Simple(NextRoundTime, function() RoundRestart()//This obviously doesn't exist, go write it. isResetting = false//Round is no longer pending reset end) end end hook.Add( "PlayerDisconnected", "team_checking_hook", checkTeams ) [/lua]
Hey, I literally copy and pasted your new code, And i went to test it and its not working :S I will pm you my whole init lua, as i dont really want everyone having it aha, I also made a video of what happens when the game mode starts, link here ; [url]http://www.youtube.com/watch?v=w9rvtXuD0lo&feature=youtube_gdata[/url] I think this isnt working because of the dead teams, (team 2 and team 4) If this is the case, do you recommend me removing the dead teams and making it so when they are dead, they can not spawn untill next round? if so , could you also help me with that? :3 Thankyou so much for helping again, really apreciate it, Im also going out of town tonight untill late tomorow, so please still reply i just wont get back to you until late tomorow, but i see you live in the usa, So it might not affect you, due to time zones (:
Well, for the thing that you dont spawn with weapons, use GM:PlayerSpawn(ply) And then use if (ply:Team() == yourteam) then ply:Give("weapon_id") ply:GiveAmmo("pistol or rife") end for example: [LUA] function GM:PlayerSpawn(ply) if (ply:Team() == yourteam) then ply:Give("weapon_id") ply:GiveAmmo("pistol or rife") end end [/LUA] Keep using that to make it so when the player spawns it give's them the weapons, also for the Notification use [LUA]v:ChatPrint("The message")[/LUA] instead of [LUA]v:PrintMessage( HUD_PRINTTALK, "The Prisoners have rebelled against the Guards! The round will restart in " .. NextRoundTime .. " seconds." )[/LUA] And it should paste it in chat. If you need any help don't hesitate to PM Me. Thanks :)
Sorry, you need to Log In to post a reply to this thread.