Call a ZCMD command?
#1

Let's say I have the following code:
pawn Код:
new Commands[][] = {"hi", "kickme", "cmd"};

CMD:hi(playerid, params[])
{
    SendClientMessage(playerid, COLOR_WHITE, "Hi!");
    return 1;
}

CMD:kickme(playerid, params[])
{
    Kick(playerid);
    return 1;
}

CMD:cmd(playerid, params[])
{
    new CmdList[256];
    strcat(CmdList, "/hi - sends you a 'Hi!' message\n");
    strcat(CmdList, "/kickme - kick yourself\n");
    strcat(CmdList, "/cmd - show this message");
    ShowPlayerDialog(playerid, 300, DIALOG_STYLE_LIST, "Commands:", CmdList, "Use", "Close");
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
    if (dialogid == 300){
        if(response){
            OnPlayerCommandReceived(playerid, Commands[listitem]);
        }
        return 1;
    }
    return 0;
}
As you can see, I'm trying to make a dialog with the commands and make it so that if the player selects the command and clicks the "Use" button then the command will be performed. But this code doesn't work as nothing happens when I click "Use" in the dialog box. I think that this line is the problem:
pawn Код:
OnPlayerCommandReceived(playerid, Commands[listitem]);
I also tried putting "/" in front of every command in the array but still no good. Any suggestions what I should do?
Reply
#2

pawn Код:
cmd_command(playerid, "");
It should work.
Reply
#3

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/command", cmdtext, true, 10) == 0)
    {
        return cmd_command(playerid, params);
        return 1;
    }
    return 0;
}
Reply
#4

I think we have a misunderstanding here... I updated my post with more details so it's easier to understand...
Reply
#5

Use CallRemoteFunction..

pawn Код:
CallRemoteFunction("OnPlayerCommandText", "is", playerid, Commands[listitem] );
This would work, OnPlayerCommandText is not supposed to be used when using ZCMD.
Reply
#6

Thanks, I'll try that
Reply
#7

Quote:
Originally Posted by Zh3r0
Посмотреть сообщение
Use CallRemoteFunction..

pawn Код:
CallRemoteFunction("OnPlayerCommandText", "is", playerid, Commands[listitem] );
This would work, OnPlayerCommandText is not supposed to be used when using ZCMD.
Thanks a lot, it works now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)