SA-MP Forums Archive
/admins Bug - 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: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /admins Bug (/showthread.php?tid=211102)



/admins Bug - ]B4E[kengston - 14.01.2011

Код:
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



Re: /admins Bug - Jochemd - 14.01.2011

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.


Re: /admins Bug - Mauzen - 14.01.2011

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


Re: /admins Bug - Jochemd - 14.01.2011

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


AW: /admins Bug - ]B4E[kengston - 14.01.2011

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


Re: /admins Bug - Jochemd - 14.01.2011

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