/admins in dialog - 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: /admins in dialog (
/showthread.php?tid=595330)
/admins in dialog -
Sh4d0w2 - 01.12.2015
My problem with this codes is its only show only 1 admin even there is 3 admins online :
PHP код:
CMD:admins(playerid, params[])
{
new count = 0, string[256],AdmRank[500];
for(new i = 0; i < MAX_PLAYERS; i++)
if(PlayerInfo[i][Level] == 1)
{
AdmRank = "Trial Admin";
}
else if(PlayerInfo[i][Level] == 2)
{
AdmRank = "Server Admin";
}
else if(PlayerInfo[i][Level] == 3)
{
AdmRank = "Senior Admin";
}
else if(PlayerInfo[i][Level] == 4)
{
AdmRank = "Lead Admin";
}
else if(PlayerInfo[i][Level] == 5)
{
AdmRank = "Global Admin";
}
else if(PlayerInfo[i][Level] == 6)
{
AdmRank = "Developer";
}
else if(PlayerInfo[i][Level] == 7)
{
AdmRank = "Co Owner";
}
else if(PlayerInfo[i][Level] == 8)
{
AdmRank = "Owner";
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(PlayerInfo[i][Level] > 0)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(i,Name,sizeof(Name));
{
format(string, sizeof(string), ""cwhite"Level: "cgreen"%d "cwhite"| "cwhite"Name:"cgreen" %s "cwhite"(ID:"cgreen"%i"cwhite") | Rank : "cgreen"%s", PlayerInfo[i][Level], Name, i,AdmRank);
ShowPlayerDialog(playerid,2312,DIALOG_STYLE_MSGBOX,"Admins Online",string,"OK","");
count++;
}
}
}
}
if (count == 0) ShowPlayerDialog(playerid,2322,DIALOG_STYLE_MSGBOX,"Admins Online","{FF0000}No Admins online right now","OK","");
return 1;
}
Re: /admins in dialog -
TwinkiDaBoss - 01.12.2015
First of all, you are using 2 exactly same loops, no reason to do that.
I havent tested this code so let me know if there are any problems
PHP код:
#define MYADMINDIALOG 5
stock GetPlayerAdminRank(playerid) {
new rank[24];
switch(PlayerInfo[playerid][Level]) {
case 0: rank = "Player";
case 1: rank = "Trial Admin";
case 2: rank = "Server Admin";
case 3: rank = "Senior Admin";
case 4: rank = "Lead Admin";
case 5: rank = "Global Admin";
case 6: rank = "Developer";
case 7: rank = "Co Owner";
case 8: rank = "Owner";
}
return rank;
}
stock GetName(playerid)
{
new szName[MAX_PLAYER_NAME];
GetPlayerName(playerid, szName, sizeof(szName));
return szName;
}
CMD:admins(playerid,params[]) {
#pragma unused params
new string[128];
for (new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i)) {
if(PlayerInfo[i][Level] >= 1) {
format(string,sizeof(string),"%s %s\n",GetName(i),GetPlayerAdminRank(i));
}
}
}
ShowPlayerDialog(playerid,MYADMINDIALOG,DIALOG_STYLE_MSGBOX,"Administrators online",string,"Confirm","Decline");
return true;
}
EDIT: Fixed the problem with the name.
EDIT: its always good to have predefined stuff in some cases, for example admin ranks so you can use stuff such as
pawn Код:
format(string,sizeof(string),"%s is my admin rank",GetPlayerAdminRank(playerid));