Command Parameters
#1

Hey guys could you give me an example of how a command would be like if i made a command, let say:

/admin [parameter 1] [value]

/admin announce Hello world!
/admin hi // sends a client message to player, HI.

I haven't really learn't the parameters to commands that much and are willing to learn how to do this, using sscanf.
Reply
#2

what processor of commands you use ?
Reply
#3

ZCMD

This might be a big ass noob question although i never have exprienced this with sscanf only the default natives :O
Reply
#4

try this.


pawn Код:
new string[100];
CMD:admin(playerid, params[])
{
    static iStr[128], player, name[24],i[30];
    if(sscanf(params[], "uss",player, i,iStr)) return false;
    if(!strcmp(i,"hi", true))
    {
        format(string, sizeof(string),"This admin %s says for you %s",GetPlayerName(playerid, name, 24), iStr);
        SendClientMessage(player, COLOR_MSG,string);
        format(string, sizeof(string),"You send %s  to %s",iStr, GetPlayerName(player, name, 24);
        SendClientMessage(playerid, COLOR_MSG, string);
    }
    if(!strcmp(i,"ann", true))
    {
        if(sscanf(params[] "s",iStr)) return false;
        format(string, sizeof(string),"%s says:%s",GetPlayerName(player, name, 24),iStr);
        SendClientMessageToAll(COLOR_MSG, string);
    }
    return 1;
}
using sscanf.
Reply
#5

Quote:
Originally Posted by TheGarfield
Посмотреть сообщение
try this.


pawn Код:
new string[100];
CMD:admin(playerid, params[])
{
    static iStr[128], player, name[24],i[30];
    if(sscanf(params[], "uss",player, i,iStr)) return false;
    if(!strcmp(i,"hi", true))
    {
        format(string, sizeof(string),"This admin %s says for you %s",GetPlayerName(playerid, name, 24), iStr);
        SendClientMessage(player, COLOR_MSG,string);
        format(string, sizeof(string),"You send %s  to %s",iStr, GetPlayerName(player, name, 24);
        SendClientMessage(playerid, COLOR_MSG, string);
    }
    if(!strcmp(i,"ann", true))
    {
        if(sscanf(params[] "s",iStr)) return false;
        format(string, sizeof(string),"%s says:%s",GetPlayerName(player, name, 24),iStr);
        SendClientMessageToAll(COLOR_MSG, string);
    }
    return 1;
}
using sscanf.
pawn Код:
if(sscanf(params, "us[24]s[30]",player, i,iStr)) return false;
Reply
#6

don't worry i got something working, Ill try those even though later.

Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)