admins online 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: admins online command (
/showthread.php?tid=486340)
admins online command -
rocker3410 - 08.01.2014
Hi I was wondering if someone can make me a command that shows online admins but in a dialog box which only shows names not level.
Re: admins online command -
ReD_HunTeR - 08.01.2014
Код:
#define DIALOG_ONLINEADMINS 1
CMD:admins(playerid, params[])
{
new adminstring[128];
if(IsPlayerConnected(playerid))
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pLevel] > 0)
{
format(adminstring, sizeof(adminstring),"%s%s[ID:%d]\n", adminstring, PlayerName(i), i);
}
}
}
ShowPlayerDialog(playerid,DIALOG_ONLINEADMINS,DIALOG_STYLE_MSGBOX,"Online admins",adminstring,"Close","");
}
else return SendClientMessage(playerid,-1," No admins online");
return 1;
}
Re: admins online command -
Sawalha - 08.01.2014
removed, sorry forget that you need it in a dialog
Re: admins online command -
rocker3410 - 08.01.2014
It says unknown command
Re: admins online command -
ReD_HunTeR - 08.01.2014
what?
Re: admins online command -
CutX - 08.01.2014
Quote:
Originally Posted by rocker3410
It says unknown command
|
forcing an output of something which is actually nothing,
(something like you're creating a string which is 6 long and trying to output the char at 8, which is not possible since there's nothing after the null char at 5 (counting from '0'))
can cause a "SERVER: unknown command".
use this, it's in YCMD which I'd recommend you to use.
PHP код:
#define SOME_DIALOG 1112
YCMD:admins(playerid,params[],help)
{
if(help) SendClientMessage(playerid,-1,"/admins is used to show which admins are currently online.");
new pn[MAX_PLAYER_NAME+2],s[50];//size of 's' depends on the number of admins you have and their name-lenght
//we'll be using the pn string for the playername as temporary string (+2 cuz of '\n')
for(new i=0; i<=GetMaxPlayers(),IsPlayerAdmin(i); i++)
format(pn,sizeof pn,"%s\n",GetName(i)),
strcat(s,pn);
if(s[0] == EOS) return SendClientMessage(playerid,-1,"There are no admins online at the moment.");
ShowPlayerDialog(playerid,SOME_DIALOG,DIALOG_STYLE_MSGBOX,"Admins online",s,"Ok","");
return 1;
}
stock GetName(playerid)
{
new n[MAX_PLAYER_NAME];
GetPlayerName(playerid, n, MAX_PLAYER_NAME);
return n;
}
im checking for rcon admins since i don't know how you define admins in your script of course.
You just have to change the 2nd condition