ZCMD issue.
#1

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..
Reply
#2

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

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... :\
Reply
#4

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.
Reply
#5

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
}
Reply
#6

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..?
Reply
#7

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.
Reply
#8

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?
Reply
#9

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

No, no callbacks!

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)