/staffadmins
#1

Problem: when i type the command i get a single admin (but i have 6 on my server),and when i click on it,i give the staff panel for me. (Topkenzo - Nivel 7) (TopKenzo - AdminLevel 7)

Dialog:

Код:
if(dialogid == DIALOG_STAFFAM)
	{
		if(response)
		{
			if(listitem >= 0)
			{
				if(PlayerInfo[playerid][pAdmin] >= 6)
				{
					new name[30],result[30],query[300],test[5],strings[300];
					format(query, sizeof(query), "SELECT * FROM `users` WHERE `id`='%d'",Selected[playerid][listitem]);
					new Cache: membresult = mysql_query(SQL,query);
					for(new i, j = cache_get_row_count (); i != j; ++i)
					{
						cache_get_field_content(i, "name", result); format(name, 30, result);
						cache_get_field_content(i, "Admin", result); format(test, 5, result);
					}
					cache_delete(membresult);
					Selected2[playerid] = Selected[playerid][listitem];
					format(strings, sizeof(strings),"Admin %s - nivel %s",name,test);
					ShowPlayerDialog(playerid, DIALOG_STAFFAM2, DIALOG_STYLE_LIST, strings, "Promoveaza\nRetrogradeaza\nRemove", "Alege", "Iesire");
				}
			}
		}
	}
	if(dialogid == DIALOG_STAFFAM2)
	{
		if(response)
		{
			if(listitem == 0)
			{
				new string1[256],rank;
				if(PlayerInfo[playerid][pSQLID] == Selected2[playerid]) return SendClientMessage(playerid, COLOR_GREY, "Nu te poti promova singur.");
				foreach(new i : Player)
				{
					if(PlayerInfo[i][pSQLID] == Selected2[playerid])
					{
						if(!EstiFondator(playerid) && PlayerInfo[i][pAdmin] > 5) return SendClientMessage(playerid, COLOR_WHITE, "Nu poti promova un admin 6+.");
					}
				}
				format(string1, sizeof(string1), "SELECT * FROM `users` WHERE `id`='%d'",Selected2[playerid]);
				new Cache: membresult = mysql_query(SQL,string1);
				for(new i, j = cache_get_row_count (); i != j; ++i)
				{
					rank = cache_get_field_content_int(i, "Admin");
				}
				cache_delete(membresult);
				if(PlayerInfo[playerid][pAdmin] == rank && !EstiFondator(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Nu poti promova un admin cu nivel la fel de mare ca tine.");
				if(PlayerInfo[playerid][pAdmin] < rank && !EstiFondator(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Nu poti promova un admin cu nivel mai mare decat tine.");
				new str[256],stringg[128],fwarn,name[30],name2[30],result[30];
				for(new i, j = cache_get_row_count (); i != j; ++i)
				{
					cache_get_field_content(i, "name", result); format(name2, 30, result);
					fwarn = cache_get_field_content_int(i, "Admin");
				}
				cache_delete(membresult);
				mysql_format(SQL,str,sizeof(str),"UPDATE users SET Admin = Admin+1 WHERE id = %d",Selected2[playerid]);
				mysql_tquery(SQL,str,"","");
				GetPlayerName(playerid, name, sizeof(name));
				format(stringg, sizeof(stringg), "L-ai promovat pe %s la urmatorul nivel de admin!", name2);
				SendClientMessage(playerid, COLOR_WHITE, stringg);
				format(str,sizeof(str),"%s l-a promovat pe %s la nivel de admin %d.",name,name2,(fwarn+1));
				ABroadCast(COLOR_YELLOW,str,1); // HLChat(COLOR_RED2,str);
				HLChat(COLOR_YELLOW,str);
				cmd_staffadmins(playerid, "");
				foreach(new i : Player)
				{
					if(PlayerInfo[i][pSQLID] == Selected2[playerid])
					{
						PlayerInfo[i][pAdmin] += 1;
						format(stringg, sizeof(stringg),"%s te-a promovat la nivel de admin %d.",name, PlayerInfo[i][pAdmin]);
						SendClientMessage(i, COLOR_YELLOW, stringg);
					}
				}		
			}
			if(listitem == 1)
			{
				new string1[256],rank;
				if(PlayerInfo[playerid][pSQLID] == Selected2[playerid]) return SendClientMessage(playerid, COLOR_GREY, "Nu te poti retrograda singur.");
				foreach(new i : Player)
				{
					if(PlayerInfo[i][pSQLID] == Selected2[playerid])
					{
						if(!EstiFondator(playerid) && PlayerInfo[i][pAdmin] > 5) return SendClientMessage(playerid, COLOR_WHITE, "Nu poti retrograda un admin 6+.");
					}
				}
				format(string1, sizeof(string1), "SELECT * FROM `users` WHERE `id`='%d'",Selected2[playerid]);
				new Cache: membresult = mysql_query(SQL,string1);
				for(new i, j = cache_get_row_count (); i != j; ++i)
				{
					rank = cache_get_field_content_int(i, "Admin");
				}
				cache_delete(membresult);
				if(PlayerInfo[playerid][pAdmin] == rank && !EstiFondator(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Nu poti retrograda un admin cu nivel la fel de mare ca tine.");
				if(PlayerInfo[playerid][pAdmin] < rank && !EstiFondator(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Nu poti retrograda un admin cu nivel mai mare decat tine.");
				new str[256],stringg[128],fwarn,name[30],name2[30],result[30];
				format(stringg, sizeof(stringg), "SELECT * FROM `users` WHERE `id`='%d'",Selected2[playerid]);
				for(new i, j = cache_get_row_count (); i != j; ++i)
				{
					cache_get_field_content(i, "name", result); format(name2, 30, result);
					fwarn = cache_get_field_content_int(i, "Admin");
				}
				cache_delete(membresult);
				mysql_format(SQL,str,sizeof(str),"UPDATE users SET Admin = Admin-1 WHERE id = %d",Selected2[playerid]);
				mysql_tquery(SQL,str,"","");
				GetPlayerName(playerid, name, sizeof(name));
				format(stringg, sizeof(stringg), "L-ai retrogradat pe %s la nivel de admin %d!", name2, (fwarn-1));
				SendClientMessage(playerid, COLOR_WHITE, stringg);

				format(str,sizeof(str),"%s l-a retrogradat pe %s la nivel de admin %d.",name,name2,(fwarn-1));
				ABroadCast(COLOR_YELLOW,str,1); // HLChat(COLOR_RED2,str);
				HLChat(COLOR_YELLOW,str);
				cmd_staffadmins(playerid, "");
				foreach(new i : Player)
				{
					if(PlayerInfo[i][pSQLID] == Selected2[playerid])
					{
						PlayerInfo[i][pAdmin] -= 1;
						format(stringg, sizeof(stringg),"%s te-a retrogradat la nivel de admin %d.",name, PlayerInfo[i][pAdmin]);
						SendClientMessage(i, COLOR_YELLOW, stringg);
					}
				}		
			}
			if(listitem == 2)
			{
				new string1[256],rank;
				if(PlayerInfo[playerid][pSQLID] == Selected2[playerid]) return SendClientMessage(playerid, COLOR_GREY, "Nu-ti poti da remove singur.");
				foreach(new i : Player)
				{
					if(PlayerInfo[i][pSQLID] == Selected2[playerid])
					{
						if(!EstiFondator(playerid) && PlayerInfo[i][pAdmin] > 5) return SendClientMessage(playerid, COLOR_WHITE, "Nu-i poti da remove unui admin 6+.");
					}
				}
				format(string1, sizeof(string1), "SELECT * FROM `users` WHERE `id`='%d'",Selected2[playerid]);
				new Cache: membresult = mysql_query(SQL,string1);
				for(new i, j = cache_get_row_count (); i != j; ++i)
				{
					rank = cache_get_field_content_int(i, "Admin");
				}
				cache_delete(membresult);
				if(PlayerInfo[playerid][pAdmin] == rank && !EstiFondator(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Nu-i poti da remove unui admin cu nivel la fel de mare ca tine.");
				if(PlayerInfo[playerid][pAdmin] < rank && !EstiFondator(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Nu-i poti da remove unui admin cu nivel mai mare decat tine.");
				new str[256],stringg[128],name[30],name2[30],result[30];
				format(stringg, sizeof(stringg), "SELECT * FROM `users` WHERE `id`='%d'",Selected2[playerid]);
				for(new i, j = cache_get_row_count (); i != j; ++i)
				{
					cache_get_field_content(i, "name", result); format(name2, 30, result);
				}
				cache_delete(membresult);
				mysql_format(SQL,str,sizeof(str),"UPDATE users SET Admin = 0 WHERE id = %d",Selected2[playerid]);
				mysql_tquery(SQL,str,"","");
				GetPlayerName(playerid, name, sizeof(name));
				format(stringg, sizeof(stringg), "I-ai dat remove lui %s din echipa adminilor!", name2);
				SendClientMessage(playerid, COLOR_WHITE, stringg);
				format(str,sizeof(str),"%s i-a dat remove lui %s din echipa adminilor.",name,name2);
				HLChat(COLOR_YELLOW,str);
				ABroadCast(COLOR_YELLOW,str,1); // HLChat(COLOR_RED2,str);
				cmd_staffadmins(playerid, "");
				foreach(new i : Player)
				{
					if(PlayerInfo[i][pSQLID] == Selected2[playerid])
					{
						PlayerInfo[i][pAdmin] = 0;
						format(stringg, sizeof(stringg),"%s ti-a dat remove din echipa adminilor.",name);
						SendClientMessage(i, COLOR_YELLOW, stringg);
					}
				}		
			}
		}
	}
command:

Код:
CMD:staffadmins(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 6)
	{
		new aim[5000],
			query[300],
			test[300],
			test1,
			test2[300],
			test3,
			aimtotal[5000],
			result[300],
			idd,
			mid=0;
		format(query, sizeof(query), "SELECT * FROM `users` WHERE `Admin` > '0'");
		new Cache: membresult = mysql_query(SQL, query);
		for(new i, j = cache_get_row_count (); i != j; ++i)
		{
			cache_get_field_content(i, "name", result); format(test, 300, result);
			test1 = cache_get_field_content_int(i, "Admin");
			cache_get_field_content(i, "lastOn", result); format(test2, 300, result);
			test3 = cache_get_field_content_int(i, "Helps");
			idd = cache_get_field_content_int(i, "id");
			Selected[playerid][mid] = idd;
			if(GetPlayerID(test) != INVALID_PLAYER_ID)
			{
				format(aim, sizeof(aim), "%s\tonline acum\t%d\t%d\n", test, test1, test3);
			}
			else
			{
				format(aim, sizeof(aim), "%s\t%s\t%d\t%d\n", test, test2, test1, test3);
			}
			mid++;
		}
		cache_delete(membresult);
		format(aimtotal, sizeof(aimtotal), "Nume\tUltima logare\tNivel de admin\tPuncte de ajutor\n%s",aim);
		ShowPlayerDialog(playerid,DIALOG_STAFFAM,DIALOG_STYLE_TABLIST_HEADERS,"ADMINI",aimtotal,"Alege","Iesire");
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)