How to create admin levels
#1

I am making an admin script but i don't know how to make admin lvls correcttly so please tell me.
Reply
#2

Admin levels are only an integer that are saved with player accounts and loaded with player accounts. What part do you not understand about creating correctly?
Reply
#3

I mean how can i make a coomand which can be only use by a lvl 3 admin or higher.
Reply
#4

Quote:
Originally Posted by nilanjay
View Post
I am making an admin script but i don't know how to make admin lvls correcttly so please tell me.
Well to start it off, do you have a Login and register system?

The base of making the Admin Levels is actually in the command, /Setadmin,/Makeadmin, /Setlevel.

I don't have much information about your script yet so i will show you a Makeadmin command.

pawn Code:
CMD:setadmin(playerid, params[])
{
    new victimname[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], admlvl, id;
    if(IsPlayerAdmin(playerid))
    {
        if (sscanf(params, "ui", id, admlvl)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setadmin [id] [adminlevel]");
        if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "System: Invalid ID");
        if (admlvl > 10 || admlvl < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid Admin Levels: 1-10!");
        PlayerInfo[id][pAdminLevel] = admlvl;
        GetPlayerName(id, victimname, sizeof(victimname));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        new str[128];
        format(str,128,"System: %s [ID %d] has set %s [ID %d] admin level to %i",adminname, playerid, victimname, id, admlvl);
        SendClientMessage(playerid,COLOR_GREEN,str);
        return 1;
    }
    else return SendClientMessage(playerid,COLOR_RED,"  You are not allowed to use this command!");
}
Make sure you have you pAdminLevel in Enums

Then the base of your code would be

pawn Code:
if(PlayerInfo[playerid][pAdminLevel] >=1)
So for an example.

pawn Code:
CMD:jetpack(playerid,params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >=3)
    {
        SetPlayerSpecialAction(playerid, 2);
        SendClientMessage(playerid,COLOR_GREEN, "|__Jetpack Spawned__|");
        return 1;
        }
        else return SendClientMessage(playerid, COLOR_RED, " You are not allowed to use this command");
    }
Only Admin's can use Jetpack command.
Reply
#5

Thanks for helping i will try this.
Reply
#6

With zcmd:

pawn Code:
CMD:admincommand(playerid, params[]) {
   if(/* your admin level variable */ >= 3) {
      SendClientMessage(playerid, 0, "You can use this command, you're a level 3+ admin, but it does nothing other than send this message.");
   }
   return 1;
}
You need to replace '/* your admin level variable */' with the variable you created for admin levels.
Reply
#7

Can you give me a more good example of these codes beacuse i use zcmd plugin.
Reply
#8

Quote:
Originally Posted by Calg00ne
View Post
With zcmd:

pawn Code:
CMD:admincommand(playerid, params[]) {
   if(/* your admin level variable */ >= 3) {
      SendClientMessage(playerid, 0, "You can use this command, you're a level 3+ admin, but it does nothing other than send this message.");
   }
   return 1;
}
You need to replace '/* your admin level variable */' with the variable you created for admin levels.
My example was ZCMD.

Okay.

I will give you an example.


pawn Code:
if(PlayerInfo[playerid][pAdminLevel] >=1)
Do you see that? What that does it says, If the person who is trying to activate the command inst a admin level 1- what ever. He cannot use the command.

So, Annother command.

pawn Code:
CMD:flip(playerid,params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >=1)
    {
        if (IsPlayerInAnyVehicle(playerid))
            {
                new VehicleID, Float:X, Float:Y, Float:Z;
                GetPlayerPos(playerid, X, Y, Z);
                VehicleID = GetPlayerVehicleID(playerid);
                SetVehiclePos(VehicleID, X, Y, Z);
                SetVehicleZAngle(VehicleID, 0);
                return 1;
            }
                else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not in any vehicle");
         }
            else return SendClientMessage(playerid, COLOR_RED, " You are not allowed to use this command");
    }
This command says if the player isnt a admin, he cannot use the flip command and he will be sent a message saying "You are not allowed to use this command"
Reply
#9

Is this a right enum?
Quote:

enum gPInfo
{
Logged,
Regged,
pAdminLevel
};

Reply
#10

Yes i add that pAdminLevel.But i still have errors see:
Quote:

C:\Users\PART\Desktop\samp03csvr_R2-2_win32\filterscripts\ad_killerking.pwn(95) : error 017: undefined symbol "PInfo"
C:\Users\PART\Desktop\samp03csvr_R2-2_win32\filterscripts\ad_killerking.pwn(95) : warning 215: expression has no effect
C:\Users\PART\Desktop\samp03csvr_R2-2_win32\filterscripts\ad_killerking.pwn(95) : error 001: expected token: ";", but found "]"
C:\Users\PART\Desktop\samp03csvr_R2-2_win32\filterscripts\ad_killerking.pwn(95) : error 029: invalid expression, assumed zero
C:\Users\PART\Desktop\samp03csvr_R2-2_win32\filterscripts\ad_killerking.pwn(95) : fatal error 107: too many error messages on one line

That line is:
Quote:

public OnPlayerConnect(playerid)
{
PInfo[playerid][Logged] = 0;
PInfo[playerid][Regged] = 0;.
PInfo[playerid][Level] = 0;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"MyAdmin/Users/%s.txt",name);
if(dini_Exists(file))
{
SendClientMessage(playerid,LIGHTBLUE,"You are registered, Please /login!");
PInfo[playerid][Regged] = 1;
PInfo[playerid][Logged] = 0;
return 1;
}
if(!dini_Exists(file))
{
SendClientMessage(playerid,LIGHTBLUE,"You are not registered, Please /register!");
PInfo[playerid][Regged] = 0;
PInfo[playerid][Logged] = 0;
return 1;
}
return 1;

return 1;
}

Reply
#11

Quote:
Originally Posted by Shockey HD
View Post
My example was ZCMD.

Okay.

I will give you an example.
Yes, I know, read my edit quote - I didn't see your message while I was writing mine.
Reply
#12

yes but dont forgot to load/save accountsM
Reply
#13

Quote:
Originally Posted by nilanjay
Посмотреть сообщение
Yes i add that pAdminLevel.But i still have errors see:


That line is:
Why do you return, return 1 three times?
Reply
#14

and do new Pinfo[MAX_PLAYERS][gPinfo];
on the top
Reply
#15

Hmm iwas confused here. Can you show me how it should look like?
Reply
#16

no im surfing with the mobile phone so iam sorry
Reply
#17

I got new errors see:

Quote:

C:\Users\PART\Desktop\samp03csvr_R2-2_win32\filterscripts\ad_killerking.pwn(31) : warning 201: redefinition of constant/macro (symbol "MAX_PLAYER_NAME")
C:\Users\PART\Desktop\samp03csvr_R2-2_win32\filterscripts\ad_killerking.pwn(101) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\PART\Desktop\samp03csvr_R2-2_win32\filterscripts\ad_killerking.pwn(101) : error 029: invalid expression, assumed zero
C:\Users\PART\Desktop\samp03csvr_R2-2_win32\filterscripts\ad_killerking.pwn(101) : error 017: undefined symbol "file"
C:\Users\PART\Desktop\samp03csvr_R2-2_win32\filterscripts\ad_killerking.pwn(101) : fatal error 107: too many error messages on one line

The line is:
Quote:

new name[MAX_PLAYER_NAME], file[256];

Reply
#18

this line is correct. post 3 lines for an 3 lines after this
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)