Specating enemy after dead if team #1 is fully dead
#1

I am trying to make if team 1 is completely dead it would spec team 2, it's a no-respawn gamemode.

Currently i have this code:
pawn Code:
stock GetRandomTeamPlayerForPlayer(playerid)
{
    new rand = -1;
    new team = mTeam[playerid];
    new Float:health;
    while(rand == -1)
    {
        rand = random(MAX_PLAYERS);
        if(!IsPlayerConnected(rand)) rand = -1;
        if(TeamCounting[team] != 0 && team == mTeam[rand]) rand = -1;
        GetPlayerHealth(rand, health);
        if(health <= 0) rand = -1;
    }
    return rand;
}
Butt his code makes everyone respawn.
Reply
#2

Set a variable to true OnPlayerDeath and at the same time check if the variable is true for the rest of the team, if it is, set all to spectatem, if it's not; do whatever you like x)
Remember to return false inside OnPlayerSpawn, if not they will respawn.
Reply
#3

i have updated the code:
It's not spectating the enemy, but just looking at the water + bridge...
pawn Code:
stock GetRandomTeamPlayerForPlayer(playerid)
{
    new rand = -1;
    new Float:health;
    if(ThisMode == 1)
    {
    while(rand == -1)
    {
    rand = random(MAX_PLAYERS);
    if(mTeam[rand] != mTeam[playerid] || !IsPlayerConnected(rand)) rand = -1;
    GetPlayerHealth(rand, health);
    if(health <= 0) rand = -1;
    }
    return rand;
}
    else if(ThisMode == 2)
    {
    while(rand == -1)
    {
    rand = random(MAX_PLAYERS);
    if(!IsPlayerConnected(rand)) rand = -1;
    GetPlayerHealth(rand, health);
    if(health <= 0) rand = -1;
    }
}
    return rand;
}
Reply
#4

Anybody?
Reply
#5

Indention is your friend.

And this code is not enough to figure out why everyone is re-spawning, so the code where you use this function.
Reply
#6

I have fixed the no-respawning. Except the spectating enemy. Now it just looks at the bridge :S
Reply
#7

Maybe it's trying to spectate yourself. Add
pawn Code:
if(rand == playerid) rand = -1;
Reply
#8

Didn't work :S
Reply
#9

bump :S.
Reply
#10

Bump again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)