• Round system crash?
    10 replies, posted
Hello. This is like the 4th help thread I've posted (Will probably be my last) in the last few days, as I've just started my first Luanda project. It's coming together nicely, but I've run into another problem. I have a round system script (Thanks to Luni and Fortune) that crashes when one of the last 2 players is propkilled (which is the goal of the game), the server crashes. Dedicated servers stop responding until they eventually close, and a listen server closes immediately, so I can't track down the issue. It's strange, as the script works fine when I slay onea of the last players. Here's the code(keep in mind that team 1 is spectators and team 2 is alive players):[code] function GM:PlayerDeath(ply, inflictor, attacker) -- just in case i guess? if ply:Team() == 1 then return end -- would there be 1 person left if we changed him? if team.NumPlayers(2) <= 2 then -- end of round: set everyone back to normal for _,ply in ipairs(team.GetPlayers(2)) do PrintMessage(HUD_PRINTCENTER, ply:GetName().. " wins! Restarting...") game.CleanUpMap() for k, v in pairs(player.GetAll()) do v:SetTeam(2) v:Spawn() end return end else ply:SetTeam(1) end end [/code] EDIT: The post is a little screwed up as I'm writing this on a mobile device. My apologies.
Do you get any console output with it? Here's the cleaned up code, for anyone needing it (I only split it to more than one line, didn't change anything) [lua]function GM:PlayerDeath(ply, inflictor, attacker) -- just in case i guess? if ply:Team() == 1 then return end -- would there be 1 person left if we changed him? if team.NumPlayers(2) <= 2 then -- end of round: set everyone back to normal for _,ply in ipairs(team.GetPlayers(2)) do PrintMessage(HUD_PRINTCENTER, ply:GetName().. " wins! Restarting...") game.CleanUpMap() for k, v in pairs(player.GetAll()) do v:SetTeam(2) v:Spawn() end return end else ply:SetTeam(1) end end[/lua]
Try removing game.CleanUpMap(). I don't really see why anything else there would crash it.
[QUOTE=Fortune11709;42361541]Try removing game.CleanUpMap(). I don't really see why anything else there would crash it.[/QUOTE] I doubt that's the cause, as it works fine if I slay the player instead. I'll give it a try and tell you if anything changes. EDIT: Wow, that somehow worked. This sucks though, as the game is based around people slinging props at eachother, so I would like the map to reset so we can get the broken props back. At least we know the cause of it so we can hopefully solve the issue. Thanks!
Try this: [CODE]function GM:PlayerDeath(ply, inflictor, attacker) -- just in case i guess? if ply:Team() == 1 then return end -- would there be 1 person left if we changed him? if team.NumPlayers(2) <= 2 then game.CleanUpMap() -- end of round: set everyone back to normal for _,ply in ipairs(team.GetPlayers(2)) do PrintMessage(HUD_PRINTCENTER, ply:GetName().. " wins! Restarting...") for k, v in pairs(player.GetAll()) do v:SetTeam(2) v:Spawn() end return end else ply:SetTeam(1) end end[/CODE] Not sure if this will work, but it might help.
[QUOTE=Fortune11709;42362179]Try this: [CODE]function GM:PlayerDeath(ply, inflictor, attacker) -- just in case i guess? if ply:Team() == 1 then return end -- would there be 1 person left if we changed him? if team.NumPlayers(2) <= 2 then game.CleanUpMap() -- end of round: set everyone back to normal for _,ply in ipairs(team.GetPlayers(2)) do PrintMessage(HUD_PRINTCENTER, ply:GetName().. " wins! Restarting...") for k, v in pairs(player.GetAll()) do v:SetTeam(2) v:Spawn() end return end else ply:SetTeam(1) end end[/CODE] Not sure if this will work, but it might help.[/QUOTE] That crashes just like before. I'm thinking I might need to just leave the cleanup out. Thanks for the help anyways :smile:
Try this: [CODE]function GM:PlayerDeath(ply, inflictor, attacker) -- just in case i guess? if ply:Team() == 1 then return end -- would there be 1 person left if we changed him? if team.NumPlayers(2) <= 2 then -- end of round: set everyone back to normal for _,ply in ipairs(team.GetPlayers(2)) do PrintMessage(HUD_PRINTCENTER, ply:GetName().. " wins! Restarting...") for k, v in pairs(player.GetAll()) do v:SetTeam(2) v:Spawn() end return end else ply:SetTeam(1) game.CleanUpMap() end end[/CODE] I'm not sure if moving it might help, but it is worth a try.
You could just remove the cleanup all together to see if it fixes the problem.
[QUOTE=Fortune11709;42362315]Try this: [CODE]function GM:PlayerDeath(ply, inflictor, attacker) -- just in case i guess? if ply:Team() == 1 then return end -- would there be 1 person left if we changed him? if team.NumPlayers(2) <= 2 then -- end of round: set everyone back to normal for _,ply in ipairs(team.GetPlayers(2)) do PrintMessage(HUD_PRINTCENTER, ply:GetName().. " wins! Restarting...") for k, v in pairs(player.GetAll()) do v:SetTeam(2) v:Spawn() end return end else ply:SetTeam(1) game.CleanUpMap() end end[/CODE] I'm not sure if moving it might help, but it is worth a try.[/QUOTE] That removes the crash, but resets the map every time someone is killed. Almost there! Thanks :D
[QUOTE=BoastingToast;42362422]That removes the crash, but resets the map every time someone is killed. Almost there! Thanks :D[/QUOTE] Move it to just before the else, see if that works.
[QUOTE=Ghost_Sailor;42362828]Move it to just before the else, see if that works.[/QUOTE] That didn't work, but putting it just after "return" worked like a charm! Thanks for all the help guys!
Sorry, you need to Log In to post a reply to this thread.