Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

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

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Scraper
Fighter
Fighter
Posts: 22
Joined: Tue Nov 01, 2016 9:06 am
SFD Account: Scrapper
SFD Alias: Scrapper
Started SFD: PreAlpha 1.7.1
Gender:

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

Post by Scraper » 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?
0 x

jamisco
Superfighter
Superfighter
Posts: 67
Joined: Sun Nov 06, 2016 11:34 pm
Title: Da God
SFD Account: Jamisco
SFD Alias: Jamisco
Started SFD: either late 2015 or early 2016
Location: Somewhere in the east of the United states
Gender:
Age: 103

Post by jamisco » Tue Jun 06, 2017 10:11 pm

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
0 x
Is it better to be feared or respected... please, is it too much to ask for both?

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Wed Jun 07, 2017 3:58 pm

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");
 }
0 x

Post Reply