SA-MP Forums Archive
Can anyone see a 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Can anyone see a problem? (/showthread.php?tid=277620)



Can anyone see a problem? - Luis- - 18.08.2011

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;
}



Re: Can anyone see a problem? - Luis- - 18.08.2011

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


Re: Can anyone see a problem? - grand.Theft.Otto - 18.08.2011

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.


Re: Can anyone see a problem? - Luis- - 18.08.2011

For some reason it is still doing it.


Re: Can anyone see a problem? - Hiddos - 18.08.2011

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?


Re: Can anyone see a problem? - grand.Theft.Otto - 18.08.2011

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.


Re: Can anyone see a problem? - Luis- - 18.08.2011

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.



Re: Can anyone see a problem? - ElieJabbour - 18.08.2011

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.


Re: Can anyone see a problem? - Luis- - 18.08.2011

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


Re: Can anyone see a problem? - grand.Theft.Otto - 18.08.2011

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

But this problem is really strange :/