spec textdraw shows my own info
#1

I need help with fixing this. I am using textdraws to get players information when using /spectate on them, but whenever i use it, it shows my own information, i am trying to figure this out, but it only increases the amount of bugs.
here's the code:

pawn Код:
forward AdminSpectate(playerid);
public AdminSpectate(playerid) // Timer update
{
    new id;
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Player Not Connected.");
    {
    new Name[MAX_PLAYER_NAME], ip[16], tdstring[128];
    new Float:health, Float:armour;
    GetPlayerName(id, Name, sizeof(Name));
    GetPlayerHealth(id, health);
    GetPlayerArmour(id, armour);
    GetPlayerIp(id, ip, 16);
    format(tdstring, sizeof(tdstring), "Name: %s", Name);
    TextDrawSetString(Textdraw0[id], tdstring);
    format(tdstring, sizeof(tdstring), "Health: %.0f", health);
    TextDrawSetString(Textdraw111[id], tdstring);
    format(tdstring, sizeof(tdstring), "Armor: %.0f", armour);
    TextDrawSetString(Textdraw2[id], tdstring);
    format(tdstring, sizeof(tdstring), "Ping: %d", GetPlayerPing(id));
    TextDrawSetString(Textdraw3[id], tdstring);
    format(tdstring, sizeof(tdstring), "IP: %s", ip);
    TextDrawSetString(Textdraw5[id], tdstring);
    format(tdstring, sizeof(tdstring), "Money: $%d", GetPlayerMoney(id));
    TextDrawSetString(Textdraw6[id], tdstring);
    }
    return 1;
}

CMD:spec
{
    Spectating[playerid] = id;
    TogglePlayerSpectating(playerid, 1);
    new Name[MAX_PLAYER_NAME], ip[16], tdstring[128];
    new Float:health, Float:armour;
    GetPlayerName(id, Name, sizeof(Name));
    GetPlayerHealth(id, health);
    GetPlayerArmour(id, armour);
    GetPlayerIp(id, ip, 16);
    new png = GetPlayerPing(id);
    TextDrawShowForPlayer(playerid, Textdraw3[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw44[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw7[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw8[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw9[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw10[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw111[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw2[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw5[playerid]);
    format(tdstring, sizeof(tdstring), "Name: %s", Name);
    TextDrawSetString(Textdraw0[id], tdstring);
    format(tdstring, sizeof(tdstring), "Health: %.0f", health);
    TextDrawSetString(Textdraw111[id], tdstring);
    format(tdstring, sizeof(tdstring), "Armor: %.0f", armour);
    TextDrawSetString(Textdraw2[id], tdstring);
    format(tdstring, sizeof(tdstring), "Ping: %d", png);
    TextDrawSetString(Textdraw3[id], tdstring);
    format(tdstring, sizeof(tdstring), "IP: %s", ip);
    TextDrawSetString(Textdraw5[id], tdstring);
    format(tdstring, sizeof(tdstring), "Money: $%i", GetPlayerMoney(id));
    TextDrawShowForPlayer(playerid, Textdraw6[playerid]);
    TextDrawSetString(Textdraw6[id], tdstring);
        PlayerSpectatePlayer(playerid, id);
}
I have AdminSpectate timer OnGameModeInit, glad if anyone could help
Reply
#2

help pls
Reply
#3

Huh where are you calling the target player which you are gonna spectate? add them in the 2nd line of ur command.
pawn Код:
if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /spec [playerid]");
    if(playerid == id) return SendClientMessage(playerid, COLOR_GREY, "You can't spectate yourself.");
Reply
#4

The code is there, i just didnt show it because i don't think it is necessary.

pawn Код:
CMD:spec(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, 0xFFFFFFAA, "{627D80}Error: You are not allowed to use this.");
    new id;
    if(sscanf(params, "d", id)) return SendClientMessage(playerid, 0xFFFFFFAA, "{627D80}Usage: /spec <ID>.");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFFFFAA, "{627D80}That player is not connected!");
All i wonder is why is it getting my information on the textdraw and not the player being specced.
Reply
#5

Quote:
Originally Posted by GwENiko
Посмотреть сообщение
The code is there, i just didnt show it because i don't think it is necessary.

pawn Код:
CMD:spec(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, 0xFFFFFFAA, "{627D80}Error: You are not allowed to use this.");
    new id;
    if(sscanf(params, "d", id)) return SendClientMessage(playerid, 0xFFFFFFAA, "{627D80}Usage: /spec <ID>.");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFFFFAA, "{627D80}That player is not connected!");
All i wonder is why is it getting my information on the textdraw and not the player being specced.
forward AdminSpectate(id);
Public AdminSpectate(id)

And remove new id;

Guess that'll work
Reply
#6

or just edit this line
pawn Код:
//
    TextDrawShowForPlayer(playerid, Textdraw3[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw44[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw7[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw8[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw9[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw10[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw111[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw2[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw5[playerid]);
    format(tdstring, sizeof(tdstring), "Name: %s", Name);
    TextDrawSetString(Textdraw0[id], tdstring);
    format(tdstring, sizeof(tdstring), "Health: %.0f", health);
    TextDrawSetString(Textdraw111[id], tdstring);
    format(tdstring, sizeof(tdstring), "Armor: %.0f", armour);
    TextDrawSetString(Textdraw2[id], tdstring);
    format(tdstring, sizeof(tdstring), "Ping: %d", png);
    TextDrawSetString(Textdraw3[id], tdstring);
    format(tdstring, sizeof(tdstring), "IP: %s", ip);
    TextDrawSetString(Textdraw5[id], tdstring);
    format(tdstring, sizeof(tdstring), "Money: $%i", GetPlayerMoney(id));
    TextDrawShowForPlayer(playerid, Textdraw6[playerid]);
    TextDrawSetString(Textdraw6[id], tdstring);
into
pawn Код:
//
    format(tdstring, sizeof(tdstring), "Name: %s", Name);
    TextDrawSetString(Textdraw0[id], tdstring);
    format(tdstring, sizeof(tdstring), "Health: %.0f", health);
    TextDrawSetString(Textdraw111[id], tdstring);
    format(tdstring, sizeof(tdstring), "Armor: %.0f", armour);
    TextDrawSetString(Textdraw2[id], tdstring);
    format(tdstring, sizeof(tdstring), "Ping: %d", png);
    TextDrawSetString(Textdraw3[id], tdstring);
    format(tdstring, sizeof(tdstring), "IP: %s", ip);
    TextDrawSetString(Textdraw5[id], tdstring);
    format(tdstring, sizeof(tdstring), "Money: $%i", GetPlayerMoney(id));
    TextDrawShowForPlayer(playerid, Textdraw6[id]);
    TextDrawSetString(Textdraw6[id], tdstring);
    TextDrawShowForPlayer(playerid, Textdraw3[id]);
    TextDrawShowForPlayer(playerid, Textdraw0[id]);
    TextDrawShowForPlayer(playerid, Textdraw44[id]);
    TextDrawShowForPlayer(playerid, Textdraw7[id]);
    TextDrawShowForPlayer(playerid, Textdraw8[id]);
    TextDrawShowForPlayer(playerid, Textdraw9[id]);
    TextDrawShowForPlayer(playerid, Textdraw10[id]);
    TextDrawShowForPlayer(playerid, Textdraw111[id]);
    TextDrawShowForPlayer(playerid, Textdraw2[id]);
    TextDrawShowForPlayer(playerid, Textdraw5[id]);
Reply
#7

pawn Код:
new id = Spectating[playerid];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)