Posts: 270
Threads: 41
Joined: Sep 2013
04.04.2014, 13:19
(
Последний раз редактировалось HitterHitman; 04.04.2014 в 14:09.
)
Hello friends I have a question about how to use Pvars. I use this variable
pawn Код:
PlayerInfo[playerid][pAdmin]
to know the player's admin level But how can I get the player's admin level in another filterscript? Please help with a simple example.
EDIT: Also if there is another method to this I want to know that too.
Posts: 270
Threads: 41
Joined: Sep 2013
Quote:
Originally Posted by Vince
If you already have the system in place then it is no use converting them to PVars. Create a wrapper so you can fetch it with CallRemoteFunction. Move your enum (but NOT the variable declaration) to an include file and then include that file into both scripts.
pawn Код:
// GM public Remote_GetData(playerid, pInfo:var) // replace pInfo with the name of your enum { return PlayerInfo[playerid][var]; }
pawn Код:
// FS GetVar(playerid, pInfo:var) // once again rename pInfo { return CallRemoteFunction("Remote_GetData", "dd", playerid, _:var); }
pawn Код:
new adminlevel = GetVar(playerid, pAdmin);
In this form it'll only work with integer variables, but it can be extended to return floats and strings.
|
So, I have to use that GM code in the script from which i have to get the data and FS code in the script which needs the data? also what is that code in gm do? Does it gets the data? But I am changing the level in this script only so why should I have to get the data? Where do I have to put new adminlevel = GetVar(playerid, pAdmin);?
And I just have to move enum in one include (just cut and paste)?
EDIT: I nedd to send data from 1 FS to another FS will it work instead of GM?
Posts: 270
Threads: 41
Joined: Sep 2013
Quote:
Originally Posted by [uL]Pottus
PVars COULD be used for this but it's a lousy way to do it here is what I would do.
1.) Create a getter function in your gamemode
pawn Код:
forward GetAdminLevel(playerid); public GetAdminLevel(playerid) { return PlayerInfo[playerid][pAdmin]; }
2.) Create a include for your filterscripts
pawn Код:
#define GetAdminLevel(%0) CallRemoteFunction("GetAdminLevel", "i", %0)
3.) Now include that into your filterscripts and use GetAdminLevel(playerid)
I'm not going to recommend PVars you might ask why there reason is simple, they're bad coding practice you simply don't need them.
@Vince that is an interesting way to do it actually!
|
Thanks that worked.
EDIT: wait a minute i used
pawn Код:
if(GetAdminLevel(playerid) >= 3)
but it isnt getting their level, it just gets 0.
EDIT 2: Ohh works my mistake.