SA-MP Forums Archive
Ending "rounds" and determining alive players - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Ending "rounds" and determining alive players (/showthread.php?tid=522813)



Ending "rounds" and determining alive players - [NWA]Hannes - 29.06.2014

Hello, I am currently working on a FFA/TDM script, where I'm thinking about having so called "game rounds".

My thought is that in FFA everybody will be randomly scattered across a map with weapons, then they find eachother and kill eachother, and in TDM there will be one spawn for each team and they get to killeachother too, might add different objectives as time progresses.

When you die you will enter spectate mode and you can spectate people who are still alive, however I ran into the problem that when everybody are dead the script will bug out and there will be nobody to spectate, causing everybody to become stuck inside spectate mode.

I need some kind of function to see how many are still alive in a "round", and when one of the last two players kill the other, he/she will be deemed the winner of the round and will receive a reward.

It's similar to Counter-Strike DM modes without instant respawn.

Any help is appreciated.


Re: Ending "rounds" and determining alive players - BroZeus - 29.06.2014

https://sampforum.blast.hk/showthread.php?tid=92679
see here
use Iter_add o player join the round
use Iter_remove when player is dead
usage of them is explained in link


Re: Ending "rounds" and determining alive players - [NWA]Hannes - 29.06.2014

I don't quite understand how to use the iterators, could you please give me an example of such usage?


Re: Ending "rounds" and determining alive players - BroZeus - 29.06.2014

just an example
pawn Code:
#include <foreach>

new Iterator:TDM<MAX_PLAYERS>;


Iter_Add(TDM, playerid);//now this when a player joins

//now this all when a player dies
if(Iter_Contains(TDM, playerid))Iter_Remove(TDM, playerid);//this should be in player disconnect too

PlayerSpectatePlayer(playerid, Iter_Random(TDM));//to spectate random players



Re: Ending "rounds" and determining alive players - [NWA]Hannes - 29.06.2014

Would something like this work?

pawn Code:
#include <foreach>

new Iterator:DM<MAX_PLAYERS>;

//OnPlayerDisconnect
if(Iter_Contains(DM, playerid)) Iter_Remove(DM, playerid);

//OnPlayerDeath
if(Iter_Contains(DM, playerid)) Iter_Remove(DM, playerid);
RoundCheck();
PlayerSpectatePlayer(playerid, Iter_Random(DM));

//The function
forward RoundCheck();
public RoundCheck()
{
    new Count;

    foreach(new x:DM)
    {
        Count++;
    }

    if(Count == 1) //Last player alive, place some kind of end round function here
}



Re: Ending "rounds" and determining alive players - BroZeus - 29.06.2014

yep it will