29.11.2011, 07:32
(
Last edited by AstonDA-G; 29/11/2011 at 05:10 PM.
)
Okay, this is my first tut, so sorry if it's bad.
First of all, I'm using zcmd and sscanf in this tutorial, so you need to download them if you haven't got them.
Once you have them, you need to add them in your script.
Okay, now we're ready to start the command. Now we need to create the command.
So, now we've got the command, we can make it do things, but firstly, we need to declare new things...
'id' will be the person to send the PM to, so with sscanf, we will detect if the sender hasn't put an id, or message.
Now, we need to get the names of the sender and reciever, this is simple.
Next, we can format the two stringsthat are sent and recieved.
Everything is formatted, and now, we can send the two strings to the players.
PLEASE NOTE: All of these messages will be sent in white. You can change the color if you want to.
And there we are, done. Hope this helped,
-Aston.
First of all, I'm using zcmd and sscanf in this tutorial, so you need to download them if you haven't got them.
Once you have them, you need to add them in your script.
Code:
#include <sscanf> #include <zcmd>
Code:
COMMAND:pm(playerid, params[]) { return 1; }
Code:
new id, string[128], string2[128], sender[MAX_PLAYER_NAME], reciever[MAX_PLAYER_NAME];
Code:
if(sscanf(params, "us[75]", id, params[2])) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /pm <id> <message>"); //params[2] is the text after the player has typed the id.
Code:
GetPlayerName(playerid, sender, sizeof(sender)); //sender will be playerid, the one who is typing the command. GetPlayerName(id, reciever, sizeof(reciever)); //reciever will be the name of the player we send the PM to.
Code:
format(string, sizeof(string), "PM recieved from %s: %s", sender, params[2]); //sender's name, followed by the message he sent. format(string2, sizeof(string2), "PM sent to %s: %s", reciever, params[2]); //reciever's name, followed by the message that this player wrote.
Code:
SendClientMessage(id, 0xFFFFFFFF, string); SendClientMessage(playerid, 0xFFFFFFFF, string2);
And there we are, done. Hope this helped,
-Aston.