Abit of help please. -
Tye Huntley - 04.10.2011
Hello,
I am having a tiny issue. I made a system up where if you were say admin rank 2 it would say Junior Admin when I type /newbie and if you were admin rank 99999 you would show up as Community Manager on /newbie, but when I do /newbie as a level 99999 Administrator it says Junior Admin.
Код:
SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/n)ewbie [newbie chat]");
return 1;
}
if(PlayerInfo[playerid][pLevel] > 1 && PlayerInfo[playerid][pAdmin] <= 1 && PlayerInfo[playerid][pHelper] <= 0) format(string, sizeof(string), "** Player %s: %s", sendername, result);
else if(PlayerInfo[playerid][pAdmin] >= 2) format(string, sizeof(string), "Junior Admin %s: %s", sendername, result);
else if(PlayerInfo[playerid][pAdmin] >= 3) format(string, sizeof(string), "General Admin %s: %s", sendername, result);
else if(PlayerInfo[playerid][pAdmin] >= 4) format(string, sizeof(string), "Senior Admin %s: %s", sendername, result);
else if(PlayerInfo[playerid][pAdmin] >= 1337) format(string, sizeof(string), "Lead Admin %s: %s", sendername, result);
else if(PlayerInfo[playerid][pAdmin] >= 99998) format(string, sizeof(string), "Community Scripter %s: %s", sendername, result);
else if(PlayerInfo[playerid][pAdmin] >=99999) format(string, sizeof(string), "Community Manager %s: %s", sendername, result);
else if(PlayerInfo[playerid][pDonateRank] >= 1) format(string, sizeof(string), "VIP %s: %s", sendername, result);
else if(PlayerInfo[playerid][pHelper] >= 5) format(string, sizeof(string), "Head Helper %s: %s", sendername, result);
else if(PlayerInfo[playerid][pHelper] >= 4) format(string, sizeof(string), "Assistant Head Helper %s: %s", sendername, result);
else if(PlayerInfo[playerid][pHelper] >= 3) format(string, sizeof(string), "Senior Helper %s: %s", sendername, result);
else if(PlayerInfo[playerid][pHelper] >= 2) format(string, sizeof(string), "General Helper %s: %s", sendername, result);
else if(PlayerInfo[playerid][pHelper] == 1) format(string, sizeof(string), "Junior Helper %s: %s", sendername, result);
else format(string, sizeof(string), "Newbie %s: %s", sendername, result);
OOCNewbie(NEWBIE_COLOR,string);
if(PlayerInfo[playerid][pAdmin] <= 1 && PlayerInfo[playerid][pHelper] <= 0) { UseNewbieTimer[playerid] = true; SetTimerEx("UseNewbie",50*1000,0,"i",playerid); }
}
}
This is the code I have for it right now.
Also I made something similar for the helpers where if you did /helpers if you were say rank 3 helper it would say Senior Helper %s [NAME], but when I do /helpers and I am a rank 5 helper it says all the ranks and my name like
Junior Helper %s
General Helper %s
Senior Helper %s
Assistant Head Helper %s
Head Helper %s
This is the code I used for this:
Код:
if (strcmp(cmd, "/helpers", true) == 0)
{
if(IsPlayerConnected(playerid))
{
SendClientMessage(playerid, COLOR_GRAD1, "Helpers Online:");
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pHelper] >= 1)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "Junior Helper %s", sendername);
SendClientMessage(playerid, COLOR_GRAD2, string);
}
if(PlayerInfo[i][pHelper] >= 2)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "General Helper %s", sendername);
SendClientMessage(playerid, COLOR_GRAD2, string);
}
if(PlayerInfo[i][pHelper] >= 3)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "Senior Helper %s", sendername);
SendClientMessage(playerid, COLOR_GRAD2, string);
}
if(PlayerInfo[i][pHelper] >= 4)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "Assistant Head Helper %s", sendername);
SendClientMessage(playerid, COLOR_GRAD2, string);
}
if(PlayerInfo[i][pHelper] >= 5)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "Head Helper %s", sendername);
SendClientMessage(playerid, COLOR_GRAD2, string);
}
}
}
}
return 1;
}
Could someone explain why these things are doing this?
Thank you in advance and +1 REP to whoever can help me.
EDIT: Okay I got /helpers showing only one rank by adding else in front of if, but it only shows Junior Helper. and non of the other ranks.
Re: Abit of help please. -
Tye Huntley - 04.10.2011
Bump. Really need help on this.
Re: Abit of help please. -
hittt - 04.10.2011
Obviously, you need to put the rank checks on a descending order. First would be 99999 then 99998 then 1337 and blah blah blah
Re: Abit of help please. -
Tye Huntley - 04.10.2011
I dont really think that should make a differance because of the pHelper and pAdmin it should be able to check what it is, but I will give it a shot.
Re: Abit of help please. -
hittt - 05.10.2011
Ill try to explain you with very easy words what you did wrong.
For example we have this code.
pawn Код:
new num = 4;
if (num >= 0) print("Our number is higher or equal to 0");
else if (num >= 1) print("Our number is higher or equal to 1");
else if (num >= 2) print("Our number is higher or equal to 2");
else if (num >= 3) print("Our number is higher or equal to 3");
else if (num >= 4) print("Our number is higher or equal to 4");
else if (num >= 5) print("Our number is higher or equal to 5");
This will return:
Код:
Our number is higher or equal to 0
In this case, pawn will first check if our number is higher or equal than 0, which is true since 5 >= 0, and it will SKIP all other checks.
In a second example we have
pawn Код:
new num = 4;
if (num >= 0) print("Our number is higher or equal to 0");
if (num >= 1) print("Our number is higher or equal to 1");
if (num >= 2) print("Our number is higher or equal to 2");
if (num >= 3) print("Our number is higher or equal to 3");
if (num >= 4) print("Our number is higher or equal to 4");
if (num >= 5) print("Our number is higher or equal to 5");
This will return:
Код:
Our number is higher or equal to 0
Our number is higher or equal to 1
Our number is higher or equal to 2
Our number is higher or equal to 3
Our number is higher or equal to 4
In this case, pawn will check our number with all 6 if() statements, and it will not skip anything. (Which is still not what you want)
BUT!
pawn Код:
new num = 4;
if (num >= 5) print("Our number is higher or equal to 5");
else if (num >= 4) print("Our number is higher or equal to 4");
else if (num >= 3) print("Our number is higher or equal to 3");
else if (num >= 2) print("Our number is higher or equal to 2");
else if (num >= 1) print("Our number is higher or equal to 1");
else if (num >= 0) print("Our number is higher or equal to 0");
This will return:
Код:
Our number is higher or equal to 4
In this case, it will first check our number with 4 >= 5, which is false, it will then try 4 >= 4, which is true, and it will SKIP all others...
Which is exactly what you need