SA-MP Forums Archive
/admins 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 command (/showthread.php?tid=347930)



/admins command - Firo - 03.06.2012

Hey, i'm working on admin mode, And i'm just done with the register login thing, now i'm willing to do a /admins command.

pawn Code:
CMD:admins( playerid,params[])
    {
        if ( GetPVarInt( playerid, "Logged" ) == 1 )
        return SendClientMessage( playerid, -1, ""COL_RED"ERROR:{FFFFFF} You have to login to see the admins list.");

        new count=0;
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(GetPVarInt(i) >= 1 && GetPVarInt(i) < 3)
                {
                    new str[128];
                    GetName(i, pName, 24);
                    format(str, sizeof(str), "%s [ID:%d] Level:[%d]",GetName(i),i,GetPVarInt(i));
                    count++;
                    ShowPlayerDialog(playerid,2,DIALOG_STYLE_MSGBOX,"Online admins:",str,"Close"," ");

                }
            }
        }
        if(count == 0)
        {
            ShowPlayerDialog(playerid,2,DIALOG_STYLE_MSGBOX,"Online admins:","There's no admins online right now.","Close"," ");
        }
        return 1;
    }
First time i'm using zCMD.

Warnings :
pawn Code:
pawno\include\YSI\internal\y_dohooks.inc(2501) : warning 235: public function lacks forward declaration (symbol "OnVehicleDamageStatusUpdate")
pawno\include\YSI\internal\y_dohooks.inc(2566) : warning 235: public function lacks forward declaration (symbol "OnUnoccupiedVehicleUpdate")
pawno\include\YSI\internal\y_dohooks.inc(3426) : warning 235: public function lacks forward declaration (symbol "OnPlayerTakeDamage")
pawno\include\YSI\internal\y_dohooks.inc(3495) : warning 235: public function lacks forward declaration (symbol "OnPlayerGiveDamage")
(473) : warning 202: number of arguments does not match definition
(473) : warning 202: number of arguments does not match definition
(476) : error 076: syntax error in the expression, or invalid function call
pawn Code:
473 : if(GetPVarInt(i) >= 1 && GetPVarInt(i) < 3) // This one checking if player level 1-3 means admin.
476 : GetName(i, pName, 24);



Re: /admins command - TheDominator - 03.06.2012

It would be helpful if you could show us which lines are 473 and 476. As for the first 4 errors they seem to occur in the SA-MP 0.3e server package update and not script related.


Re: /admins command - Firo - 03.06.2012

Quote:
Originally Posted by TheDominator
View Post
It would be helpful if you could show us which lines are 473 and 476. As for the first 4 errors they seem to occur in the SA-MP 0.3e server package update and not script related.
Hey mate, i posted the lines above... Down of the warnings.


Re: /admins command - Firo - 03.06.2012

Help please?


Re: /admins command - Amit_B - 04.06.2012

Hey

To fix these error you need to remove or comment line 476. Its unnecessary because your'e using it below this line.
The warnings comes from the part when you've checked, I guess, the admin level of the players?

GetPlayerPVar() requires 2 parameters as I believe you know, which one of them is the ID of the player and the second is the variable name. At the line with both of the warnings you've used this function twice without adding a variable name. What you need to do is to add the variable name as second parameter.


Re: /admins command - Firo - 04.06.2012

Quote:
Originally Posted by Amit_B
View Post
Hey

To fix these error you need to remove or comment line 476. Its unnecessary because your'e using it below this line.
The warnings comes from the part when you've checked, I guess, the admin level of the players?

GetPlayerPVar() requires 2 parameters as I believe you know, which one of them is the ID of the player and the second is the variable name. At the line with both of the warnings you've used this function twice without adding a variable name. What you need to do is to add the variable name as second parameter.
Thanks for your comment, anyway I already removed line 476 and i did GetPlayerPVar function
pawn Code:
error 017: undefined symbol "varname"
This is the GetPlayerPVar that requires 2 parameters
pawn Code:
GetPVarInt(playerid, varname[]);
pawn Code:
CMD:admins( playerid,params[])
    {
        if ( GetPVarInt( playerid, "Logged" ) == 1 )
        return SendClientMessage( playerid, -1, ""COL_RED"ERROR:{FFFFFF} You have to login to see the admins list.");

        new count=0;
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(GetPVarInt(i) >= 1 && GetPVarInt(i) < 3)
                {
                    new str[128];
                    GetPVarInt(playerid, varname[]);
//                  GetName(i, pName, 24);
                    format(str, sizeof(str), "%s [ID:%d] Level:[%d]",GetName(i),i,GetPVarInt(i));
                    count++;
                    ShowPlayerDialog(playerid,2,DIALOG_STYLE_MSGBOX,"Online admins:",str,"Close"," ");

                }
            }
        }
        if(count == 0)
        {
            ShowPlayerDialog(playerid,2,DIALOG_STYLE_MSGBOX,"Online admins:","There's no admins online right now.","Close"," ");
        }
        return 1;
    }
Toda.


Re: /admins command - 3ventic - 04.06.2012

No... replace
Code:
if(GetPVarInt(i) >= 1 && GetPVarInt(i) < 3)
with
Code:
if(GetPVarInt(i, variable-for-admin-level) >= 1 && GetPVarInt(i, variable-for-admin-level) < 3)
and remove
Code:
GetPVarInt(playerid, varname[]);



Re: /admins command - Amit_B - 04.06.2012

You have to script with the right syntax if you want the code to 'work'. Errors and warnings are the last things to stop scripter from creating a script.

pawn Code:
CMD:admins( playerid,params[])
    {
        if ( GetPVarInt( playerid, "Logged" ) == 1 )
        return SendClientMessage( playerid, -1, ""COL_RED"ERROR:{FFFFFF} You have to login to see the admins list.");

        new count=0;
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(GetPVarInt(i,"Admin") >= 1 && GetPVarInt(i,"Admin") < 3)
                {
                    new str[128];
//                  GetPVarInt(playerid, varname[]);
//                  GetName(i, pName, 24);
                    format(str, sizeof(str), "%s [ID:%d] Level:[%d]",GetName(i),i,GetPVarInt(i,"Admin"));
                    count++;
                    ShowPlayerDialog(playerid,2,DIALOG_STYLE_MSGBOX,"Online admins:",str,"Close"," ");

                }
            }
        }
        if(count == 0)
        {
            ShowPlayerDialog(playerid,2,DIALOG_STYLE_MSGBOX,"Online admins:","There's no admins online right now.","Close"," ");
        }
        return 1;
    }
As you can see i've added as a second parameter the string "Admin" which I guess is the name of the admin level variable. It's not sure to work! the variable name has to be the name of the admin level in the admin mode you're using. I don't know what admin mode it is or what is the name of the variable so it looks you'll just have to figure it yourself.

No problem Ofiro!


Re: /admins command - Firo - 04.06.2012

Thanks for help, but it doesn't show me on /admins that i'm the Online admin at the server.


Re: /admins command - 3ventic - 04.06.2012

You need to find out what variable is used to store admin level and replace "Admin" with it.


Re: /admins command - Firo - 04.06.2012

Quote:
Originally Posted by 3ventic
View Post
You need to find out what variable is used to store admin level and replace "Admin" with it.
I already know what's the variable and i changed it, Its 'Level' , Level0 = Member, Level1 = Moderator, blabla..


Re: /admins command - Firo - 05.06.2012

A little bump, it does not show admins.