PDA

View Full Version : Filterscript / Gamemode Communication ??


stuoyto
10/05/2012, 01:38 AM
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

SuperViper
10/05/2012, 01:51 AM
In your gamemode:

SetPVarInt(playerid, "pAdminLevel", PlayerInfo[playerid][pAdminLevel])

In your filterscript:

if(GetPVarInt(playerid, "pAdminLevel") >= blabla)
{
....
}

stuoyto
10/05/2012, 02:01 AM
Thanks alot this is cery useful information to me ;)
Rep +

stuoyto
10/05/2012, 02:11 AM
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\gamemode s\RRP.pwn(67) : error 021: symbol already defined: "SetPVarInt"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

Yuryfury
10/05/2012, 03:01 AM
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:


#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. :)

stuoyto
10/05/2012, 03:13 AM
Wow that is a great idea thanks

SuperViper
10/05/2012, 03:15 AM
Files are less efficient than PVars. You put the SetPVarInt after your loading code.

(SF)Noobanatior
10/05/2012, 03:56 AM
for this case use it just after you set PlayerInfo[playerid][pAdminLevel] when they login or where ever you do it