/admins Bug
#1

Код:
if(strcmp("/admins",cmdtext,true) == 0)
	{
	new string[128];
	new name[20];
	for(new i; i<MAX_PLAYERS; i++)
	{
	if(GetPVarInt(i,"Aduty") == 1)
	{
	if(Spieler[i][AdminLevel] >= 1)
	{
	GetPlayerName(i, name, sizeof(name));
	format(string, sizeof(string), "Level: 1  Admin[ID: %d]: %s ",i,name);
	SendClientMessage(playerid, COLOR_LIGHTRED, string);
	}
	if(Spieler[i][AdminLevel] == 2)
	{
	GetPlayerName(i, name, sizeof(name));
	format(string, sizeof(string), "Level: 2  Admin[ID: %d]: %s ",i,name);
	SendClientMessage(playerid, COLOR_LIGHTRED, string);
	}
	if(Spieler[i][AdminLevel] == 3)
	{
	GetPlayerName(i, name, sizeof(name));
	format(string, sizeof(string), "Level: 3  Admin[ID: %d]: %s ",i,name);
	SendClientMessage(playerid, COLOR_LIGHTRED, string);
	}
	if(Spieler[i][AdminLevel] == 4)
	{
	GetPlayerName(i, name, sizeof(name));
	format(string, sizeof(string), "Level: 4  Admin[ID: %d]: %s ",i,name);
	SendClientMessage(playerid, COLOR_LIGHTRED, string);
	}
	if(Spieler[i][AdminLevel] == 5)
	{
	GetPlayerName(i, name, sizeof(name));
	format(string, sizeof(string), "Level: 5  Admin[ID: %d]: %s ",i,name);
	SendClientMessage(playerid, COLOR_LIGHTRED, string);
	}
	if(Spieler[i][AdminLevel] == 6)
	{
	GetPlayerName(i, name, sizeof(name));
	format(string, sizeof(string), "Level: 6  Admin[ID: %d]: %s ",i,name);
	SendClientMessage(playerid, COLOR_LIGHTRED, string);
	}
	if(Spieler[i][AdminLevel] == 7)
	{
	GetPlayerName(i, name, sizeof(name));
	format(string, sizeof(string), "Level: 7  Admin[ID: %d]: %s ",i,name);
	SendClientMessage(playerid, COLOR_LIGHTRED, string);
	}}}
	return 1;
}


You know the Bug? Please help me.

]B4E[kengston
Reply
#2

pawn Код:
if(Spieler[i][AdminLevel] >= 1)
to
pawn Код:
if(Spieler[i][AdminLevel] == 1)
You do actually check if the admin level is HIGHER than one, or equal.
Reply
#3

if(Spieler[i][AdminLevel] >= 1)

This will also be called when you are a lvl 9999 admin, so there will be 2 messages

change it to

if(Spieler[i][AdminLevel] == 1)

like for the other levels.


Another more clean variant would be not to handle every level itself, but to make it dynamic.
Just check if the admin level is >= 1 and then use

pawn Код:
format(string, sizeof(string), "Level: %d  Admin[ID: %d]: %s ",Spieler[i][AdminLevel],i,name);
To insert the level, so you dont have to use the same code again and again.


Edit: Too slow, first method already posted
Reply
#4

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Another more clean variant would be not to handle every level itself, but to make it dynamic.
Just check if the admin level is >= 1 and then use

pawn Код:
format(string, sizeof(string), "Level: %d  Admin[ID: %d]: %s ",Spieler[i][AdminLevel],i,name);
To insert the level, so you dont have to use the same code again and again.
Maybe he wants to sort it on level. :P
Reply
#5

Damn Thank you. This was a stupid mistake :P THX
Reply
#6

Btw, just a little detail, but I would check if the player 'i' is connected (otherwise it may loop like 480 times to much through MAX_PLAYERS while it's useless.)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)