[Help] Permission System
#1

Hello everyone and good morning. I hope it is bright and sunny where you are! I need some help from you all though. I have ******d Admin systems and permission systems for SAMP. While I found a lot of them none of them are simple enough for me. What I mean is I do not want 50+ features. I just want my commands to be controlled. I want to be able to control what players get what commands. Nothing more nothing less.

Here is what one of my commands look like. This happens to be a command for spawning weapon set 2;

Код:
CMD:set2(playerid, params[])
{
    GivePlayerWeapon(playerid, 1, 1);
    GivePlayerWeapon(playerid, 4, 1);
    GivePlayerWeapon(playerid, 12, 1);
    GivePlayerWeapon(playerid, 16, 10);
    GivePlayerWeapon(playerid, 23, 150);
    GivePlayerWeapon(playerid, 26, 125);
    GivePlayerWeapon(playerid, 32, 200);
    GivePlayerWeapon(playerid, 31, 200);
    GivePlayerWeapon(playerid, 33, 175);
    GivePlayerWeapon(playerid, 37, 1500);
    SendClientMessage(playerid, COLOR_YELLOW, "You've been granted weapon set 2!");
    return 1;
}
With commands like these what would I need to do in order to add a permission like system to all my commands? Again all I am looking for is something that checks to see if the user is a 0, 1, 2, or 3.

0 = User
1 = Trusted User
2 = Admin
3 = Owner

Any and all help is appreciated. I always +Rep those who earn it! Thanks for reading guys and gals, and make sure to have a wonderful day!!

-
0Z3ro0
Reply
#2

This might help you : https://sampwiki.blast.hk/wiki/IsPlayerAdmin . It means that if the player has logged in as a rcon admin the command will work. But for more levels you might need to use an enum and I think it will get more complicated then you want.
pawn Код:
CMD:set2(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))  return SendClientMessage(playerid, 0xDEEE20FF, "You dont have permission for this command!");
    GivePlayerWeapon(playerid, 1, 1);
    GivePlayerWeapon(playerid, 4, 1);
    GivePlayerWeapon(playerid, 12, 1);
    GivePlayerWeapon(playerid, 16, 10);
    GivePlayerWeapon(playerid, 23, 150);
    GivePlayerWeapon(playerid, 26, 125);
    GivePlayerWeapon(playerid, 32, 200);
    GivePlayerWeapon(playerid, 31, 200);
    GivePlayerWeapon(playerid, 33, 175);
    GivePlayerWeapon(playerid, 37, 1500);
    SendClientMessage(playerid, COLOR_YELLOW, "You've been granted weapon set 2!");
    return 1;
}
Reply
#3

Find some tutorials about Y-INI or any INI files writer/reader
I suggest you use this tutorial for registering and then i can give you a code for it...
Reply
#4

Quote:
Originally Posted by rappy93
Посмотреть сообщение
This might help you : https://sampwiki.blast.hk/wiki/IsPlayerAdmin . It means that if the player has logged in as a rcon admin the command will work. But for more levels you might need to use an enum and I think it will get more complicated then you want.
pawn Код:
CMD:set2(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))  return SendClientMessage(playerid, 0xDEEE20FF, "You dont have permission for this command!");
    GivePlayerWeapon(playerid, 1, 1);
    GivePlayerWeapon(playerid, 4, 1);
    GivePlayerWeapon(playerid, 12, 1);
    GivePlayerWeapon(playerid, 16, 10);
    GivePlayerWeapon(playerid, 23, 150);
    GivePlayerWeapon(playerid, 26, 125);
    GivePlayerWeapon(playerid, 32, 200);
    GivePlayerWeapon(playerid, 31, 200);
    GivePlayerWeapon(playerid, 33, 175);
    GivePlayerWeapon(playerid, 37, 1500);
    SendClientMessage(playerid, COLOR_YELLOW, "You've been granted weapon set 2!");
    return 1;
}
Sorry when I meant not complicated I wasn't referring to how in depth the code went I was referring to all the features it would offer. I only want an admin system that restricts commands based on those 4 classes. Thank you for your insight! I will be using your method to eliminate one of my groups (Owner). However I am still looking for something that can support those other levels.
Reply
#5

Quote:
Originally Posted by FailerZ
Посмотреть сообщение
Find some tutorials about Y-INI or any INI files writer/reader
I suggest you use this tutorial for registering and then i can give you a code for it...
Is this just a login and register system? If so I will make sure to add it. With that being said what code would you teach me based on me having the FS you mentioned.
Reply
#6

Please show your "enum pInfo" or "enum PlayerInfo" to us,

so we we're able to help you

Here is my example:

For RCON,
pawn Код:
CMD:set2(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You must be an RCON Admin to use this Command.");
    GivePlayerWeapon(playerid, 1, 1);
    GivePlayerWeapon(playerid, 4, 1);
    GivePlayerWeapon(playerid, 12, 1);
    GivePlayerWeapon(playerid, 16, 10);
    GivePlayerWeapon(playerid, 23, 150);
    GivePlayerWeapon(playerid, 26, 125);
    GivePlayerWeapon(playerid, 32, 200);
    GivePlayerWeapon(playerid, 31, 200);
    GivePlayerWeapon(playerid, 33, 175);
    GivePlayerWeapon(playerid, 37, 1500);
    SendClientMessage(playerid, COLOR_YELLOW, "You've been granted weapon set 2!");
    return 1;
}
For Admins (using my Admin Level Function),
pawn Код:
CMD:set2(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 1)
    {
        GivePlayerWeapon(playerid, 1, 1);
        GivePlayerWeapon(playerid, 4, 1);
        GivePlayerWeapon(playerid, 12, 1);
        GivePlayerWeapon(playerid, 16, 10);
        GivePlayerWeapon(playerid, 23, 150);
        GivePlayerWeapon(playerid, 26, 125);
        GivePlayerWeapon(playerid, 32, 200);
        GivePlayerWeapon(playerid, 31, 200);
        GivePlayerWeapon(playerid, 33, 175);
        GivePlayerWeapon(playerid, 37, 1500);
        SendClientMessage(playerid, COLOR_YELLOW, "You've been granted weapon set 2!");
    }
    else return SendClientMessage(playerid, -1, "{FF0000}<!> {EEEEEE}You need to be atleast Admin Level 1 to use this Command.");
    return 1;
}
For VIPs (Using my VIP Level Function),
pawn Код:
CMD:set2(playerid, params[])
{
    if(PlayerInfo[playerid][VipLevel] >= 1)
    {
        GivePlayerWeapon(playerid, 1, 1);
        GivePlayerWeapon(playerid, 4, 1);
        GivePlayerWeapon(playerid, 12, 1);
        GivePlayerWeapon(playerid, 16, 10);
        GivePlayerWeapon(playerid, 23, 150);
        GivePlayerWeapon(playerid, 26, 125);
        GivePlayerWeapon(playerid, 32, 200);
        GivePlayerWeapon(playerid, 31, 200);
        GivePlayerWeapon(playerid, 33, 175);
        GivePlayerWeapon(playerid, 37, 1500);
        SendClientMessage(playerid, COLOR_YELLOW, "You've been granted weapon set 2!");
    }
    else return SendClientMessage(playerid, -1, "{FF0000}<!> {EEEEEE}You need to be atleast VIP Level 1 to use this Command.");
    return 1;
}
Change,
Код:
if(PlayerInfo[playerid][AdminLevel] >= 1)
to your Admin Level Function

Код:
if(PlayerInfo[playerid][VipLevel] >= 1)
to your VIP Level Function

For Example,

My Enum,
Код:
enum pInfo
{
	AdminLevel,
	VipLevel
}
that's why i get this,
Код:
if(PlayerInfo[playerid][AdminLevel] >= 1)
Код:
if(PlayerInfo[playerid][VipLevel] >= 1)
What is 1 shown above ?

1 is my Admin and VIP Level.

My New Variable = pInfo to PlayerInfo,
Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#7

Quote:
Originally Posted by SAMProductions
Посмотреть сообщение
Please show your "enum pInfo" or "enum PlayerInfo" to us,

so we we're able to help you

Here is my example:

For RCON,
pawn Код:
CMD:set2(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You must be an RCON Admin to use this Command.");
    GivePlayerWeapon(playerid, 1, 1);
    GivePlayerWeapon(playerid, 4, 1);
    GivePlayerWeapon(playerid, 12, 1);
    GivePlayerWeapon(playerid, 16, 10);
    GivePlayerWeapon(playerid, 23, 150);
    GivePlayerWeapon(playerid, 26, 125);
    GivePlayerWeapon(playerid, 32, 200);
    GivePlayerWeapon(playerid, 31, 200);
    GivePlayerWeapon(playerid, 33, 175);
    GivePlayerWeapon(playerid, 37, 1500);
    SendClientMessage(playerid, COLOR_YELLOW, "You've been granted weapon set 2!");
    return 1;
}
For Admins (using my Admin Level Function),
pawn Код:
CMD:set2(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 1)
    {
        GivePlayerWeapon(playerid, 1, 1);
        GivePlayerWeapon(playerid, 4, 1);
        GivePlayerWeapon(playerid, 12, 1);
        GivePlayerWeapon(playerid, 16, 10);
        GivePlayerWeapon(playerid, 23, 150);
        GivePlayerWeapon(playerid, 26, 125);
        GivePlayerWeapon(playerid, 32, 200);
        GivePlayerWeapon(playerid, 31, 200);
        GivePlayerWeapon(playerid, 33, 175);
        GivePlayerWeapon(playerid, 37, 1500);
        SendClientMessage(playerid, COLOR_YELLOW, "You've been granted weapon set 2!");
    }
    else return SendClientMessage(playerid, -1, "{FF0000}<!> {EEEEEE}You need to be atleast Admin Level 1 to use this Command.");
    return 1;
}
For VIPs (Using my VIP Level Function),
pawn Код:
CMD:set2(playerid, params[])
{
    if(PlayerInfo[playerid][VipLevel] >= 1)
    {
        GivePlayerWeapon(playerid, 1, 1);
        GivePlayerWeapon(playerid, 4, 1);
        GivePlayerWeapon(playerid, 12, 1);
        GivePlayerWeapon(playerid, 16, 10);
        GivePlayerWeapon(playerid, 23, 150);
        GivePlayerWeapon(playerid, 26, 125);
        GivePlayerWeapon(playerid, 32, 200);
        GivePlayerWeapon(playerid, 31, 200);
        GivePlayerWeapon(playerid, 33, 175);
        GivePlayerWeapon(playerid, 37, 1500);
        SendClientMessage(playerid, COLOR_YELLOW, "You've been granted weapon set 2!");
    }
    else return SendClientMessage(playerid, -1, "{FF0000}<!> {EEEEEE}You need to be atleast VIP Level 1 to use this Command.");
    return 1;
}
Change,
Код:
if(PlayerInfo[playerid][AdminLevel] >= 1)
to your Admin Level Function

Код:
if(PlayerInfo[playerid][VipLevel] >= 1)
to your VIP Level Function

For Example,

My Enum,
Код:
enum pInfo
{
	AdminLevel,
	VipLevel
}
that's why i get this,
Код:
if(PlayerInfo[playerid][AdminLevel] >= 1)
Код:
if(PlayerInfo[playerid][VipLevel] >= 1)
What is 1 shown above ?

1 is my Admin and VIP Level.

My New Variable = pInfo to PlayerInfo,
Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
I don't have any Enum pinfo? I just installed ****** register and login system it has a pinfo would you like that?
Reply
#8

Yes, all i want to see is your Admin Level Function or VIP Level Function shown in there
Reply
#9

Quote:
Originally Posted by SAMProductions
Посмотреть сообщение
Yes, all i want to see is your Admin Level Function or VIP Level Function shown in there
Ok here is the code;

Код:
//Credits to ******, Dracoblue and Kush.

#include <a_samp>
#include <YSI\y_ini>

#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4

#define PATH "/Users/%s.ini"

#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"

enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

/*Credits to Dracoblue*/
stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}

main()
{
        print("\n----------------------------------");
        print(" Blank Gamemode by your name here");
        print("----------------------------------\n");
}

public OnGameModeInit()
{
        SetGameModeText("Blank Script");
        return 1;
}

public OnGameModeExit()
{
        return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
        return 1;
}

public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    return 1;
}

public OnPlayerSpawn(playerid)
{
        return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
        return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
        return 1;
}

public OnPlayerText(playerid, text[])
{
        return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/mycommand", cmdtext, true, 10) == 0)
        {
                // Do something here
                return 1;
        }
        return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
        return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
        return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
        return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
        return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
        return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
        return 1;
}

public OnRconCommand(cmd[])
{
        return 1;
}

public OnPlayerRequestSpawn(playerid)
{
        return 1;
}

public OnObjectMoved(objectid)
{
        return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
        return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
        return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
        return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
        return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
        return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
        return 1;
}

public OnPlayerExitedMenu(playerid)
{
        return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
        return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
        return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
        return 1;
}

public OnPlayerUpdate(playerid)
{
        return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
        return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
        return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
        return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
        return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
                        }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                                        ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
        return 1;
}
Reply
#10

Try This One,
pawn Код:
CMD:set2(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        GivePlayerWeapon(playerid, 1, 1);
        GivePlayerWeapon(playerid, 4, 1);
        GivePlayerWeapon(playerid, 12, 1);
        GivePlayerWeapon(playerid, 16, 10);
        GivePlayerWeapon(playerid, 23, 150);
        GivePlayerWeapon(playerid, 26, 125);
        GivePlayerWeapon(playerid, 32, 200);
        GivePlayerWeapon(playerid, 31, 200);
        GivePlayerWeapon(playerid, 33, 175);
        GivePlayerWeapon(playerid, 37, 1500);
        SendClientMessage(playerid, COLOR_YELLOW, "You've been granted weapon set 2!");
    }
    else return SendClientMessage(playerid, -1, "{FF0000}<!> {EEEEEE}You need to be atleast Admin Level 1 (Trusted User) to use this Command.");
    return 1;
}
Just Change This to your Required Admin Level for this Command,
Код:
if(PlayerInfo[playerid][pAdmin] >= 1)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)