Variables accessible in mutliple scripts
#1

Is it possible to have a variable be recognized in different filterscripts (or other scripts) in Pawn?

In C/C++ I knew just to place "extern vname" in the header file, then define the variable in one other file. After that, all of the files could see it, and it would be the same variable... anything like this in Pawn?
Reply
#2

Just make an include with that variable. I think, it must work.
Reply
#3

I haven't tried yet but... will the variable in the include just be two separate variables when they enter the script?

Like able to have to have diff. values? I do not want that to happen.
Reply
#4

I am not sure. You have to test yourself.
Reply
#5

Use the Pawn Property Function

https://sampwiki.blast.hk/wiki/Getproperty
Reply
#6

is that the only way? Is this used alot?

(btw, the include "solution" did not work)
Reply
#7

Yeah includes wouldn't work, using an include is just like sticking the include's code into the .pwn, nothing else.

You can use the property solution like BlockFoX suggested, or you can create a public callback and use CallRemoteFunction("MyCallBack","ifs",integer,Floa t:float,string[]); which will call MyCallBack(integer,Float:float,string[]) in the GM and all 16 FSs
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)