New question, help 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: New question, help command (
/showthread.php?tid=358991)
New question, help command -
NewbieScripter - 12.07.2012
Hello, how to perform this code ? or already is good?
PHP код:
command(admins,playerid)
{
new longstring[200],shortstring[30],Count = 0,pName[25];
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerAdmin(i))
{
Count++;
GetPlayerName(i,pName,25);
format(shortstring,sizeof(shortstring),"%s (ID:%d) \n",pName,playerid);
strcat(longstring,shortstring);
}
}
format(shortstring,sizeof(shortstring),"%d admins online",Count);
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX,"Online Admins",longstring,"Ok","");
return 1;
}
Re: New question, help command -
aRoach - 12.07.2012
pawn Код:
command(admins, playerid)
{
new longstring[200], shortstring[30], Count = 0, pName[25];
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerAdmin(i))
{
Count ++;
GetPlayerName(i, pName, 25);
format(shortstring, sizeof shortstring, "%s (ID:%d) \n", pName, i);
strcat(longstring,shortstring);
}
}
format(shortstring, sizeof shortstring, "%d admins online", Count);
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Online Admins", longstring, "Ok", "");
return 1;
}
Re: New question, help command -
clarencecuzz - 12.07.2012
Why would you change the loop?
Count is supposed to count how many admins are online. This would just ruin it.
It was fine how he had it.
Have a guess what this would return?
pawn Код:
format(shortstring, sizeof shortstring, "%d admins online", Count);
I have no idea either... should have left the loop how it was, if there is an admin online, Count goes up by 1, so it can return the total amount of admins online at the end of the command.