SA-MP Forums Archive
auto spec after death problem - 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: auto spec after death problem (/showthread.php?tid=593431)



auto spec after death problem - CraTzy - 05.11.2015

So , when a player died he spec others till map dont finish
but when they die they see other player's afk , any help ?

all i can give u is the stock

pawn Код:
stock StartSpectate(playerid, specplayerid)
{
    if(playerid == specplayerid) return StartSpectate(playerid, GetRandomPlayer(playerid));
    for(new x=0; x<MAX_PLAYERS; x++) {
        if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && PlayerData[x][SpecID] == playerid) {
           AdvanceSpectate(x);
        }
    }
    SetPlayerInterior(playerid,GetPlayerInterior(specplayerid));
    SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(specplayerid));
    TogglePlayerSpectating(playerid, 1);
    Spectekiler[playerid] = 1;

    if(IsPlayerInAnyVehicle(specplayerid)) {
        PlayerSpectateVehicle(playerid, GetPlayerVehicleID(specplayerid));
        PlayerData[playerid][SpecID] = specplayerid;
        PlayerData[playerid][SpecType] = ADMIN_SPEC_TYPE_VEHICLE;
    }
    else {
        PlayerSpectatePlayer(playerid, specplayerid);
        PlayerData[playerid][SpecID] = specplayerid;
        PlayerData[playerid][SpecType] = ADMIN_SPEC_TYPE_PLAYER;
    }
    return 1;
}



Re: auto spec after death problem - jeffery30162 - 05.11.2015

so you want to spectate the player that killed you correct?

Well you need to on playerdeath just spectate that player that killed you, then make a timer that runs every idk 3 seconds to check if the player you are spectating is still alive, if he is not alive, find someone that is alive to spectate.


Re: auto spec after death problem - CraTzy - 05.11.2015

hmm , i got this on player death

pawn Код:
public OnPlayerDeath(playerid, killerid, reason){
    if(GetServerCount() > 1)
    {
        SetPVarInt(playerid, "Geberdi", 1);
        StartSpectate(playerid, GetRandomPlayer(playerid));
    } else
    if(GetServerCount() == 1)
    {
        ProgressForMap();
    }
    return true;
}

stock GetAliveCount(){
    new p_Count;
    for(new i = 0; i < MAX_PLAYERS; i++){
    if(IsPlayerConnected(i)){
    if(GetPVarInt(i, "Geberdi") == 0){
    p_Count++;
    }}}
    return p_Count;
}