/me and /do - 2 lines
#2

There's no reason to check if a player is logged in on each command as you can do it with one of ZCMD's callbacks. Furthermore, you're dealing with a single string- there's no reason to use sscanf here.

You can't do it in two lines, but it's close enough! And remember, the amount of lines in a script really don't mean a damn thing.

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(!IsPlayerLoggedIn(playerid))
    {
        SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
        return 0;
    }
    return 1;
}

CMD:me(playerid, params[])
{
    if(AntiAdv(playerid, params[]))
        return 1;
    if(strlen(params) < 3) // if the "action" in the /me command was less than 3 characters in length, the command won't process
        return 1;
   
    new
        string[144];
   
    format(string, sizeof(string), "* %s %s", RPN(playerid), params);
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    return 1;
}

CMD:do(playerid, params[])
{
    if(AntiAdv(playerid, params[]))
        return 1;
    if(strlen(params) < 3) // if the "description" in the /do command was less than 3 characters in length, the command won't process
        return 1;
   
    new
        string[144];
   
    format(string, sizeof(string), "* %s (( %s ))", params, RPN(playerid));
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    return 1;
}
Try searching BEFORE posting next time, please.
Reply


Messages In This Thread
/me and /do - 2 lines - by Iuly1234 - 16.06.2013, 19:33
Re: /me and /do - 2 lines - by Scenario - 16.06.2013, 20:09
Re: /me and /do - 2 lines - by dannyk0ed - 16.06.2013, 20:29
Re: /me and /do - 2 lines - by Iuly1234 - 17.06.2013, 07:16
Re: /me and /do - 2 lines - by Pottus - 17.06.2013, 07:28
Re: /me and /do - 2 lines - by Iuly1234 - 17.06.2013, 19:31
Re: /me and /do - 2 lines - by lean1337 - 17.06.2013, 20:42
Re: /me and /do - 2 lines - by Red_Dragon. - 18.06.2013, 00:01
Re: /me and /do - 2 lines - by Iuly1234 - 18.06.2013, 06:52
Re: /me and /do - 2 lines - by Iuly1234 - 19.06.2013, 13:08

Forum Jump:


Users browsing this thread: 2 Guest(s)