Help with using zcmd - 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: Help with using zcmd (
/showthread.php?tid=211465)
Help with using zcmd -
XoX - 15.01.2011
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?
Re: Help with using zcmd -
Stylock - 15.01.2011
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.
Re: Help with using zcmd -
XoX - 15.01.2011
Thank you very much.