Filterscript / Gamemode Communication ?? -
stuoyto - 10.05.2012
Hello samp forum members,
Today i have come across a problem that has really stumped me and put a halt on my gamemodes progress. The problem is the communication between my gamemode and my filsterscipts. I dont have any errors or code to show because i dont know how do create what im looking for but ill explain what i want to achieve.
On my gamemade i have player info stored in my Info enum
Код:
enum Info
{
pMoney,
pSking,
pAdminLevel
.....etc
}
and i have an array called PlayerInfo to store the enum
Код:
new PlayerInfo[MAX_PLAYERS][Info];
Now, what i am going to do is create a seperate commands filterscript to keep things tidy and alot of the commands require a certain Admin Level
Код:
PlayerInfo[playerid][pAdminLevel]
However, that is defined on my gamemode and is not present in my commands filterscript and will get a 'undefined symbol' error when adding it to my filterscript.
Basically what i am looking for is a way to allow the two scripts to communicate together a pass information eg Pass PlayerInfo[playerid][pAdminLevel] values to the commands filterscript.
If anybody knows what i mean and how to do this i would really appreciate it.
Stuoyto
Re: Filterscript / Gamemode Communication ?? -
SuperViper - 10.05.2012
In your gamemode:
pawn Код:
SetPVarInt(playerid, "pAdminLevel", PlayerInfo[playerid][pAdminLevel])
In your filterscript:
pawn Код:
if(GetPVarInt(playerid, "pAdminLevel") >= blabla)
{
....
}
Re: Filterscript / Gamemode Communication ?? -
stuoyto - 10.05.2012
Thanks alot this is cery useful information to me

Rep +
Re: Filterscript / Gamemode Communication ?? -
stuoyto - 10.05.2012
Wait, ive just tested the code you gave me and im not sure where to put the:
Код:
SetPVarInt(playerid, "pAdminLevel", PlayerInfo[playerid][pAdminLevel])
If i put it at the top of the script i get:
Код:
C:\Users\Stuart\Desktop\Sanandreas\Server\gamemodes\RRP.pwn(67) : error 021: symbol already defined: "SetPVarInt"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: Filterscript / Gamemode Communication ?? -
Yuryfury - 10.05.2012
What you can do is make an include (For Example: pawno/include/stuoytoadmin.inc) and to #include <stuoytoadmin> in both the filterscript and the gamemode.
The include should look something like this:
pawn Код:
#include <a_samp>
//====================ENUNM====================
enum gPInfo
{
Logged,
Level,
Skin,
Spec,
Muted,
Frozen,
Jailed,
Banned,
Warnings,
Cash,
Kills,
Deaths
};
new PInfo[MAX_PLAYERS][gPInfo];
//=============================================
stock IsPlayerYAdmin(playerid)
{
if(PInfo[playerid][Logged]==1)
{
new file[256],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,MAX_PLAYER_NAME);
format(file,sizeof(file),"YAdmin/Users/%s.user",playername);
PInfo[playerid][Level] = dini_Int(file,"Level");
if(PInfo[playerid][Level]>=1)
{
return 1;
}
else return 0;
}
else return 0;
}
stock IsPlayerYAdminLevel(playerid,level)
{
if(PInfo[playerid][Logged]==1)
{
new file[256],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,MAX_PLAYER_NAME);
format(file,sizeof(file),"YAdmin/Users/%s.user",playername);
PInfo[playerid][Level] = dini_Int(file,"Level");
if(PInfo[playerid][Level]>=level)
{
return 1;
}
else return 0;
}
else return 0;
}
You can then use the new IsPlayer(Y)Admin functions in either script. If you use Y-INI, just modify it accordingly.
Re: Filterscript / Gamemode Communication ?? -
stuoyto - 10.05.2012
Wow that is a great idea thanks
Re: Filterscript / Gamemode Communication ?? -
SuperViper - 10.05.2012
Files are less efficient than PVars. You put the SetPVarInt after your loading code.
Re: Filterscript / Gamemode Communication ?? -
(SF)Noobanatior - 10.05.2012
for this case use it just after you set PlayerInfo[playerid][pAdminLevel] when they login or where ever you do it