SA-MP Forums Archive
How can I script a /me CMD? | Beginner Scripter - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How can I script a /me CMD? | Beginner Scripter (/showthread.php?tid=280381)



How can I script a /me CMD? | Beginner Scripter - B-rian - 31.08.2011

I wanted to know how I can script a /me cmd like the ones in an RP server, i would appreciate a tutorial or a detailed post Thank you


Re: How can I script a /me CMD? | Beginner Scripter - Jafet_Macario - 31.08.2011

Uhm, you use zcmd/ycmd/dcmd/strcmp . .?


Re: How can I script a /me CMD? | Beginner Scripter - Scenario - 31.08.2011

Seriously? Search before you post! More information on searching can be found here.


Re: How can I script a /me CMD? | Beginner Scripter - =WoR=Bruno - 31.08.2011

https://sampforum.blast.hk/showthread.php?tid=280380

Why open the same thread twice? ^^


Re: How can I script a /me CMD? | Beginner Scripter - Speed - 31.08.2011

pawn Код:
if(strcmp(cmd, "/me", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /me [action]");
                return 1;
            }
            format(string, sizeof(string), "* %s %s", sendername, result);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            printf("%s", string);
        }
        return 1;
    }
Here you go


Re: How can I script a /me CMD? | Beginner Scripter - Amel_PAtomAXx - 31.08.2011

pawn Код:
if(strcmp(cmdtext,"/me",true,3)== 0)
    {
        if ( cmdtext[ 3 ] != ' ' || !cmdtext[ 4 ] )
        return SendClientMessage( playerid, -1, "USAGE: /me (action)" );
        new pName[MAX_PLAYER_NAME],string[128];
        GetPlayerName(playerid,pName,sizeof(pName));
        format(string,sizeof(string),"**%s%s.",pName,cmdtext[3]);
        SendClientMessageToAll(0xFFFFFFFF,string);
            return 1;
    }



Re: How can I script a /me CMD? | Beginner Scripter - Kingunit - 31.08.2011

Quote:
Originally Posted by Speed
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/me", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /me [action]");
                return 1;
            }
            format(string, sizeof(string), "* %s %s", sendername, result);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            printf("%s", string);
        }
        return 1;
    }
Here you go
He probably don't have that proxdetector.


Re: How can I script a /me CMD? | Beginner Scripter - AustinJ - 31.08.2011

I recommend using sscanf and zcmd. The way you could do this with these is....
PHP код:
CMD:me(playeridparams[])
{
    new 
action[256], string[256], name[24], Float:xFloat:yFloat:z;
    if(
sscanf(params"s[256]"action))
    {
        
SendClientMessage(playeridCOLOR"USAGE: /me [action]");
    }
    else
    {
        
GetPlayerName(playeridname24);
        
GetPlayerPos(playeridxyz);
        
format(string256"* %s %s *"nameaction);
        for(new 
0MAX_PLAYERSi++)
        {
            if(
IsPlayerInRangeOfPoint(i10xyz))
            {
                
SendClientMessage(iCOLORstring);
            }
        }
    }
    return 
1;




Re: How can I script a /me CMD? | Beginner Scripter - B-rian - 01.09.2011

Guys thanks for the tips and codes! I managed to do it now Also sry for double posting this thread, it was a fail of my PC vry sorry


Re: How can I script a /me CMD? | Beginner Scripter - Scenario - 01.09.2011

Quote:
Originally Posted by AustinJ
Посмотреть сообщение
I recommend using sscanf and zcmd. The way you could do this with these is....
PHP код:
CMD:me(playeridparams[])
{
    new 
action[256], string[256], name[24], Float:xFloat:yFloat:z;
    if(
sscanf(params"s[256]"action))
    {
        
SendClientMessage(playeridCOLOR"USAGE: /me [action]");
    }
    else
    {
        
GetPlayerName(playeridname24);
        
GetPlayerPos(playeridxyz);
        
format(string256"* %s %s *"nameaction);
        for(new 
0MAX_PLAYERSi++)
        {
            if(
IsPlayerInRangeOfPoint(i10xyz))
            {
                
SendClientMessage(iCOLORstring);
            }
        }
    }
    return 
1;

No. You don't need to use sscanf for such a simple command.

You can use "params" and run a "strlen" check to see if it's too long...