Problem with PlayerSpectatePlayer
#1

Hi, I'm Brazilian

I'm creating a server and created a system for admins to see the players, with the cmd "/admintv"
typing this command he puts admin on Spectating mode and puts in the screen two arrows in TextDraw
to admin on mode SelectTextDraw, when the admin click on the arrow next puts to the admin Spectate
the next player and when clicking on the previous arrow puts to the admin Spectate the previous player it in
ascending order of IDS for example if the admin is seeing the player ID 10 if the admin click next places
to the admin Spectate the player ID 11, and so on .

The problem is that when he clicks on the next or previous arrow the server closes

Please help me not getting to solve this problem

This is the code of the arrow next and the arrow previous

I posted a topic with the same question in the area Portuguкs/Portuguese but nobody knew how to help me


pawn Код:
public ClickBotaoProximo(playerid)
{
    idtv[playerid]++;

    if(idtv[playerid] > MAX_JOGADORES) return idtv[playerid] = 0;
    if(!IsPlayerConnected(idtv[playerid])) return ClickBotaoProximo(playerid);
   
    if(IsPlayerInAnyVehicle(idtv[playerid]))
    {
        new carrodotv = GetPlayerVehicleID(idtv[playerid]);
        PlayerSpectateVehicle(playerid, carrodotv);
       
        new string[128];
        format(string,sizeof(string),"[PROXIMO] Vocк avanзou e agora estб vendo o jogador no veiculo [ID: %d]",idtv[playerid]);
        SendClientMessage(playerid, COR_AMARELO,string);
    }
    else
    {
        PlayerSpectatePlayer(playerid, idtv[playerid]);
       
        new string[128];
        format(string,sizeof(string),"[PROXIMO] Vocк avanзou e agora estб vendo o jogador [ID: %d]",idtv[playerid]);
        SendClientMessage(playerid, COR_AMARELO,string);
    }
    return 1;
}

public ClickBotaoAnterior(playerid)
{
    idtv[playerid]--;

    if(idtv[playerid] > MAX_JOGADORES) return idtv[playerid] = 0;
    if(!IsPlayerConnected(idtv[playerid])) return ClickBotaoAnterior(playerid);

    if(IsPlayerInAnyVehicle(idtv[playerid]))
    {
        new carrodotv = GetPlayerVehicleID(idtv[playerid]);
        PlayerSpectateVehicle(playerid, carrodotv);

        new string[128];
        format(string,sizeof(string),"[PROXIMO] Vocк voltou e agora estб vendo o jogador no veiculo [ID: %d]",idtv[playerid]);
        SendClientMessage(playerid, COR_AMARELO,string);
    }
    else
    {
        PlayerSpectatePlayer(playerid, idtv[playerid]);

        new string[128];
        format(string,sizeof(string),"[PROXIMO] Vocк voltou e agora estб vendo o jogador [ID: %d]",idtv[playerid]);
        SendClientMessage(playerid, COR_AMARELO,string);
    }
    return 1;
}
Reply
#2

You must toggle on and off spectating:

Before using PlayerSpectatePlayer or PlayerSpectateVehicle, you muse use: TogglePlayerSpectating(playerid, 1);. Use '0' to disable it again; https://sampwiki.blast.hk/wiki/TogglePlayerSpectating
Reply
#3

Thanks, it's worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)