Sharing variables between scripts
#1

Hey,
I'm trying to script but I have a question.

Ok, say I have 2 filterscripts.
test1 and test2

test1.pwn:
new testvar = 0;

test2.pwn:
stock changevar()
{
testvar = 1;
}

changevar();
if(testvar == 1)
dothis();

I noticed if I declare variables in a .inc it can share them, but they seem to be loaded as 2 seperate instances, because if I modify the variable in 1 script it doesn't change in the other one.

Basically my question is: Is it possible to share variables between filterscripts? Like if I have an admin script and a seperate stats script, and I wanted to share the same enum for all of them. If this isn't possible, what can I do instead?

Thanks.
Reply
#2

You cannot use the same vars as the Gamemode. You better remove the filterscript and build it inside the gamemode.
Reply
#3

Quote:
Originally Posted by Kingunit
Посмотреть сообщение
You cannot use the same vars as the Gamemode. You better remove the filterscript and build it inside the gamemode.
These are both filterscripts, so it's not possible to share variables through all your filterscripts? Like if I want a filterscript to change a players money, and keep all the filterscripts able to read that variable too.
Reply
#4

Quote:
Originally Posted by vivec45
Посмотреть сообщение
These are both filterscripts, so it's not possible to share variables through all your filterscripts? Like if I want a filterscript to change a players money, and keep all the filterscripts able to read that variable too.
Not really. Never found a solution. Honestly the best solution is building those filterscript in one gamemode.
Reply
#5

Quote:
Originally Posted by Kingunit
Посмотреть сообщение
Not really. Never found a solution. Honestly the best solution is building those filterscript in one gamemode.
Okay, thanks. I understand now.

E: If I'm starting a new script, would it be better to start writing it in 0.3d scripting?
Reply
#6

Quote:
Originally Posted by vivec45
Посмотреть сообщение
E: If I'm starting a new script, would it be better to start writing it in 0.3d scripting?
Yes, because RC phase soon will be over, and 0.3d R1 comes
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
For global data use properties (instead of the GVar plugin, frankly the most pointless plugin ever).
I'm really appreciate you for writing this line.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)