[HELP] bug with "admins" command - 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: [HELP] bug with "admins" command (
/showthread.php?tid=528842)
[HELP] bug with "admins" command -
V4at - 30.07.2014
Hi, sometimes it works fine, but once in a way everything shows in the first line.. Where can be problem in this code?
pawn Код:
COMMAND:admins(playerid, params[])
{
new string[800], count=0;
new fstring[64];
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(GetPVarInt(i, "Admin_level") >= 1)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(i,pname, sizeof(pname));
format(fstring, sizeof(fstring),"{FFAF00}» {6EF83C}%s (%i) - {FF0000}Level: %i{FFFFFF}\n", pname, i, GetPVarInt(i, "Admin_level"));
strcat(string, fstring, sizeof(string));
count++;
}
}
ShowPlayerDialog(playerid,2563,DIALOG_STYLE_MSGBOX,"{A3E4FF}Administrators",string,"OK","");
if(count==0) ShowPlayerDialog(playerid,2563,DIALOG_STYLE_MSGBOX,"{A3E4FF}Administrators","{F81414}no administrators online","OK","");
return 1;
}
Re: [HELP] bug with "admins" command -
Threshold - 30.07.2014
Try this:
pawn Код:
COMMAND:admins(playerid, params[])
{
new string[1260], count = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
new var = GetPVarInt(i, "Admin_level");
if(!var) continue;
count++;
if(count >= 15) continue;
new pname[MAX_PLAYER_NAME], fstr[80];
GetPlayerName(i, pname, sizeof(pname));
format(fstr, sizeof(fstr), "{FFAF00}» {6EF83C}%s (%i) - {FF0000}Level: %i\n", pname, i, var);
strcat(string, fstr);
}
if(count > 15)
{
new fstr[60];
format(fstr, sizeof(fstr), "\n{FF0000}There are %d additional Administrators online.", count - 15);
strcat(string, fstr);
}
else if(!count) strcat(string, "{F81414}No Administrators Online");
ShowPlayerDialog(playerid, 2563, DIALOG_STYLE_MSGBOX, "{A3E4FF}Administrators", string, "OK", "");
return 1;
}
Re: [HELP] bug with "admins" command -
V4at - 30.07.2014
Now everything is correctly, thank you!