Is it possible
#1

EDIT:
Really thank you guys for the replys, it helped me alot, but now i am wondering if its possible to make a PlayerInfo work with a Gamemode and filterscript?

must i use it like this?:

Gamemode:
pawn Code:
//Gamemode
enum PlayerInfo
{
PlayerInfo[playerid][pAdmin]
}

new pInfo[MAX_PLAYERS][PlayerInfo];

forward getAllInfos(playerid);
public getAllInfos(playerid)
{
    return pInfo[playerid][pAdmin];
}
Filterscript:

pawn Code:
#define GetPlayerInfo(%0) CallRemoteFunction("getAllInfos", "i", %0)

//somewhere in script
GetPlayerInfo(playerid);//is there a way to not write this in the filterscript and it gets everything from the gamemode?
if(pInfo[playerid][pAdmin] >= 3)
{
//code
}
I want to get all player stats/infos known by the filterscript is this possible?

again thank you guys for helping me out
Reply
#2

Yes, it is possible to get a value from a script to another but it's not very similar to your example.

Either set a property: https://sampwiki.blast.hk/wiki/Function:setproperty
Or make a public function that returns the value of it and call: https://sampwiki.blast.hk/wiki/CallRemoteFunction
Reply
#3

Thank you for your reply, can you maybe give me an example how to use it?

like what do i put in the gamemode and what in filterscript, i will be very happy if you guys could help me out.
Reply
#4

I have never worked with properties but I believe it'd work. Few examples:

PHP Code:
// in gamemode:
forward GM_IsPlayerSpawned(playerid);
public 
GM_IsPlayerSpawned(playerid)
{
    return 
IsSpawned[playerid];
}
// in filterscript:
#define IsPlayerSpawned(%0) CallRemoteFunction("GM_IsPlayerSpawned", "i", %0) 
PHP Code:
// in gamemode:
SetValueForSpawned(playeridtoggle)
{
    
IsSpawned[playerid] = toggle;
    
    new 
tmp_prop[16];
    
format(tmp_propsizeof tmp_prop"%i_IsSpawned"playerid);
    
setproperty(.name tmp_prop, .value toggle);
}
// in filterscript:
IsPlayerSpawned(playerid)
{
    new 
tmp_prop[16];
    
format(tmp_propsizeof tmp_prop"%i_IsSpawned"playerid);
    return 
getproperty(.name tmp_prop);

Reply
#5

Again thank you very much for your help!
Reply
#6

or just use pvars, its simply
in GM
pawn Code:
SetPVarInt(playerid, "Spawned", 1);
in FS
pawn Code:
if(GetPVarInt(playerid, "Spawned") == 1)
{
// code
}
Reply
#7

Quote:
Originally Posted by Jefff
View Post
or just use pvars, its simply
in GM
pawn Code:
SetPVarInt(playerid, "Spawned", 1);
in FS
pawn Code:
if(GetPVarInt(playerid, "Spawned") == 1)
{
// code
}
Bad advice.
Use CallRemoteFunction() pvars have uses but this is a terrible use for them here is what I would do.

Gamemode.
Code:
 forward GetSpawnVar(playerid);
public GetSpawnVar(playerid) { return PlayerSpawned[playerid]; }
Filterscript.
Code:
#define PlayerSpawned[%0] CallRemoteFunction("GetSpawnVar","i",%0);
It will end up being less work and less overhead than using pvars I will explain why.

1.) You would need to set the pvar anytime the variable changes or swap your variable for a pvar (extra work).
2.) It would end up being less efficient to use pvars because of what you would need to do in your gamemode.
3.) It looks like shit using a #define and CallRemoteFunction() you can simulate the design of your gamemode in filterscripts.
Reply
#8

Really thank you guys for the replys, it helped me alot, but now i am wondering if its possible to make a PlayerInfo work with a Gamemode and filterscript?

must i use it like this?:

Gamemode:
pawn Code:
//Gamemode
enum PlayerInfo
{
PlayerInfo[playerid][pAdmin]
}

new pInfo[MAX_PLAYERS][PlayerInfo];

forward getAllInfos(playerid);
public getAllInfos(playerid)
{
    return pInfo[playerid][pAdmin];
}
Filterscript:

pawn Code:
#define GetPlayerInfo(%0) CallRemoteFunction("getAllInfos", "i", %0)

//somewhere in script
GetPlayerInfo(playerid);//is there a way to not write this in the filterscript and it gets everything from the gamemode?
if(pInfo[playerid][pAdmin] >= 3)
{
//code
}
I want to get all player stats/infos known by the filterscript is this possible?

again thank you guys for helping me out
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)