Call a ZCMD command? - 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: Call a ZCMD command? (
/showthread.php?tid=240937)
Call a ZCMD command? -
JackYack13 - 16.03.2011
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?
Re: Call a ZCMD command? -
Shelby - 16.03.2011
pawn Код:
cmd_command(playerid, "");
It should work.
Re: Call a ZCMD command? -
Snipa - 16.03.2011
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/command", cmdtext, true, 10) == 0)
{
return cmd_command(playerid, params);
return 1;
}
return 0;
}
Re: Call a ZCMD command? -
JackYack13 - 17.03.2011
I think we have a misunderstanding here... I updated my post with more details so it's easier to understand...
Re: Call a ZCMD command? -
Zh3r0 - 17.03.2011
Use CallRemoteFunction..
pawn Код:
CallRemoteFunction("OnPlayerCommandText", "is", playerid, Commands[listitem] );
This would work, OnPlayerCommandText is not supposed to be used when using ZCMD.
Re: Call a ZCMD command? -
JackYack13 - 17.03.2011
Thanks, I'll try that
Re: Call a ZCMD command? -
JackYack13 - 17.03.2011
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