/pm command problem -
kbalor - 29.07.2012
When I pm a player. It only show the usage of pm (USAGE: /pm [PlayerID] [Message]) and it's not sending..
Here's the Pm command that iam using..
pawn Код:
CMD:pm(playerid, params[])
{
new pID, Msg[128];
if(sscanf(params, "ds[128]", pID, Msg)) return SendClientMessage(playerid, -1, "USAGE: /pm [PlayerID] [Message]");
if(pID == playerid) return SendClientMessage(playerid, 0xFF0000FF, "You can't PM to yourself!");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, 0xFF0000FF, "Invalid PlayerID or the PlayerID is not online!");
if(GetPVarInt(playerid, "PMEnabled") == 0) return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
new str[256], pName[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(pID, pName2, sizeof(pName2));
format(str, sizeof(str), "PM Sent to %s (ID: %d): %s", pName2, pID, Msg);
SendClientMessage(playerid, -1, str);
format(str, sizeof(str), "PM from %s (ID: %d): %s", pName, playerid, Msg);
SendClientMessage(pID, -1, str);
return 1;
}
Re: /pm command problem -
kbalor - 29.07.2012
If anyone what's the problem??
Re: /pm command problem - Emmet_ - 29.07.2012
I assume you're using the sscanf stock instead of the plugin (the plugin is too much time to set up so I use the stock too xD).
Anyway, try this instead:
pawn Код:
CMD:pm(playerid, params[])
{
new pID, Msg[128];
if(sscanf(params, "ds", pID, Msg)) return SendClientMessage(playerid, -1, "USAGE: /pm [PlayerID] [Message]");
if(pID == playerid) return SendClientMessage(playerid, 0xFF0000FF, "You can't PM to yourself!");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, 0xFF0000FF, "Invalid PlayerID or the PlayerID is not online!");
if(GetPVarInt(playerid, "PMEnabled") == 0) return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
new str[256], pName[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(pID, pName2, sizeof(pName2));
format(str, sizeof(str), "PM Sent to %s (ID: %d): %s", pName2, pID, Msg);
SendClientMessage(playerid, -1, str);
format(str, sizeof(str), "PM from %s (ID: %d): %s", pName, playerid, Msg);
SendClientMessage(pID, -1, str);
return 1;
}
gedgfgsd
Re: /pm command problem -
[MM]RoXoR[FS] - 29.07.2012
Your code is perfect.
Changed d to u in sscanf
pawn Код:
CMD:pm(playerid, params[])
{
new pID, Msg[128];
if(sscanf(params, "us[128]", pID, Msg)) return SendClientMessage(playerid, -1, "USAGE: /pm [PlayerID] [Message]");
if(pID == playerid) return SendClientMessage(playerid, 0xFF0000FF, "You can't PM to yourself!");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, 0xFF0000FF, "Invalid PlayerID or the PlayerID is not online!");
//Also it was playerid in GetPVar instead of pID
if(GetPVarInt(pID, "PMEnabled") == 0) return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
new str[256], pName[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(pID, pName2, sizeof(pName2));
format(str, sizeof(str), "PM Sent to %s (ID: %d): %s", pName2, pID, Msg);
SendClientMessage(playerid, -1, str);
format(str, sizeof(str), "PM from %s (ID: %d): %s", pName, playerid, Msg);
SendClientMessage(pID, -1, str);
return 1;
}
Re: /pm command problem -
kbalor - 29.07.2012
Solved: Just forgot to update sscanf 2.6 thanks for the help anyway +rep both and to andi
Edit: how do i change the color of USAGE: /pm [PlayerID] [Message]??
Re: /pm command problem -
Pravin - 29.07.2012
pawn Код:
SendClientMessage(pID, -1, str);
Change -1 to your own colour.
-1 is white colour.