ZCMD SubCommand
#1

Hi,

Is it possible to do it but witch ZCMD ?

if(strcmp(cmd, "/give", true) == 0)
{
subcmd = strtok(cmdtext, idx);
if(PlayerInfo[playerid][pAdmin] < ADMIN2){return NotAdmin(playerid,cmd);}

if(!strlen(subcmd))
{
SendCmdModelMessage(playerid, "/give <Name>");
return 1;
}

if(strcmp(subcmd, "money", true) == 0)
{
return 1;
}
return 1;
}

And second question: Is ZCMD faster than dcmd ? Or faster than strcmp ?

Thanks.
Reply
#2

Yes, zcmd it's faster than dcmd and strcmp.
And yes, you can do it with zcmd.
Here's a quick example:

pawn Код:
CMD:test(playerid, params[])
{
    new subcmd[144];
    if(sscanf(params, "s[144], subcmd)) return SendClientMessage(playerid, -1, "USAGE: /test [Name]");
    if(strcmp(subcmd, "
money", true) == 0)
    {
        // Code.
    }
    return 1;
}
Reply
#3

Okay thanks !
Reply
#4

Sorry, for the double post but ...

For the subcmd sscanf, it's the same, can I put it ?

if(sscanf(params, "rs[32]i", giveplayerid, weapon, ammo))

Or have I to put it ?

if(sscanf(subcmd[lenght of subcmd], "rs[32]i", giveplayerid, weapon, ammo))

Or ?

if(sscanf(params, "s[32]rs[32]i",subcmd, giveplayerid, weapon, ammo))
Reply
#5

PHP код:
CMD:test(playeridparams[])
{
    new 
subcmd[32];
    if(
sscanf(params"s[32]"subcmd)) return SendClientMessage(playeridRED"Correct usage: /test [subcmd]");
    if(!
strcmp(subcmd"kick"true))
    {
         new 
idlol[5];
         if(
sscand(subcmd"s[5]i"lolid)) return SendClientMessage(playeridRED"Correct usage: /test kick [id]");
         
Kick(id);
    }

You can use it this way.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)