SA-MP Forums Archive
How to create admin levels - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to create admin levels (/showthread.php?tid=273643)



How to create admin levels - nilanjay - 02.08.2011

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


Re: How to create admin levels - Calgon - 02.08.2011

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?


Re: How to create admin levels - nilanjay - 02.08.2011

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


Re: How to create admin levels - Shockey HD - 02.08.2011

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.


Re: How to create admin levels - nilanjay - 02.08.2011

Thanks for helping i will try this.


Re: How to create admin levels - Calgon - 02.08.2011

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.


Re: How to create admin levels - nilanjay - 02.08.2011

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


Re: How to create admin levels - Shockey HD - 02.08.2011

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"


Re: How to create admin levels - nilanjay - 02.08.2011

Is this a right enum?
Quote:

enum gPInfo
{
Logged,
Regged,
pAdminLevel
};




Re: How to create admin levels - nilanjay - 02.08.2011

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;
}




Re: How to create admin levels - Calgon - 02.08.2011

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.


Re: How to create admin levels - Tigerkiller - 02.08.2011

yes but dont forgot to load/save accountsM


Re: How to create admin levels - Shockey HD - 02.08.2011

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?


Re: How to create admin levels - Tigerkiller - 02.08.2011

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


Re: How to create admin levels - nilanjay - 02.08.2011

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


Re: How to create admin levels - Tigerkiller - 02.08.2011

no im surfing with the mobile phone so iam sorry


Re: How to create admin levels - nilanjay - 02.08.2011

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];




Re: How to create admin levels - Tigerkiller - 02.08.2011

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