Is Player Admin?
#1

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!
Reply
#2

Код:
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!
Reply
#3

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
Reply
#4

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

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 :=)
Reply
#6

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
Reply
#7

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;
}
Reply
#8

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

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

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.
Reply
#10

-.- 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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)