SA-MP Forums Archive
[Tutorial] [TUT] How to add a message when the command is wrong - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] [TUT] How to add a message when the command is wrong (/showthread.php?tid=129740)

Pages: 1 2


[TUT] How to add a message when the command is wrong - yoan103 - 23.02.2010

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


Re: [TUT] How to add a message when the command is wrong - Torran - 23.02.2010

That dosent really work for me


Re: [TUT] How to add a message when the command is wrong - yoan103 - 23.02.2010

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


Re: [TUT] How to add a message when the command is wrong - Torran - 23.02.2010

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


Re: [TUT] How to add a message when the command is wrong - yoan103 - 23.02.2010

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


Re: [TUT] How to add a message when the command is wrong - saiberfun - 23.02.2010

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


Re: [TUT] How to add a message when the command is wrong - yoan103 - 23.02.2010

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");
}


Re: [TUT] How to add a message when the command is wrong - Torran - 23.02.2010

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


Re: [TUT] How to add a message when the command is wrong - yoan103 - 23.02.2010

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


Re: [TUT] How to add a message when the command is wrong - yoan103 - 24.02.2010

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


Re: [TUT] How to add a message when the command is wrong - Torran - 24.02.2010

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


Re: [TUT] How to add a message when the command is wrong - Klutty - 24.02.2010

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


Re: [TUT] How to add a message when the command is wrong - [DK]JaloNik - 08.07.2010

Nice thanks,.


Re: [TUT] How to add a message when the command is wrong - MadalinX5 - 10.07.2010

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 :\


Re: [TUT] How to add a message when the command is wrong - GaGlets(R) - 11.07.2010

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.
}



Re: [TUT] How to add a message when the command is wrong - [NTX]MikeQ - 12.07.2010

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


Re: [TUT] How to add a message when the command is wrong - iZN - 13.07.2010

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.


Re: [TUT] How to add a message when the command is wrong - Kar - 13.07.2010

whats the zcmd


Re: [TUT] How to add a message when the command is wrong - Aleluja - 13.07.2010

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


Re: [TUT] How to add a message when the command is wrong - Thebest96 - 16.07.2010

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