SA-MP Forums Archive
Assigning gamemode variables to values in a filterscript - 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: Assigning gamemode variables to values in a filterscript (/showthread.php?tid=578986)



Assigning gamemode variables to values in a filterscript - Stinged - 23.06.2015

I've never had to set a gamemode variable from a filterscript to a value before, so I've never faced this problem.
If I ever wanted to get the value, I would use the CallRemoteFunction method, for example:
pawn Код:
forward GetPlayerWhatever(playerid);
public GetPlayerWhatever(playerid)
{
    return whatever[playerid];
}
Now, I need to set that variable to a value, from the filterscript I'm currently scripting.
I've tried doing something like this, but it doesn't seem to work.
pawn Код:
forward SetPlayerWhatever(playerid, value);
public SetPlayerWhatever(playerid, value)
{
    return whatever[playerid] = value;
}
So I'm asking how could I do that?


Re: Assigning gamemode variables to values in a filterscript - J0sh... - 23.06.2015

Wouldn't you do CallRemoteFunction?


Re: Assigning gamemode variables to values in a filterscript - Konstantinos - 23.06.2015

In case you have tested it in OnFilterScriptInit, it wouldn't work - you'd have to delay it.

pawn Код:
// <filterscript>
#define SetPlayerWhatever(%0,%1) CallRemoteFunction("GM_SetPlayerWhatever", "ii", %0, %1)

// an example setting the value to 10 for that playerid somewhere in filterscript:
SetPlayerWhatever(playerid, 10);

// <gamemode>
// global:
new whatever[MAX_PLAYERS];

forward GM_SetPlayerWhatever(playerid, value);
public GM_SetPlayerWhatever(playerid, value)
{
    whatever[playerid] = value;
}
It works good.


Re: Assigning gamemode variables to values in a filterscript - Stinged - 23.06.2015

That's what I was doing, but without paying attention I was only adding one "i" in the format[] argument in CallRemoteFunction.
I noticed that after you posted those codes, Konstantinos.
Thanks for your help.