[Solved] Need help with my little command
#1

Hey,
I tried scripting command which would show online admins.. but I failed..
Here is the code:
pawn Код:
if(strcmp(cmdtext,"/admins",true)==0)
    {
      new AnyAdmins = 0;
    for(new i; i<MAX_PLAYERS; i++)
    {
      new anames[24], string[256];
      if (dUserINT(PlayerName(i)).("Adminlvl")>=1)
      {
        AnyAdmins = 1;
        GetPlayerName(i,anames,24);
            }
            if (AnyAdmins == 1)
            {
              SystemMsg(playerid,"Admins Online:");
              format(string,256,"%s ",anames);
              SystemMsg(playerid,string);
            }
            else
            {
                SystemMsg(playerid,"No Admins Online");
            }
        }
        return 1;
    }
It sends many messages to playerid... Any help?
Reply
#2

Quote:
Originally Posted by Justas [SiJ
]
Hey,
I tried scripting command which would show online admins.. but I failed..
Here is the code:
pawn Код:
if(strcmp(cmdtext,"/admins",true)==0)
    {
      new AnyAdmins = 0;
    for(new i; i<MAX_PLAYERS; i++)
    {
      new anames[24], string[256];
      if (dUserINT(PlayerName(i)).("Adminlvl")>=1)
      {
        AnyAdmins = 1;
        GetPlayerName(i,anames,24);
            }
            if (AnyAdmins == 1)
            {
              SystemMsg(playerid,"Admins Online:");
              format(string,256,"%s ",anames);
              SystemMsg(playerid,string);
            }
            else
            {
                SystemMsg(playerid,"No Admins Online");
            }
        }
        return 1;
    }
It sends many messages to playerid... Any help?
Edit nvm, i fail lol.
Reply
#3

pawn Код:
dcmd_admins(playerid,params[])
{
#pragma unused params
new Count[2], i, string[128];
for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
{
if(dUserINT(PlayerName(i)).("Adminlvl") == 0) Count[0]++;
}

if( (Count[0] == 0 && Count[1] == 0) || (Count[0] == 0 && Count[1] >= 1 && dUserINT(PlayerName(i)).("Adminlvl") == 0) ) return SendClientMessage(playerid, COLOR_BLUE, "Admins Online: None");

if(Count[0] == 1)
{
for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && dUserINT(PlayerName(i)).("Adminlvl") > 0)
{
format(string, sizeof(string), "Admins Online: %s (%d)",PlayerName2(i), PlayerData[i][Adminlvl] ); SendClientMessage(playerid, COLOR_BLUE, string);
}
}

if(Count[0] > 1)
{
new x; format(string, sizeof(string), "Admins Online: ");
for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && dUserINT(PlayerName(i)).("Adminlvl") > 0)
{
format(string,sizeof(string),"%s%s (%d)",string,PlayerName2(i),PlayerData[i][Adminlvl]);
x++;
if(x >= 5)
{
SendClientMessage(playerid, COLOR_BLUE, string); format(string, sizeof(string), "Admins Online: "); x = 0;
}
else format(string, sizeof(string), "%s, ", string);
}
if(x <= 4 && x > 0)
{
string[strlen(string)-3] = '.';
SendClientMessage(playerid, COLOR_BLUE, string);
}
}
return 1;
}
Reply
#4

OTThe first ~10 lines are total useless!, of your code coop)
Reply
#5

Quote:
Originally Posted by ♣ ⓐⓢⓢ
OTThe first ~10 lines are total useless!, of your code coop)
But the rest works?
Reply
#6

Yes, it should but I dont understand why you did
pawn Код:
string[strlen(string)-3] = '.';
shouldnt it be 2 ?
Reply
#7

Quote:
Originally Posted by ♣ ⓐⓢⓢ
shouldnt it be 2 ?
It's possilble that I've failed again. I have almost failed about 5 times today. Or maybe more.
Reply
#8

Thanks for replies,
coop>
pawn Код:
dcmd_admins(playerid,params[])
{
#pragma unused params
new Count[2], i, string[128];
for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
{
if(dUserINT(PlayerName(i)).("Adminlvl") == 0) Count[0]++;
}

if( (Count[0] == 0 && Count[1] == 0) || (Count[0] == 0 && Count[1] >= 1 && dUserINT(PlayerName(i)).("Adminlvl") == 0) ) return SendClientMessage(playerid, COLOR_BLUE, "Admins Online: None");

if(Count[0] == 1)
{
for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && dUserINT(PlayerName(i)).("Adminlvl") > 0)
{
format(string, sizeof(string), "Admins Online: %s (%d)",PlayerName2(i), PlayerData[i][Adminlvl] ); SendClientMessage(playerid, COLOR_BLUE, string);
}
}

if(Count[0] > 1)
{
new x; format(string, sizeof(string), "Admins Online: ");
for(i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && dUserINT(PlayerName(i)).("Adminlvl") > 0)
{
format(string,sizeof(string),"%s%s (%d)",string,PlayerName2(i),PlayerData[i][Adminlvl]);
x++;
if(x >= 5)
{
SendClientMessage(playerid, COLOR_BLUE, string); format(string, sizeof(string), "Admins Online: "); x = 0;
}
else format(string, sizeof(string), "%s, ", string);
}
if(x <= 4 && x > 0)
{
string[strlen(string)-3] = '.';
SendClientMessage(playerid, COLOR_BLUE, string);
}
}
return 1;
}
Why did you used PlayerName2(i) here:
pawn Код:
format(string,sizeof(string),"%s%s (%d)",string,PlayerName2(i),PlayerData[i][Adminlvl]);
?
Shouldn't it be PlayerName ?
Cause I only have stock PlayerName(playerid)

And...
Quote:

error 017: undefined symbol "PlayerData"

Did you copied this from GF ?
Reply
#9

Yea (I didn't say yea to that I have copied this from God Father, because I didn't... It's from my Admin script...), just change the PlayerName2 to PlayerName. I think that it would work.
Reply
#10

And...
Quote:

error 017: undefined symbol "PlayerData"

Did you copied this from GF ?
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)