Jump to content
  • 0

Global Variables


sentan

Question

Hello,

 

i have a problem with global variables, works so far, but after reconnect the variables are empty. Someone know what the problem is?

init.sqf
 

if(isServer) then {
	[] execVM "myServerScript.sqf";
};


[] execVM "myClientScript.sqf";

myServerScript.sqf

my_var1 = true;
publicVariable "my_var1";

my_var2 = floor(time);
publicVariable "my_var2";

my_var3 = [	
			[8096.875, 7824.2896,0],
			[8241.0039, 7612.2881,0],
			[8935.9805, 7398.7944,0]
] call BIS_fnc_selectRandom;
publicVariable "my_var3";

myClientScript.sqf
 

while {true} do {
    sleep 10;
    systemchat format["%1 || %2 || %3", my_var1, my_var3, my_var3];
};

Output looks like: true || 145256352 || 8096.875, 7824.2896,0
but after a player die and he reconnect, then it looks so: any || any || any

Can someone help?
I need these variables after reconnect.

thanks

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

JIP clients will need a few seconds until they receive the publicVariables.

I recommend to set a 'waitUntil' timer to check whether the variable is already defined or not.

while {true} do {
	waitUntil {(!isNil "my_var1") && (!isNil "my_var2") && (!isNil "my_var3")};
        systemChat format["%1 || %2 || %3", my_var1, my_var3, my_var3];
	uiSleep 10;
};
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...