31.08.2009, 16:35
pawn Код:
format(string, sizeof(string), "Admin %s whispers: %s", sendername, playerid);
But anyway, here's one that should work (untested) with dcmd and sscanf:
pawn Код:
// assuming you already have a 'string[128]' defined
dcmd_whisper(playerid, params[])
{
if (AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid))
{
new
TargetID,
msg[128];
if (sscanf(params, "us", TargetID, msg) != 0)
{
SendClientMessage(playerid, ADMIN_RED, "Usage: /whisper <Target ID or name> <text>");
SendClientMessage(playerid, ADMIN_RED, "Alternatives: /w, /whisper");
return 1;
}
if (IsPlayerConnected(TargetID))
{
format(string, sizeof(string), "Admin %s whispers: %s", GetPlayerName2(playerid), msg);
SendClientMessage(TargetID, YELLOW, string);
return 1;
}
else return SendClientMessage(playerid, ADMIN_RED, "Player not found!");
}
else SendClientMessage(playerid, ADMIN_RED, "This is a level 1 command!");
return 1;
}
dcmd_w(playerid, params[])
{
return dcmd_whisper(playerid, params);
}
pawn Код:
stock GetPlayerName2(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
return pname;
}
// in case you need it