[Tutorial] Simple Command (/me <action>)
#1

Hey,

I saw many of newbie's looking for command like this as shown in the photo, Some of them didn't tried to make or under stand its functions, Well most of them have already known its functions. Example:-
Well to let you know that its simple as hell . Here we are going to use the command /me. Normally /me will change into our/your name For example Typing this is chat:-

/me: is now posting on sa-mp forums.

The text will appear like this:- [vTc]Patroool is now posting on sa-mp forums.

So Let's begin!


This codes will come under:
Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
  • 1)
Then, Add this
Code:
if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
    {
        if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "* %s is %s", str, cmdtext[4]);
        SendClientMessageToAll(0xFFFF00AA, str);
        return 1;
    }
    return 0;
}
Functions
Code:
 new str[128];
Creating a string.

Code:
GetPlayerName(playerid, str, sizeof(str));
Will get the player name, Who is typing.

Code:
format(str, sizeof(str), "* %s is %s", str, cmdtext[4]);
Format of the command, Like i said above (*[vTc]Patroool is <ACTION>)
Code:
SendClientMessageToAll(0xFFFF00AA, str);
Will send message to all players, With the format above. Currently the colour is WHITE (0xFFFF00AA).

Well, Thats all Your command is ready!
It was a quick tutorial, So when the newbie use the Search button they would see this tutorial

*If you want colour's list you can get here (COLOURS)
+rep please Dont mind
And please comment. Thank you very much!
Reply
#2

Why would you send it to everybody? You should use ProxDetector.
Reply
#3

Awesome! NiCe Tutorial TnX
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)