Page 1 of 1

Script that ends the game after ALL of the players are dead.

Posted: Fri Jun 02, 2017 11:10 am
by Scraper
Can someone please help me? I am making a map that should be played in 2+ players, but I want the game to end after ALL the players are dead, not after only one player is alive.
What I mean was, is there any script to PREVENT Gameover if there is only one player remaining?

Re: Script that ends the game after ALL of the players are dead.

Posted: Tue Jun 06, 2017 10:11 pm
by jamisco
You are probably going to have to override the method that triggers game over, in which I don't think gurt has released that to the public yet

Re: Script that ends the game after ALL of the players are dead.

Posted: Wed Jun 07, 2017 3:58 pm
by JakSparro98
Scraper wrote:
Fri Jun 02, 2017 11:10 am
Can someone please help me? I am making a map that should be played in 2+ players, but I want the game to end after ALL the players are dead, not after only one player is alive.
What I mean was, is there any script to PREVENT Gameover if there is only one player remaining?
You can prevent gameover only if you change the map type to "custom", then the script will handle the gameover and the showed text.
This could be the script you wanted, I've not considered bots as players in this though:

Code: Select all

 Events.UpdateCallback m_updateEvent = null;

 public void OnStartup() {
    m_updateEvent = Events.UpdateCallback.Start(OnUpdate, 0);
 }
 public void OnUpdate(float elapsed) {
foreach(IPlayer temp in Game.GetPlayers())
if(!temp.IsBot && !temp.IsDead)
return;

Game.SetGameOver("some text");
 }