SA-MP Forums Archive
[Help] /admins problem - 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: [Help] /admins problem (/showthread.php?tid=365041)



[Help] /admins problem - mickos - 01.08.2012

Hey guys,


I have a little, problem

when players type ingame /admins, it will be show the online admins
But when there no admins online and a player do /admins they wont see anything
I've tried alot to make a SendClientMessage or anything that says: Sorry, there are no online admins at the moment.
But it gave errors and warnings.
Thats the reason that I deleted it.

this is the script:

PHP код:
if(strcmp(cmd"/admins"true) == 0)
        {
        new 
str[128];
        for(new 
0MAX_PLAYERSi++)
                {
                if(
Stats[i][AdminLvl] > && IsPlayerConnected(i))
                    {
                    new 
name[90];
                    
GetPlayerName(i,name,sizeof(name));
                    
format(str,sizeof(str),"%s(id:%d) [Level: %d] is Online.",name,i);
                    
SendClientMessage(i,COLOR_BLUE,str);
                    }
                }
        return 
1;
        } 
And when I was tryig to make a dialog it failed to hard

I mean if a player type /admins I was try to show this:

2 - DIALOG_STYLE_LIST



But not with that text in there, but the online admins need he to show


Re: [Help] /admins problem - Kindred - 01.08.2012

First off, stop spacing out your code like that, it looks like complete shit and anyone who wants to help you will be appalled by this.

Second, why were you sending the message to the admins? If you did /admins, it would send the message to the admins that are online.

Fixed:

pawn Код:
if(strcmp(cmd, "/admins", true) == 0)
{
    new str[128], playeramount = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Stats[i][AdminLvl] > 0 && IsPlayerConnected(i))
        {
            new name[90];
            GetPlayerName(i,name,sizeof(name));
            format(str,sizeof(str),"%s(id:%d) [Level: %d] is Online.",name,i);
            SendClientMessage(playerid,COLOR_BLUE,str);
            playeramount ++;
        }
        if(playeramount == 0) return SendClientMessage(playerid,COLOR_BLUE,"No admins are on!");
    }
    return 1;
}



Re: [Help] /admins problem - mickos - 01.08.2012

And this is the one that I tried to make:

If a player type /admins he will show a dialog with the online administrators but it didnt work

here's the code:

PHP код:
if(strcmp(cmd"/admins"true) == 0)
        {
        new 
str[128];
        for(new 
0MAX_PLAYERSi++)
               {
               if(
Stats[i][AdminLvl] > && IsPlayerConnected(i))
                   {
                   new 
name[90];
                   
GetPlayerName(i,name,sizeof(name));
                   
format(str,sizeof(str),"%s(id:%d) is Online.",name,i);
                   
ShowPlayerDialog(playerid1DIALOG_STYLE_MSGBOX"{FFFFFF}Online Admins"BigString15"Close","");
                   }
               }
               return 
1;
   } 



Re: [Help] /admins problem - Kindred - 01.08.2012

Try this.

pawn Код:
if(strcmp(cmd, "/admins", true) == 0)
{
    new str[128], string[128], playeramount = 0; //Increase str to a suitable number
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Stats[i][AdminLvl] > 0 && IsPlayerConnected(i))
        {
            new name[90];
            GetPlayerName(i,name,sizeof(name));
            format(string,sizeof(str),"\n%s(id:%d) [Level: %d] is Online.",name,i);
            strcat(str, string);
            playeramount ++;
        }
        if(playeramount == 0) return SendClientMessage(playerid,COLOR_BLUE,"No admins are on!");
        ShowPlayerDialog(playerid, dialogidhere, DIALOG_STYLE_LIST, str, "Close", ""); //Shows dialog with admins, one button "Close"
    }
    return 1;
}
And seriously, search, I could probably find out a way to do this easily.

((Untested, might not work, this just came to mind))


Re: [Help] /admins problem - mickos - 01.08.2012

Thank you it works fine +repped