/admins command
#1

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);
Reply
#2

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

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

Help please?
Reply
#5

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

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

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[]);
Reply
#8

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

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

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

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

A little bump, it does not show admins.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)