pInfo in filterscript
#1

Dear Guys and Girls,


I would like to create a filterscript where it checks if the player who is going to use a command is an admin.
It is easy to check if the player is using Rcon login, but I would like to check it this way so I don't have to share the rconpassword.

Using:

Код:
 	if(PlayerInfo[playerid][pAdmin] > 0)
 	{
        }
I don't know how to do this.

I thought I had to do:

Код:
#define FILTERSCRIPT
#include <a_samp>

 enum pInfo
 {
 pAdmin
 };
 new PlayerInfo[MAX_PLAYERS][pInfo];
It does not work.

Could anyone help me or show me a filterscript as an example to make it work?


Thank you in advance.
Reply
#2

Enums do not transfer from script to script, as they are saved in the script they are created. Pvars are saved to the player, so instead of using an enum here, you need a pvar.
Reply
#3

It's not working because the player pAdmin enum is default '0' you did it right but you'll need to set the enum of admin to 1+ in order to use any command checking if the enum bigger than '0' ,
pawn Код:
CMD:makemeadmin(playerid,params[])
{
    PlayerInfo[playerid][pAdmin] =1;//So now you're allowed to use any command checking the admin enum.
    return 1;
}
The above was just an example you'll need to create a command to set admin level for players.
Reply
#4

Thank you for the answers guys, but I can't get it to work. It seems like it cannot check if the player is an admin or not.

Could anyone make a simple filterscript which checks

if(PlayerInfo[playerid][pAdmin] > 0)
{
}

So it will hook/connect to the gamemode?
Reply
#5

I can't get it working, please could someone help me??
Reply
#6

Do you got full player system with saving done?if you do post some info. Also you can must change >0 to >=1 as that would work. Also how many admin levels do you got?
Reply
#7

Is there a way to do it like this?

Код:
 
public OnPlayerConnect(playerid)
{
new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    new file[128];
    format(file,sizeof(file),"%s.ini", Name);
    if(dini_Exists(file))
    {

        PlayerInfo[playerid][pAdmin] = dini_Int(file,"AdminLevel");
    }
 	return 1;
}
The user file is directly located in the folder 'scriptfiles'.

I would like to read the player's AdminLevel variable from the USER_NAME.ini file. Is this possible?
Reply
#8

Could some check this for me?
Reply
#9

The server is saving the player details using dini in .ini files which are located directly in the folder 'scriptfiles'. (the code is located in the gamemode.)

Now I would like to create a filterscript where it gets the player's adminrank. I don't know how to do this.

I think it should be like this, but it does not work.

Код:
Public OnPlayerConnect(playerid)
{
new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    new file[128];
    format(file,sizeof(file),"%s.ini", Name);
    if(dini_Exists(file))
    {

        PlayerInfo[playerid][pAdmin] = dini_Int(file,"AdminLevel");
    }
 	return 1;
}
Reply
#10

Just make some functions in your gamemode to return admin level for example.

pawn Код:
forward GetAdminLevel(playerid);
public GetAdminLevel(playerid) { return PlayerInfo[playerid][pAdmin]; }
Now make an include file to be used with filterscripts

pawn Код:
#define GetAdminLevel(%0) CallRemoteFunction("GetAdminLevel", "i", %0)
Now you can use GetAdminLevel(playerid) in your filterscripts. However keep in mind you rarely should need a filterscript in a public server so chances are your better off using callback hooking and compiling into the gamemode its self.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)