[Tutorial] [TUT] How to add a message when the command is wrong
#1

Allways get tired of the SERVER: Unknown command when a player types something else, that isn't added to your gamemode commands? Well here is how to do it, if you have dcmd or onplayercommandtext. In the end of the whole OnPlayerCommandText there should be
Code:
return 0;
replace it with this
Code:
	 return SendClientMesage(playerid, COLOR_ORANGE, "Command does not exist please use /help");
}
put whatever you want it to say, and put this in the defines place
Code:
#define COLOR_ORANGE 0xFF9900AA
You can change the text to whatever you want, you can even add a GameTextForPlayer, here are my set of colors i am using
Code:
#define COLOR_RED 0xAA3333AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_SPAWN 0xFF8C55FF
#define COLOR_LIGHTBLUE 0x6DC5F3FF
#define COLOR_ADMIN 0xFF0000FF
#define COLOR_SAY 0x2986CEFF
#define COLOR_SYSGREY 0xC6BEBDFF
#define COLOR_BLACK 0x000000FF
#define COLOR_JOIN 0x74E80099
#define COLOR_WARN 0xBE615099
#define COLOR_RACE 0x00BBBB99
#define COLOR_KRED 0xFF0000FF
P.S COLOR_RACE is pretty cool
Reply
#2

That dosent really work for me
Reply
#3

Why is that it works perfectly to me just put the return SendClientMessage On the return 0;
Reply
#4

Quote:
Originally Posted by yoan103
Why is that it works perfectly to me
Might be the fact that im using ZCMD but yeah it does SERVER: UNKNOWN COMMAND,
Even if i do that And btw i didnt get it of this tut ive known it before
Reply
#5

zcmd this is the first time i'm hearing about it, so yea maybe it doesn't work for zcmd and i use the normal commands so there aren't any errors and it's pretty handy
Reply
#6

Quote:
Originally Posted by Torran
Quote:
Originally Posted by yoan103
Why is that it works perfectly to me
Might be the fact that im using ZCMD but yeah it does SERVER: UNKNOWN COMMAND,
Even if i do that And btw i didnt get it of this tut ive known it before
zcmd got an own callback doesnt it?
well just goto the usual OnPlayerCommandText or add it again and then return SendClientMesage(playerid, COLOR_ORANGE, "Command does not exist please use /help");

should work i guess
but dunno zcmd really
Reply
#7

OK but does it work for the people that are using normal commands?
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, COLOR_RACE, "You don't have enough $ to heal.");
GivePlayerMoney(playerid, -500);
SendClientMessage(playerid, COLOR_RACE, "Healed for 500$.");
SetPlayerHealth(playerid, 100);
return 1;
}

return SendClientMesage(playerid, COLOR_ORANGE, "Command does not exist please use /help");
}
Reply
#8

Quote:
Originally Posted by ┤ŞąiBЄЯҒПŋ├
Quote:
Originally Posted by Torran
Quote:
Originally Posted by yoan103
Why is that it works perfectly to me
Might be the fact that im using ZCMD but yeah it does SERVER: UNKNOWN COMMAND,
Even if i do that And btw i didnt get it of this tut ive known it before
zcmd got an own callback doesnt it?
well just goto the usual OnPlayerCommandText or add it again and then return SendClientMesage(playerid, COLOR_ORANGE, "Command does not exist please use /help");

should work i guess
but dunno zcmd really
Lol yeah it has its own xd I forgot about that
Reply
#9

If anyone likes my tutorials please post comments and i will upload a tutorial with SetPlayerPos but to teleport with vehicle!!!
Reply
#10

please tell me what you liked or not in my tutorials pLSsss
Reply
#11

Quote:
Originally Posted by yoan103
please tell me what you liked or not in my tutorials pLSsss
Its good for newbies, But alot of people already know this
Reply
#12

Well, its good for the people that didn't know this before.
Reply
#13

Nice thanks,.
Reply
#14

Maybe because it's SendClientMessage not mesage IT took me a like 2 mins to figure out what was wrong and why the command was invalid :\
Reply
#15

Omg you can also ad else after all commands and remove that stupid
pawn Code:
return 1/0;
pawn Code:
public commandscallback
{
if(commands){...
...
...
}
else
{
//Message/or smth else
return 1;
}
//no return needed anymore to this callback.
}
Reply
#16

Quote:
Originally Posted by ded
View Post
ZCMD doesn't call OnPlayerCommandText..
Yeah that sux
Reply
#17

pawn Code:
else
        {
                new string[128], cmd[256], idx;
                cmd = strtok(cmdtext, idx);
        format(string, sizeof(string), "%s is an Unknown Command. Please check /help", cmd);
        SendClientMessage(playerid, COLOR_WHITE, string);
        }
        return 1;
    }
This codes works... Plus good now.
Reply
#18

whats the zcmd
Reply
#19

Quote:
Originally Posted by Klutty
View Post
Well, its good for the people that didn't know this before.
I agree with YOu
Reply
#20

N00b tuturial dont helped in nothing, ohhh helped in CRASH MY SCRIPT!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)