31.01.2011, 13:21
TESTED AND WORKS!!!
Alright.
I will use ZCMD. You'll need the ZCMD include. The sscanf2 include as well.
You can easily find them on the forum.
Lets start with making the command.
That's how we start making the command.
Now we need this in our command:
The id is the person we'll send it to.
the string is the message you and the player will get.
The text is the text you'll send.
Now we're going to use the sscanf fuction.
If you forget the [100] after the S you'll get a warning in your server.exe, so don't forget it.
Now we want to check if the player is connected.
We don't use playerid at the !IsPlayerConnected(id)) because we don't want to know if the player that uses the command is online.
Now what will happen when the player is connected and you used the cmd on a good way?
Now that's done.
The whole code:
I hope I've explained this well enough.
Good luck
EDIT:
Damn you calgon!! xD
You were faster. LOl
Alright.
I will use ZCMD. You'll need the ZCMD include. The sscanf2 include as well.
You can easily find them on the forum.
Lets start with making the command.
pawn Код:
COMMAND:pm(playerid,params[])
{
return 1;
}
Now we need this in our command:
pawn Код:
new id,string[100],text[100],playername1[MAX_PLAYER_NAME],playername2[MAX_PLAYER_NAME];
the string is the message you and the player will get.
The text is the text you'll send.
Now we're going to use the sscanf fuction.
pawn Код:
if(sscanf(params,"us[100]",id,text)) return SendClientMessage(playerid,COLOR,"USAGE:/pm playerid text");
Now we want to check if the player is connected.
pawn Код:
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR,"Player not connected");
Now what will happen when the player is connected and you used the cmd on a good way?
pawn Код:
else
{
GetPlayerName(playerid,playername1,sizeof(playername1));
GetPlayerName(id,playername2,sizeof(playername2));
format(string,sizeof(string),"PM from %s: %s",playername1,text);
SendClientMessage(id,COLOR,string);
format(string,sizeof(string),"PM to %s: %s",playername2,text);
SendClientMessage(playerid,COLOR,string);
}
The whole code:
pawn Код:
COMMAND:pm(playerid,params[])
{
new id,string[100],text[100],playername1[MAX_PLAYER_NAME],playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername1,sizeof(playername1));
GetPlayerName(id,playername2,sizeof(playername2));
if(sscanf(params,"us[100]",id,text)) return SendClientMessage(playerid,COLOR,"USAGE:/pm playerid text");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR,"Player not connected");
else
{
GetPlayerName(playerid,playername1,sizeof(playername1));
GetPlayerName(id,playername2,sizeof(playername2));
format(string,sizeof(string),"PM from %s: %s",playername1,text);
SendClientMessage(id,COLOR,string);
format(string,sizeof(string),"PM to %s: %s",playername2,text);
SendClientMessage(playerid,COLOR,string);
}
return 1;
}
Good luck

EDIT:
Damn you calgon!! xD
You were faster. LOl