2021-02-26, 12:31 PM
(2021-02-25, 09:26 PM)Kwarde Wrote:(2021-02-24, 01:19 AM)destiezk Wrote:Code:CMD:id(playerid, params[])
{
new target_id, string[256], target_name[MAX_PLAYER_NAME 1];
if (sscanf(params, "u", target_id)) return SendClientMessage(playerid, -1, "USAGE: /id <nick/playerid>");
GetPlayerName(target_id, target_name, sizeof(target_name));
format(string, sizeof(string), "%s [ID: %d]", target_name, target_id)
SendClientMessage(playerid, -1, string);
return 1;
}
Except for the fact that "MAX_PLAYER_NAME 1" should be just "MAX_PLAYER_NAME" (reaching length MAX_PLAYER_NAME (24) is only possible with SetPlayerName()) and that 256 cells is useless for an array only used in SendClientMessage() (max. output is 144 characters anyway), this is the code you're looking for (ignoring the indentation).
You need a variable to store the found (or non found) playerid in. You can't do that in params.
What you're saying is incorrect, you need 1 for the null terminator. The guy above me linked you an example.