25.02.2016, 19:57
(
Последний раз редактировалось EiresJason; 25.02.2016 в 22:31.
)
Make sure you always put code snippets into [.pawn] [/pawn] tags (remove the full stop in the first tag).
Also, reduce the size of your strings as they're unnecessarily large.
You need to check if the player is connected after calling the sscanf function (otherwise the value of 'id' is always 0 and will not correctly represent the player you want to message).
Also, reduce the size of your strings as they're unnecessarily large.
You need to check if the player is connected after calling the sscanf function (otherwise the value of 'id' is always 0 and will not correctly represent the player you want to message).
pawn Код:
CMD:pm(playerid, params[])
{
new id;
new message[128], string[200]; // reduce the size of the string if needed
new name[MAX_PLAYER_NAME];
new tname[MAX_PLAYER_NAME];
if(sscanf(params, "us", id, message)) return SendClientMessage(playerid, -1 , "Server: Usage, /pm [id]
[message]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "ERROR:This player isn't in game.");
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, tname, sizeof(tname));
format(string, sizeof(string), "To %s (%d): %s ", tname , id , message);
SendClientMessage(id, -1, string);
format(string, sizeof(string), "From %s (%d): %s", name , playerid, message);
SendClientMessage(playerid, -1 , string);
return 1;
}