Can anyone see a problem?
#1

Hello, I have recently made a /spec command which shows the players id and name, it shows id 0's id and name but it only shows id 1's name.

pawn Код:
CMD:spec(playerid, params[])
{
    new string[128], tname[MAX_PLAYER_NAME], id;
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1 , "ERROR: You are not an admin!");
    if (sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /spec [playerid]");
    if(id == playerid)return SendClientMessage(playerid,COLOR_RED,"ERROR: You are not able to spec yourself.");// Just making sure.
    if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, COLOR_RED, "ERROR: This ID has not been found.");
    TogglePlayerSpectating(playerid, true);
    PlayerSpectatePlayer(playerid, id);
    GetPlayerName(id, tname, sizeof(tname));
    format(string, sizeof(string), "~b~ID: ~w~%d~n~~b~Name: ~w~%s", id, tname);
    GameTextForPlayer(playerid, string, 12000, 4);
    return 1;
}
Reply
#2

I am actually sorry for this but I need it fixing as soon as.
Reply
#3

Hmm, I don't see a problem but I might be blind. Try this:

pawn Код:
CMD:spec(playerid, params[])
{
    new string[128], tname[MAX_PLAYER_NAME], id;
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1 , "ERROR: You are not an admin!");
    //if (sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /spec [playerid]");

    id = strval(params);

    if(id == playerid)return SendClientMessage(playerid,COLOR_RED,"ERROR: You are not able to spec yourself.");// Just making sure.
    if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, COLOR_RED, "ERROR: This ID has not been found.");
    TogglePlayerSpectating(playerid, true);
    PlayerSpectatePlayer(playerid, id);
    GetPlayerName(id, tname, sizeof(tname));
    format(string, sizeof(string), "~b~ID: ~w~%d~n~~b~Name: ~w~%s", id, tname);
    GameTextForPlayer(playerid, string, 12000, 4);
    return 1;
}
I commented out sscanf for now and added id = strval(params);

Try it.
Reply
#4

For some reason it is still doing it.
Reply
#5

1. Are you still spectating the right user/player?
2. Could you be a bit more specific what you mean by this, lol?
Quote:

it shows id 0's id and name but it only shows id 1's name.

Who's name does it show and who do you try to spectate?
Reply
#6

He's saying it shows id 0's name and id as gametext, but it doesnt show the id for id 1, it only shows the name.
Reply
#7

Well, I am trying to spectate an NPC but would that matter? Anywho here's some pictures.

This picture is perfect and working.


This one isn't.
Reply
#8

Quote:
Originally Posted by -Luis
Посмотреть сообщение
Well, I am trying to spectate an NPC but would that matter? Anywho here's some pictures.

This picture is perfect and working.


This one isn't.
You can't spectate a NPC -.-, Try spectating a player.
Reply
#9

Yes you can, I know it is possible I have personally done it in other servers and I am doing it on my server.
Reply
#10

Yes you can spectate bots, I just tried on my server.

But this problem is really strange :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)