/admins help - 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 help (
/showthread.php?tid=409009)
/admins help -
Noles2197 - 20.01.2013
Only one admin will appear on the list of admins even if there's more than one online.
Help appreciated!
PHP код:
case 2:
{
new name[MAX_PLAYER_NAME],string[128],id,admin[20],duty[32];
GetPlayerName(id,name,sizeof(name));
if(PlayerInfo[playerid][pAdmin]==1) {admin ="Moderator";}
else if(PlayerInfo[playerid][pAdmin]==2) {admin="Administrator";}
else if(PlayerInfo[playerid][pAdmin]==3) {admin = "Head Administrator";}
if(PlayerInfo[playerid][pDuty]==0) {duty ="{FF0000}Off duty";}
else if(PlayerInfo[playerid][pDuty]==1) {duty ="{007F0E}On duty!";}
if(PlayerInfo[id][pAdmin]>0)
{
format(string,sizeof(string),"{FF7FB6}%s {A9C4E4}%s is %s",admin,name,duty);
ShowPlayerDialog(playerid,6,DIALOG_STYLE_MSGBOX,"Staff team", string, "Close", "");
}
}
Re: /admins help -
Threshold - 20.01.2013
I'm assuming this code is inside a loop, so...
pawn Код:
case 2:
{
new name[MAX_PLAYER_NAME],string[128],id,admin[20],duty[32];
GetPlayerName(id,name,sizeof(name));
switch(PlayerInfo[id][pAdmin])
{
case 1: admin = "Moderator";
case 2: admin = "Administrator";
case 3: admin = "Head Administrator";
}
if(PlayerInfo[id][pDuty] == 0)
{
duty = "{FF0000}Off duty";
}
else if(PlayerInfo[playerid][pDuty] == 1)
{
duty = "{007F0E}On duty!";
}
if(PlayerInfo[id][pAdmin] > 0)
{
format(string,sizeof(string),"%s{FF7FB6}%s {A9C4E4}%s is %s\n",admin,name,duty);
}
}
ShowPlayerDialog(playerid,6,DIALOG_STYLE_MSGBOX,"Staff team", string, "Close", "");
NOTE: PlayerInfo[playerid][pAdmin]
You are not trying to find the Admin level of 'PLAYERID', you are trying to find the Admin level of 'ID', so you would use:
PlayerInfo[id][pAdmin]
Also, if you're formatting strings, you should always use the string outside the loop until it is fully built, like using string in a ShowPlayerDialog line, the ShowPlayerDialog should be OUTSIDE the loop.
https://sampwiki.blast.hk/wiki/Loops