Save variable outside a public - 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: Save variable outside a public (
/showthread.php?tid=424339)
Save variable outside a public -
surrender - 21.03.2013
Hey guys, I've got the following code:
pawn Код:
new x; // on top of my script
...
public _function()
{
...
x = 11;
...
return true;
}
public _function2() return printf("%d", x); // returns 0 (like x is just initialised)
What I want is the value of x in _function2() (after it has been filled in _function() ofc).
It is not an option for me to return the value at the end of _function() so I can do newvar = _function().
How can I do that?
Re: Save variable outside a public -
Vince - 21.03.2013
I do not understand what you mean.
Re: Save variable outside a public -
surrender - 21.03.2013
I defined x on top of the script, filled it in function1 and want to use it on function2.
Re: Save variable outside a public -
Misiur - 21.03.2013
Well, if you are sure that _function was called before _function2, then it should return 11.