SA-MP Forums Archive
Command Parameters - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command Parameters (/showthread.php?tid=253834)



Command Parameters - Lorenc_ - 08.05.2011

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.


Re: Command Parameters - TheGarfield - 08.05.2011

what processor of commands you use ?


Re: Command Parameters - Lorenc_ - 08.05.2011

ZCMD

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


Re: Command Parameters - TheGarfield - 08.05.2011

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.


Re: Command Parameters - HyperZ - 08.05.2011

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;



Re: Command Parameters - Lorenc_ - 08.05.2011

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

Thanks.