an example for zcmd sub cmds.
#1

Ok I have tried alot making a cmd from zcmd that includes sub commands. Can anyone give me a little example?

Like , /heal <health/armour>
If /heal health then he gets 100 hp. If /heal armour he gets 100 armour.

Give me an example of you own I may make the command by myself. Please take time, thank you.
Reply
#2

pawn Код:
CMD:cmd(playerid, params[])
{
    if(isnull(params)) return // message here

    if(!strcmp(params, "health", true, 6))
    {
        new id;
        if(sscanf(params, "{s[128]}u", id)) return // message here

        // set health here, id
    }
    return 1;
}
Find the macro "isnull" somewhere.
Reply
#3

Just fix this mistake done in the above code:
Код:
if(! strcmp(params, "health", true, 6))
Reply
#4

dont mind the intention
PHP код:
CMD:heal(playerid,params[])
{
   if(!
strlen(params)) return SendClientMessage(playerid, -1"usage: /heal [health/armour]"); // or isnull(params)
   
if(! strcmp(params"health"true6))
  {
      
SetPlayerHealth(playerid,100.0);
}
   else if(! 
strcmp(params"armour"true6)
{
setplayerarmour(playerid,100.0);
}
return 
1;

Reply
#5

I will try each and every code of yours thanks.
Reply
#6

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Just fix this mistake done in the above code:
Код:
if(! strcmp(params, "health", true, 6))
Quote:

0 if strings match each other on given length;
1 o r -1 if some character do not match: string1[i] - string2[i] ('i' represents character index starting from 0);

No. His code is right.

Edit: Actually nevermind, seems like it was edited. Sorry.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)