SA-MP Forums Archive
returning level to admin name - 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)
+--- Thread: returning level to admin name (/showthread.php?tid=582225)



returning level to admin name - PowerF - 19.07.2015

Код:
COMMAND:admins(playerid, params[])
{
	if (playerData[playerid][playerScore] >= 1000)
	{
		new count = 1, string[828];
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i) && playerData[i][playerAdmin] >= 1 && playerData[i][playerAdmin] < 7)
			{
				// If admin level is higher than 1, here it goes...
				format(string, sizeof(string), "%s%s(%i) - Level: %i\n", string, playerData[i][tempAdminName], i, playerData[i][playerAdmin]);
				count ++;
			}
		}
		
		if(count != 1)
		{
			// Show admins that are presently online, along with their rank
			ShowPlayerDialog(playerid, 200, DIALOG_STYLE_MSGBOX, "Online Administrators", string, "OK", "");
		}
		else
		{
			// No admins online - Either this or nothing, either way the user will know admins are offline...
			ShowPlayerDialog(playerid, 200, DIALOG_STYLE_MSGBOX, "Online Admins", "There are no administrators present.", "OK", "");
		}
	}
	else
	{
	    SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must have at-least 1000 score to view the admin list.");
	}
	
	return 1;
}
if i type /admins,that's just showing the name and level,how do i return it to name?
example;blablabla - level 1 to -> blablabla - Moderator


Re: returning level to admin name - MotherDucker - 19.07.2015

Use something such as a switch / case method.

This way you will be able to change the names easily without having to change all of your code, and you will just need to use one function with one input.

Should look something like this.
Код:
stock AdminLevel(playerid)
{
	switch(playerData[playerid][playerAdmin])
	{
		case 0:
			return "Helper";
		case 1:
			return "Moderator";
		case 2:
			return "Admin";
		...
	}
}



Re: returning level to admin name - PowerF - 09.08.2015

um sorry for bumping this topic :3,someone please?


Re: returning level to admin name - rymax99 - 09.08.2015

Quote:
Originally Posted by PowerF
Посмотреть сообщение
um sorry for bumping this topic :3,someone please?
You already got a response that's valid.

Quote:
Originally Posted by MotherDucker
Посмотреть сообщение
Use something such as a switch / case method.

This way you will be able to change the names easily without having to change all of your code, and you will just need to use one function with one input.

Should look something like this.
Код:
stock AdminLevel(playerid)
{
	switch(playerData[playerid][playerAdmin])
	{
		case 0:
			return "Helper";
		case 1:
			return "Moderator";
		case 2:
			return "Admin";
		...
	}
}