Ending "rounds" and determining alive players
#1

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.
Reply
#2

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
Reply
#3

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

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
Reply
#5

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
}
Reply
#6

yep it will
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)