SA-MP Forums Archive
Variables accessible in mutliple scripts - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Variables accessible in mutliple scripts (/showthread.php?tid=130680)



Variables accessible in mutliple scripts - littlegrimlin1 - 27.02.2010

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?


Re: Variables accessible in mutliple scripts - ¤Adas¤ - 27.02.2010

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


Re: Variables accessible in mutliple scripts - littlegrimlin1 - 27.02.2010

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.


Re: Variables accessible in mutliple scripts - ¤Adas¤ - 27.02.2010

I am not sure. You have to test yourself.


Re: Variables accessible in mutliple scripts - BlackFoX - 27.02.2010

Use the Pawn Property Function

https://sampwiki.blast.hk/wiki/Getproperty


Re: Variables accessible in mutliple scripts - littlegrimlin1 - 28.02.2010

is that the only way? Is this used alot?

(btw, the include "solution" did not work)


Re: Variables accessible in mutliple scripts - Joe Staff - 28.02.2010

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