SA-MP Forums Archive
[Help] ZCMD & Default commands. - 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: [Help] ZCMD & Default commands. (/showthread.php?tid=120999)



[Help] ZCMD & Default commands. - CaHbKo - 14.01.2010

Hi,

I got this problem. I switched to zcmd recently, but there are too much commands to convert, so i did this:
Quote:
Quote:
Originally Posted by s1cr0n
Is it possible to use zcmd in combination with standard onplayercommandtext and dcmd ?
I'm asking this because I don't have time to convert my whole script to zcmd now, and until then may I use them combined ?
Yes, you can combine zcmd with usual commands or dcmd:

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/command1", true))
    {
        SendClientMessage(playerid, 0x00FFFFFF, "usual command");
        return 0;
    }
    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Unknown command");
    return 1;
}

COMMAND:command2(playerid)
{
    SendClientMessage(playerid, 0x00FF00FF, "zcmd command");
    return 1;
}
But you will have to switch "return 1" to "return 0" in every command to get them working. To avoid this, change the following line in the include (# 85):

pawn Код:
if (zcmd_g_HasOPCS && !CallLocalFunction("OnPlayerCommandReceived", "is", playerid, cmdtext))
to this one:

pawn Код:
if (zcmd_g_HasOPCS && CallLocalFunction("OnPlayerCommandReceived", "is", playerid, cmdtext))
Then you can just copy all your commands from OnPlayerCommandText and paste them to OnPlayerCommandReceived:

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/command1", true))
    {
        SendClientMessage(playerid, 0x00FFFFFF, "command1");
        return 1;
    }
    ....
    ....

    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Unknown command");
    return 0;
}
But now all those commands in OnPlayerCommandReceived work (return 1; and stuff), and ZCMD ones don't..
Example of my zcmd command:
pawn Код:
CMD:setneed(playerid, params[])
{
  if(IsLogged(playerid))
  {
    new need=-1, playa=-1, amount=-1;
        sscanf(params, "iui",need,playa,amount);
        if(need<0 || playa<0 || amount<0)
        {
            SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USAGE:] /setneed [need] [player] [amount]");
            return 1;
        }
        if (PlayerInfo[playerid][pAdmin] >= 5)
        {
          if(IsPlayerConnected(playa))
          {
            if(playa != INVALID_PLAYER_ID)
            {
              NeedStatIncrease(playa, need, amount);
                }
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You're not an administrator.");
        }
    }
    return 1;
}
What is wrong?

Thanks.


Re: [Help] ZCMD & Default commands. - CaHbKo - 16.01.2010

Bump.