Some help... -
Ankon - 02.01.2016
Hello everyone. I am not a pro scripter and thus want a help from you all.I wante to make a hidebadge command. It means that the player can hide his original nametag colour(the colour on your names when you press TAB)...
I used sscanf.. But I can't use it properly so I am using isnull..
First I defined these things at the top of my gamemode.
//---Some functions---//
#if !defined isnull
#define isnull(%1) \
((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
//----end of these functions---//
Then I used this command...(I use i-zcmd to make commands..)
CMD:hbadge(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /hbadge [FBI,LSPD,OFF]");
else if(strcmp(params,"lspd",true) == 0)
{
SetPlayerColor(playerid,COLOR_BLUE);
SendClientMessage(playerid, COLOR_WHITE, "Badge on.");
}
else if(strcmp(params,"fbi",true) == 0)
{
SetPlayerColor(playerid,COLOR_LIGHTERBLUE);
SendClientMessage(playerid, COLOR_WHITE, "Badge on.");
}
else if(strcmp(params,"off",true) == 0)
{
SetPlayerColor(playerid,COLOR_WHITE);
SendClientMessage(playerid, COLOR_WHITE, "You're badge has been removed");
}
return 1;
}
//---End of command---//
I added isnull because if they just wrote /hbadge then a message would say them "Correct Usage:blah blah blah.."
Everything works perfect... The badge works..
But when I type only /hbadge the SendClientMessage with correct usage doesn't show up.. Please help..
If you think should use sscanf please mention how...
I say again.. I am a noob scripter..not as pro like you all..
Thanks...
Graceful if you help..
Re: Some help... -
Godey - 02.01.2016
I Suggest you use a dialog response
because that is much easier and you can understand it better.
Do you want me to make it for you?
Re: Some help... -
Godey - 02.01.2016
If you still need the old one, You Haven't returned a value so,
Code:
CMD:hbadge(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /hbadge [FBI,LSPD,OFF]");
else if(strcmp(params,"lspd",true) == 0)
{
SetPlayerColor(playerid,COLOR_BLUE);
SendClientMessage(playerid, COLOR_WHITE, "Badge on.");
return 1;
}
else if(strcmp(params,"fbi",true) == 0)
{
SetPlayerColor(playerid,COLOR_LIGHTERBLUE);
SendClientMessage(playerid, COLOR_WHITE, "Badge on.");
return 1;
}
else if(strcmp(params,"off",true) == 0)
{
SetPlayerColor(playerid,COLOR_WHITE);
SendClientMessage(playerid, COLOR_WHITE, "You're badge has been removed");
return 1;
}
return 1;
}
Please rep me if it helped!
Re: Some help... -
AndySedeyn - 02.01.2016
You're using an else-if statement for nothing. You're returning a value in every single statement making the else-if statements redundant. Here's an example with sscanf:
PHP Code:
CMD:hbadge(playerid, params[]) {
new
faction[5];
if(sscanf(params, "s[5]", faction)) {
return SendClientMessage(playerid, COLOR_RED, "USAGE: /hbadge [FBI, LSPD, OFF]");
}
if(!strcmp(faction, "fbi", true)) {
SetPlayerColor(playerid, COLOR_BLUE);
SendClientMessage(playerid, COLOR_WHITE, "Badge on.");
}
else if(!strcmp(faction, "lspd", true)) {
SetPlayerColor(playerid, COLOR_LIGHTERBLUE);
SendClientMessage(playerid, COLOR_WHITE, "Badge on.");
}
else if(!strcmp(faction, "off", true)) {
SetPlayerColor(playerid, COLOR_WHITE);
SendClientMessage(playerid, COLOR_WHITE, "Your badge has been removed.");
}
else {
SendClientMessage(playerid, COLOR_RED, "You've entered an incorrect faction name.");
}
return true;
}
The exclamation point before the strcmp function is the same as doing "== 0" at the end of the strcmp function.
Re: Some help... -
Godey - 02.01.2016
Ankon Said:
Quote:
I used sscanf.. But I can't use it properly so I am using isnull..
|
Re: Some help... -
AndySedeyn - 02.01.2016
Quote:
Originally Posted by Godey
Ankon Said:
|
So what? He has to learn somehow. And why not by a working example?
Re: Some help... -
Godey - 02.01.2016
Quote:
So what? He has to learn somehow. And why not by a working example?
|
Sure, well atleast it's fixed

And both function the same tho'
Re: Some help... -
Ankon - 03.01.2016
Yep AndySedeyn is right... I have to learn.. and thank you all for the fix... Thanks AndySedeyn.... I quite learned somethings.. Thanks...
Rep(ed) you both.. Thanks...