SA-MP Forums Archive
Retrieving variables from GM to FS - 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: Retrieving variables from GM to FS (/showthread.php?tid=513606)



Retrieving variables from GM to FS - biker122 - 17.05.2014

Hey there, Is it possible to retrieve some PARTICULAR player variable(s) from the gamemode to fs? For example, How can I retrieve the player's admin level from gamemode and store it in player's admin level which is inside the filterscript.

I've heard something like this, but still can't remember how it was possible.

Hope someone would help me,
Thanks.


Re: Retrieving variables from GM to FS - Threshold - 17.05.2014

An easy way to do this is PVars.

https://sampwiki.blast.hk/wiki/SetPVarInt
https://sampwiki.blast.hk/wiki/GetPVarInt

An example of this:
pawn Код:
//In an admin filterscript
SetPVarInt(playerid, "AdminLevel", 4); //Set my admin level to 4.
pawn Код:
//In my main gamemode...
new adminlevel = GetPVarInt(playerid, "AdminLevel"); //This will return '4', so adminlevel = 4.
if(adminlevel < 5) return SendClientMessage(playerid, -1, "You must be at least admin level 5 to use this.");
The parameter 'varname' is important in both. You can't have SetPVarInt(playerid, "ADMIN"), and then GetPVarInt(playerid, "ADMINLEVEL"), because they are two different varnames. You must use the same, like in the example 'AdminLevel' and 'AdminLevel'. I believe these are case sensitive?

Also note:
Quote:
Originally Posted by SA-MP Wiki
Variables aren't reset until after OnPlayerDisconnect is called, so the values are still accessible in OnPlayerDisconnect.



Re: Retrieving variables from GM to FS - biker122 - 17.05.2014

Well, I'll be a bit more clear. In the current gamemode i'm running, it retrieves the data from the MySQL database.
So, should I add SetPVarInt(playerid,"AdminLevel",PInfo[playerid][Level]); in LoadStats function?


Re: Retrieving variables from GM to FS - Threshold - 17.05.2014

Pretty much, yeah. Then in your filterscript, you would use 'GetPVarInt(playerid, "AdminLevel")' to retrieve the admin level.


Re: Retrieving variables from GM to FS - Stinged - 17.05.2014

You can use this:
pawn Код:
// In your gamemode
forward GetPlayerAdminLevel(playerid);
public GetPlayerAdminLevel(playerid)
{
    return PlayerInformation[playerid][admin];
}

// In your filterscript
#define GetPlayerAdminLevel(%0) CallRemoteFunction("GetPlayerAdminLevel", "i", %0)
Then you easily use GetPlayerAdminLevel(playerid) in your filterscript like PlayerInformation[playerid][admin] in your gamemode.

(Change them to whatever you want, just giving an example)