Dialog 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: Dialog help (
/showthread.php?tid=644681)
Dialog help -
TomRedlake - 12.11.2017
Hello guys,
I have some trouble with
/admins command. Take a look:
Code here:
Код:
CMD:admins(playerid, params[])
{
if(PlayerInfo[playerid][pHour] >= 2 || PlayerInfo[playerid][pAdminLevel] >= 1 || PlayerInfo[playerid][pVIP] >= 1)
{
new adminstring[128],countadmin=0;
if(IsPlayerConnected(playerid))
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdminLevel] > 0)
{
format(adminstring, sizeof(adminstring),"Name\tPosition\tStatus\n\%s%s\t%s\t%s\n", adminstring, GetName(i),GetAdminName(i),GetAdminOnlineStatus(i));
countadmin++;
}
}
}
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_TABLIST_HEADERS,"{00CED1}Online Staff Members",adminstring,"{00CED1}Close","");
}
if(countadmin == 0) return ShowPlayerDialog(playerid, DIALOG_NOONLINE, DIALOG_STYLE_MSGBOX,"{00CED1}Online Staff Members","No Staff members online","{00CED1}Close","");
}
return 1;
}
Re: Dialog help -
SyS - 12.11.2017
concatenate the title to string before entering loop
PHP код:
CMD:admins(playerid, params[])
{
if(PlayerInfo[playerid][pHour] >= 2 || PlayerInfo[playerid][pAdminLevel] >= 1 || PlayerInfo[playerid][pVIP] >= 1)
{
new adminstring[128],countadmin=0;
format(adminstring, sizeof(adminstring),"Name\tPosition\tStatus\n");
if(IsPlayerConnected(playerid))
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdminLevel] > 0)
{
format(adminstring, sizeof(adminstring),"%s%s\t%s\t%s\n", adminstring, GetName(i),GetAdminName(i),GetAdminOnlineStatus(i));
countadmin++;
}
}
}
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_TABLIST_HEADERS,"{00CED1}Online Staff Members",adminstring,"{00CED1}Close","");
}
if(countadmin == 0) return ShowPlayerDialog(playerid, DIALOG_NOONLINE, DIALOG_STYLE_MSGBOX,"{00CED1}Online Staff Members","No Staff members online","{00CED1}Close","");
}
return 1;
}
Note:
Use foreach to iterate through connected players
Using strcat would be better.
Re: Dialog help -
TomRedlake - 12.11.2017
Thank you very much