How can I script a /me CMD? | Beginner Scripter
#1

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
Reply
#2

Uhm, you use zcmd/ycmd/dcmd/strcmp . .?
Reply
#3

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

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

Why open the same thread twice? ^^
Reply
#5

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
Reply
#6

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;
    }
Reply
#7

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.
Reply
#8

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;

Reply
#9

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
Reply
#10

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...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)