Page 1 of 1

[ACS] Survival ACS Last Life Execute is buggy

Posted: Thu Aug 29, 2019 11:16 pm
by TaporGamingBugReport
I have so long to wait about fix it.

Thanks to TDRR for this code

Code: Select all

int DeadPlayers; //This is a script-scope variable.

Script "Suvival_Death" DEATH
{
     if(PlayerIsSpectator(PlayerNumber()) == 2); //This checks if the player ran out of lives
     {
          DeadPlayers++;
     }
     if(DeadPlayers >= PlayerCount()); //This checks if all players are dead.
     {
          //do whatever you need to do here
     }
}
After so i added ; on 2 ) but it's buggy. TDRR can you fix this?

[ACS] Re: Survival ACS Last Life Execute is buggy

Posted: Sat Aug 31, 2019 3:57 pm
by Fused
Then why did you add it?

Your if statement will no longer execute the code inside now, because the semicolon indicates the end of the action. I'm suprised this even compiled at all.
Removing those semicolons it will fix it.

[ACS] Re: Survival ACS Last Life Execute is buggy

Posted: Sat Aug 31, 2019 5:32 pm
by TaporGamingBugReport
Fixed. but... only 2 players died. they executed the script to goes there instead of all players are dead


Could someone to fix this?

[ACS] Re: Survival ACS Last Life Execute is buggy

Posted: Tue Sep 03, 2019 7:06 pm
by Empyre
Did you remove the semicolon after both of the If statements? The semicolon after the if statement will cause it to execute an empty command block if the condition is true, and then it will always execute the following command block unconditionally.

Also, you have the DeadPlayers variable declared outside of the script, so it is not a script-scope variable despite what the comment says. Every time the script is executed, it will add more to that variable, instead of starting at 0, so it becomes >= PlayerCount() too soon. To fix that, move the variable declaration inside the script, after the first { and before the first if.

[ACS] Re: Survival ACS Last Life Execute is buggy

Posted: Wed Sep 04, 2019 2:21 am
by TaporGamingBugReport
Ok i see... Only 3 or 2 player died to execute the final results but 1 player in server and lost all lives to execute the final results is not compatiable yet.
If someone disconnected the game. Add a requirement to execute round lost.Who need to add it?

Code: Select all

int DeadPlayers; //This is a script-scope variable.

Script "SuvivalDeath" DEATH //Only Compatiable 3 Players in the game
{
     if(!GetCvar("survival")) terminate;
	 	
	 if(!GetPlayerLivesLeft(PlayerNumber()))
	 {
     if(PlayerIsSpectator(PlayerNumber()) == 8);
     {
          DeadPlayers++;
		  Log(n:0, s:" \cgis out!");
     }
     if(DeadPlayers > PlayerCount()) //Not Executed if is one player in the server and died
     {
	      Log(s:"\cgMission Failed!");
	 }
   }
}
but it kinda more buggy if after exiting the map and survived yet

[ACS] Re: Survival ACS Last Life Execute is buggy

Posted: Wed Sep 04, 2019 4:50 pm
by Empyre
What you need is a loop. This code is not tested, but it should, at most, need some minor tweaking.

Code: Select all

#define MaxPlayers 50;
script "SurvivalDeath" DEATH
{
     if (!GetCvar("survival")) terminate;
     int DeadPlayers;
     for (int I = 0; I < MaxPlayers; I++)
     {
          if (PlayerInGame(I))
               if (PlayerIsSpectator(I) == 8)
               {
                    DeadPlayers++;
                    If (PlayerNumber() == I)
                        Log(n:0, s:" \cgis out!");
               }
     }
     if(DeadPlayers >= PlayerCount())
     {
	      Log(s:"\cgMission Failed!");
     }
}

[ACS] Re: Survival ACS Last Life Execute is buggy

Posted: Sun Sep 08, 2019 8:36 am
by TaporGamingBugReport
Empyre wrote:
Wed Sep 04, 2019 4:50 pm
What you need is a loop. This code is not tested, but it should, at most, need some minor tweaking.

Code: Select all

#define MaxPlayers 50;
script "SurvivalDeath" DEATH
{
     if (!GetCvar("survival")) terminate;
     int DeadPlayers;
     for (int I = 0; I < MaxPlayers; I++)
     {
          if (PlayerInGame(I))
               if (PlayerIsSpectator(I) == 8)
               {
                    DeadPlayers++;
                    If (PlayerNumber() == I)
                        Log(n:0, s:" \cgis out!");
               }
     }
     if(DeadPlayers >= PlayerCount())
     {
	      Log(s:"\cgMission Failed!");
     }
}
I tested out but... wont work. Semicolon is too buggy to risk the script should you add the semicolons?

[ACS] Re: Survival ACS Last Life Execute is buggy

Posted: Mon Sep 09, 2019 6:27 pm
by Fused
I think you should slow down a bit and try something easier, because this type of code is still a little advanced for you. There's no need for any extra stray semicolons, and a script like this isn't too hard at all. Even if you get a working script, you will quickly have a problem with including new features since you have no clue what each block of code does. Perhaps you should try and make something a little more simple first?