Help with using zcmd
#1

Hey Guys,

i'm a bit confused with using zcmd.

In the description it's said that zcmd uses OnPlayerCommandText().
If i add f.ex
Код:
if(COMMAND:TEST(playerid, params[]) // or CMD:mycommand(playerid, params[])
{
SendClientMessage(playerid, COLOR_RED, "This is a test cmd");
return 1;
}
I get "error 017: undefined symbol "cmd_TEST""

If i change OnPlayerCommandText(playerid,cmdtext[]) to OnPlayerCommandText(playerid,params[]) it says:
"error 025: function heading differs from prototype"

What i'm doing wrong?
Reply
#2

You can just delete OnPlayerCommandText from your script and add two new callbacks instead.

pawn Код:
/*
this callback is called when someone sends a command.
if you return 0 here, the command won't be performed.
*/

public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(GetPlayerState(playerid) == PLAYER_STATE_WASTED) //if wasted, can't perform commands
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "Commands are temporary disabled.");
        return 0;
    }
    return 1;
}

/*
this callback gets called after command execution, here if you do
"return 0" the player will see standard "Unknown command" message.
*/

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(success)
    {
        return 1;
    }
    return 0;
}

//your command is here
CMD:test(playerid, params[])
{
    #pragma unused params
    SendClientMessage(playerid, COLOR_RED, "This is a test cmd");
    return 1;
}
But note that you don't need to add those callbacks, if you don't use them.
Reply
#3

Thank you very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)