SA-MP Forums Archive
pInfo in filterscript - 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)
+--- Thread: pInfo in filterscript (/showthread.php?tid=487267)



pInfo in filterscript - mrxqware - 12.01.2014

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.


Re: pInfo in filterscript - Mattakil - 12.01.2014

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.


Re: pInfo in filterscript - SilentSoul - 12.01.2014

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.


Re: pInfo in filterscript - mrxqware - 12.01.2014

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?


Re: pInfo in filterscript - mrxqware - 12.01.2014

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


Re: pInfo in filterscript - xZdadyZx - 12.01.2014

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?


Re: pInfo in filterscript - mrxqware - 12.01.2014

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?


Re: pInfo in filterscript - mrxqware - 13.01.2014

Could some check this for me?


Re: pInfo in filterscript - mrxqware - 13.01.2014

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



Re: pInfo in filterscript - Pottus - 13.01.2014

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.