The best command procesor
#10

Quote:
Originally Posted by The Toni
Посмотреть сообщение
Here is my code for a /me command with zcmd + sscanf.

pawn Код:
CMD:me(playerid, params[])
{
    if(sscanf(params, "s[128]", str))
    {
        return SendClientMessage(playerid, LBLUE, "Usage: /me (action)") &&
        SendClientMessage(playerid, ORANGE, "Function: make a me action");
    }
    format(str, sizeof(str), "* %s %s", pName(playerid), str);
    SendClientMessageToAll(PURPLE, str);
    return 1;
}
You can make that less lines if you want to, and in my eyes still not messy. Take a look at this (Its just for showing, theres nothing wrong with it)

pawn Код:
CMD:me(playerid, params[])
{
    if(sscanf(params, "s[128]", str)) return SendClientMessage(playerid, LBLUE, "Usage: /me (action)") &&
        SendClientMessage(playerid, ORANGE, "Function: make a me action");
    format(str, sizeof(str), "* %s %s", pName(playerid), str);
    SendClientMessageToAll(PURPLE, str);
    return 1;
}
or you can do

pawn Код:
CMD:me(playerid, params[])
{
    if(sscanf(params, "s[128]", str))return SendClientMessage(playerid, LBLUE, "Usage: /me (action)") && SendClientMessage(playerid, ORANGE, "Function: make a me action");
    format(str, sizeof(str), "* %s %s", pName(playerid), str);
    SendClientMessageToAll(PURPLE, str);
    return 1;
}
And i always put an 'else' in, like this

pawn Код:
CMD:me(playerid, params[])
{
    if(sscanf(params, "s[128]", str)) return SendClientMessage(playerid, LBLUE, "Usage: /me (action)") && SendClientMessage(playerid, ORANGE, "Function: make a me action");
    else {
         format(str, sizeof(str), "* %s %s", pName(playerid), str);
         SendClientMessageToAll(PURPLE, str);
    }
    return 1;
}
Reply


Messages In This Thread
The best command procesor - by [SOB]Chris - 18.10.2010, 02:21
Re: The best command procesor - by [L3th4l] - 18.10.2010, 02:23
Re: The best command procesor - by Steven82 - 18.10.2010, 02:38
Respuesta: The best command procesor - by [SOB]Chris - 18.10.2010, 02:40
Re: Respuesta: The best command procesor - by Toni - 18.10.2010, 02:46
Re: The best command procesor - by CuervO - 18.10.2010, 02:53
Re: The best command procesor - by Toni - 18.10.2010, 02:55
Re: The best command procesor - by nemesis- - 18.10.2010, 03:01
Re: The best command procesor - by Toni - 18.10.2010, 03:07
Re: Respuesta: The best command procesor - by Niixie - 18.10.2010, 08:10

Forum Jump:


Users browsing this thread: 1 Guest(s)