Spectating a random team player
#1

I've got this:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    if(hasDied[playerid]) {
        new rand = random(playersAliveCount);
        if(gTeam[rand] == gTeam[playerid]) {
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectatePlayer(playerid, rand);
        } else {

        }
        return 0;
    }
}
But I want to make it so that if the random player's team is not the same as the local player's team, it will generate a new random player id and check again.
Reply
#2

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    if(hasDied[playerid])
    {
        new rand = random(playersAliveCount);
        while(gTeam[rand] != gTeam[playerid])
        {
            rand = random(playersAliveCount);
        }
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, rand);
        return 0;
    }
}
Reply
#3

I've got this:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    if(hasDied[playerid])
    {
        new rand = random(playersAliveCount);
        while(gTeam[rand] != gTeam[playerid])
        {
            rand = random(playersAliveCount);
        }
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, rand);
        return 0;
    } else {
        switch(classid) {
            case 0..2: GameTextForPlayer(playerid, "~g~Grove", 3000, 0);
            case 3..5: GameTextForPlayer(playerid, "~p~Ballas", 3000, 0);
        }
        SetPlayerPos(playerid, 2194.7080, -1156.8996, 1029.7968);
        SetPlayerInterior(playerid, 15);
        SetPlayerFacingAngle(playerid, 95.5932);
        SetPlayerCameraPos(playerid, 2191.2080, -1152.8996, 1031.2968);
        SetPlayerCameraLookAt(playerid, 2194.7080, -1156.8996, 1029.7968);
        SetPlayerVirtualWorld(playerid, playerid + 1);
        return 1;
    }
}
public OnPlayerDeath(playerid, killerid, reason)
{
    hasDied[playerid] = true;
    return 1;
}
But I still respawn after dying!
Reply
#4

Use OnPlayerSpawn?
Reply
#5

I try that, and now I only see blueberry beach
Reply
#6

It might be yourself you're trying to spec.

Change the code a bit
pawn Код:
while(rand == playerid || gTeam[rand] != gTeam[playerid])
Reply
#7

It now spectates them, but it shows them as falling in the air, while staying still (almost like they're airbreaking) - should i set my interior to theirs?
Reply
#8

I tried doing this:
pawn Код:
SetPlayerInterior(playerid, GetPlayerInterior(rand));
But now it doesn't even spectate them.
Reply
#9

I really need some help with this...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)