[Help] 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)
+--- Thread: [Help] Zcmd (
/showthread.php?tid=559751)
[Help] Zcmd -
INKISICION - 25.01.2015
How to display a message when there is no command using CMD
Example:
/Hi there
Message:
SendClientMessage(playerid, -1, "This command does not exist");
Re: [Help] Zcmd -
scout322 - 25.01.2015
Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success) SendClientMessage(playerid, COLOR_NEWS, "Error: That command does not exist. Refer to /help for server commands.");
return 1;
}
Re: [Help] Zcmd -
WopsS - 25.01.2015
Quote:
Originally Posted by scout322
Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success) SendClientMessage(playerid, COLOR_NEWS, "Error: That command does not exist. Refer to /help for server commands.");
return 1;
}
|
This should be
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success)
return SendClientMessage(playerid, COLOR_NEWS, "Error: That command does not exist. Refer to /help for server commands."), 0;
return 1;
}
You want to stop exection of function when command doesn't exist and return 0 because it doesn't exist.
Re: [Help] Zcmd -
scout322 - 25.01.2015
I think it doesnt change anything.. it still works my way too.
Re: [Help] Zcmd -
WopsS - 25.01.2015
Quote:
Originally Posted by scout322
I think it doesnt change anything.. it still works my way too.
|
Maybe it work for you, but your example is wrong.
Let's say that, all players need to have score greater then 1, ok?
And on the server we will have 2 players:
Player X and
Player Y.
Your code will be
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success)
SendClientMessage(playerid, COLOR_NEWS, "Error: That command does not exist. Refer to /help for server commands.");
if(GetPlayerScore(playerid) <= 1)
SendClientMessage(playerid, COLOR_NEWS, "Error: You need to have score greater then 1 to use commands on this server");
return 1;
}
Now,
Player X's level is 2 and
Player Y's level is 1.
Each player will execute two commands.
/command1 - require score 2 to use it.
/command2 - doesn't exist.
Player X will execute:
/command1 and
/command2.
When
Player X will execute
/command1, he will be ok, no error message.
When
Player X will execute
/command2, he will receive a message with unknown command.
Player Y will execute:
/command1 and
/command2.
When
Player Y will execute
/command1, he will receive a message about the level.
When
Player Y will execute
/command2, he will receive a message with unknown command and about the level.
So, if you want to avoid this you need to return function with 0 and you need that.
Re: [Help] Zcmd -
INKISICION - 25.01.2015
Thanks guys