Filterscript / Gamemode Communication ??
#1

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
Reply
#2

In your gamemode:

pawn Код:
SetPVarInt(playerid, "pAdminLevel", PlayerInfo[playerid][pAdminLevel])
In your filterscript:

pawn Код:
if(GetPVarInt(playerid, "pAdminLevel") >= blabla)
{
    ....
}
Reply
#3

Thanks alot this is cery useful information to me
Rep +
Reply
#4

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.
Reply
#5

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.
Reply
#6

Wow that is a great idea thanks
Reply
#7

Files are less efficient than PVars. You put the SetPVarInt after your loading code.
Reply
#8

for this case use it just after you set PlayerInfo[playerid][pAdminLevel] when they login or where ever you do it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)