SA-MP Forums Archive
Is Player Admin? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Is Player Admin? (/showthread.php?tid=251908)



Is Player Admin? - Slash01 - 29.04.2011

Hello there!

i need a quick scripting help for one command

i want to make an /admins command, to let people know what admins are online.

how do i do this?

please let me know if you you need to see my script, or a part of it

thanks!


Re: Is Player Admin? - Ironboy500[TW] - 29.04.2011

Код:
SendClientMessage(playerid, COLOR, "Online Admins!");
for (new i; i < GetMaxPlayers(); i++)
{
     if(IsPlayerAdmin(i) && IsPlayerConnected(i))
     {
           new playername[24];
           new string[40];
           GetPlayerName(i, playername, 24);
           format(string, sizeof(string), "Admin %s (id:%d)", playername, i)
           SendClientMessage(playerid, COLOR, string);
     }
}
Untested, should work. Next time, search!


Re: Is Player Admin? - Sascha - 29.04.2011

there are 2 ways....
either: check for rcon admins:
pawn Код:
if(strcmp("/admins", cmdtext, true, 7) == 0)
{
  new pname[MAX_PLAYER_NAME], string[50];
  for(new i=0; i<GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
    {
      if(IsPlayerAdmin(i))
      {
        GetPlayerName(i, pname, sizeof(pname));
        format(string, sizeof(string), "*%s", name);
        SendClientMessage(playerid, COLOR, string);
      }
    }
  }
  return 1;
}
or check for admins of your admin script..
(therefore I can only give you a little example as I don't know your level definitions, etc...)
pawn Код:
if(strcmp("/admins", cmdtext, true, 7) == 0)
{
  new pname[MAX_PLAYER_NAME], string[50];
  for(new i=0; i<GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
    {
      if(PlayerInfo[i][Level] >= 1)   //you may need to edit this...
      {
        GetPlayerName(i, pname, sizeof(pname));
        format(string, sizeof(string), "*%s", name);
        SendClientMessage(playerid, COLOR, string);
      }
    }
  }
  return 1;
}
edit: hm someone before


Re: Is Player Admin? - Slash01 - 29.04.2011

thanks so much! i did, but i didnt want to steal from other scripts....


Re: Is Player Admin? - Sascha - 29.04.2011

hehe...
if you copy something from another script, but don't claim it as your own and just use it as examples to learn from, this wouldn't be considered as stealing :=)


Re: Is Player Admin? - Slash01 - 29.04.2011

i see, however, i have tried to compile with peoples suggestions, and it occured to me, i use DCMD and DINI, so all my commands are CMD: report etc.... i just cand figure this one out :L

ill copy my report command and see if you can help? thanks so much in advance!


CMD:report(playerid, params[])
{
new str[50];
if(sscanf(params, "s[50]", str)== 0) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [text]");
SendClientMessage(playerid, COLOR_YELLOW, "Your report has been sent to any online admins.");
for(new i=0; i<MAX_PLAYERS; i++)
{
if(GetAdminLevel(i)>= 1 || IsPlayerAdmin(i))
{
format(str, sizeof(str), "[REPORT] %s: %s", GetPName(playerid), params);
SendClientMessage(i, COLOR_REPORT, str);
}
}
return 1;
}

PS: if you think this is abit advance, i had a friend help/script this for me lol


Re: Is Player Admin? - leong124 - 29.04.2011

sscanf will return 1(or -1?) if the format is not correct.
Also, you don't need to use sscanf as well.
Seems you are using ZCMD(not DCMD ), you can use insull like this:
pawn Код:
CMD:report(playerid, params[])
{
    new string[128];//Since max I/O is 128, you must use 128.
    if(!isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [text]");
    SendClientMessage(playerid, COLOR_YELLOW, "Your report has been sent to any online admins.");
    format(str, sizeof(str), "[REPORT] %s: %s", GetPName(playerid), params);//Put it here to reduce repeated processing
    for(new i=0; i<MAX_PLAYERS; i++)
        if(GetAdminLevel(i)>= 1 || IsPlayerAdmin(i)) SendClientMessage(i, COLOR_REPORT, str);
    return 1;
}



Re: Is Player Admin? - Slash01 - 29.04.2011

uhh the report command was an example, n yeah sorry zcmd XD

i need an /admins command lol, that was just an example!


Re: Is Player Admin? - Vince - 29.04.2011

pawn Код:
if(sscanf(params, "s[50]", str)== 0) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [text]");
Just remove the == 0 in that line. sscanf returns 0 on success, and 1 on fail.


Re: Is Player Admin? - Slash01 - 29.04.2011

-.- i want to make a command which when you type /admins, it shows you which admins are online, the /report command was an example! it works lol

thanks

any suggestions?