SA-MP Forums Archive
ZCMD issue. - 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: ZCMD issue. (/showthread.php?tid=190049)



ZCMD issue. - DiddyBop - 14.11.2010

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    CMD:testcmd(playerid, params[])
    {
        SendClientMessage(playerid, 0x375FFFFF, "test test test win win win");
        return 1;
    };
     return 0;
}
Gives error..
Код:
error 029: invalid expression, assumed zero
error 017: undefined symbol "cmd_testcmd"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
This is a gamemode, #include <zcmd> is there on top also..


Re: ZCMD issue. - Brian_Furious - 14.11.2010

Do not put the ZCMD commands under public OnPlayerCommandText(playerid, cmdtext[])


Re: ZCMD issue. - DiddyBop - 14.11.2010

Quote:
Originally Posted by Brian_Furious
Посмотреть сообщение
Do not put the ZCMD commands under public OnPlayerCommandText(playerid, cmdtext[])
Where should i put them? When i put them under no callback like dcmd, it crashs compiler... :\


Re: ZCMD issue. - GaGlets(R) - 14.11.2010

Dont add `;` at the end
pawn Код:
COMMAND:testcmd(playerid, params[])
{
    SendClientMessage(playerid, 0x375FFFFF, "test test test win win win");
    return 1;
}
And ofcourse if you are using zcmd in the same scrit where are OnPlayerCommandText callback then OnPlayerCommandText callback will not work.


Re: ZCMD issue. - Brian_Furious - 14.11.2010

Exemple:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{  
    if(strcmp(cmd, "/givecash", true) == 0) {
        new tmp[256];
        tmp = strtok(cmdtext, idx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        giveplayerid = strval(tmp);
       
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        moneys = strval(tmp);
       
        //printf("givecash_command: %d %d",giveplayerid,moneys);

       
        if (IsPlayerConnected(giveplayerid)) {
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            playermoney = GetPlayerMoney(playerid);
            if (moneys > 0 && playermoney >= moneys) {
                GivePlayerMoney(playerid, (0 - moneys));
                GivePlayerMoney(giveplayerid, moneys);
                format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
            }
            else {
                SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
            }
        }
        else {
                format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_YELLOW, string);
            }
        return 1;
    }
   
    // PROCESS OTHER COMMANDS
   
   
    return 0;
}


COMMAND:test(playerid, params[])
{
      SendClientMessage(playerid COLOR_RED, " WEWEWE");
      return true; // you can put true or 1
}



Re: ZCMD issue. - DiddyBop - 14.11.2010

Quote:
Originally Posted by GaGlets®
Посмотреть сообщение
Dont add `;` at the end
pawn Код:
COMMAND:testcmd(playerid, params[])
{
    SendClientMessage(playerid, 0x375FFFFF, "test test test win win win");
    return 1;
}
And ofcourse if you are using zcmd in the same scrit where are OnPlayerCommandText callback then OnPlayerCommandText callback will not work.
Compiler still crash, And same errors under onplayercmdtext (ik shouldnt be under there)

Should i try this in a filterscript..?


Re: ZCMD issue. - Brian_Furious - 14.11.2010

Quote:
Originally Posted by DiddyBop
Посмотреть сообщение
Compiler still crash, And same errors under onplayercmdtext (ik shouldnt be under there)

Should i try this in a filterscript..?
Yes try it in a FS, the crash maybe will be beacuse you have the commands in strcmp + strok, and ZCMD inlcude with some commands there.


Re: ZCMD issue. - DiddyBop - 14.11.2010

Quote:
Originally Posted by Brian_Furious
Посмотреть сообщение
Yes try it in a FS, the crash maybe will be beacuse you have the commands in strcmp + strok, and ZCMD inlcude with some commands there.
well, should they be in a callback?


Re: ZCMD issue. - Haydz - 14.11.2010

pawn Код:
COMMAND:mycommand(playerid, params[])
    {
        //do your stuff here
        return 1;
    }



Re: ZCMD issue. - [L3th4l] - 14.11.2010

No, no callbacks!

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    return 0;
}

COMMAND:(or CMD:)kick(playerid, params[])
{
    // Your code
}