[Help] Zcmd
#1

How to display a message when there is no command using CMD

Example:

/Hi there


Message: SendClientMessage(playerid, -1, "This command does not exist");
Reply
#2

Код:
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;
}
Reply
#3

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.
Reply
#4

I think it doesnt change anything.. it still works my way too.
Reply
#5

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.
Reply
#6

Thanks guys
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)