Forum Jump :

Author Message


Posts: 2
Rank:


Level: Member

Country: es
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2014-04-26 10:53        
     
Hi, I have a problem about variables and multiplayer, here is my example:


init.sqf
publicVariable "A","points";
_null = [] execVM "engine.sqf";

engine.sqf
if (isServer) then {
	A = 0;
	publicVariable "A";
	points = 0;
	publicVariable "points";
};


if (isServer) then {
	while {true} do {
		if (B == 1) then {
			points = points +1;
			sleep 1;
		}

Okay, the problem is when player1 has A = 10, maybe player2 has A = 8
Any solutions to this? Thanks


Author Message


Posts: 250
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name: austinXmedic

 
#2 Posted at 2014-05-03 15:38        
     
BIS_fnc_MP is your best buddy for MP scripting. you can sync that across all clients by doing something similar to this:

Put this in your init.sqf
AUSMD_fnc_syncVariable =
{
     _var = _this select 0;
     _value = _this select 1;
     _var = _value;
};
then to sync your variable across all clients you execute the function using this:
[["yourvariablenamehere",yourvaluehere],"AUSMD_fnc_syncVariable",nil,false] spawn BIS_fnc_MP;

Might not work, maybe it will. let me know if it doesn't and i'll try to find a way to fix it.


EDIT:

Also you can only use publicVariable "varhere";
if you want to sync more than one variable then you need to make another line with publicvariable "varhere"; But personally I found publicVariable to be broken in the way that it doesn't actually sync across all clients hilariously, maybe it was just for what I was using it for (maybe its fixed?).

Some of my work:
http://steamcommunity.com/sharedfiles/filedetails/?id=287343671 -- Unit Play/ Unit Capture Functions Guide
http://steamcommunity.com/sharedfiles/filedetails/?id=265454265 -- Zeus Guide
add me on steam: austin_medic

Advertisement


Author Message


Posts: 2
Rank:


Level: Member

Country: es
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2014-06-12 17:31        
     
# austin(medic) : BIS_fnc_MP is your best buddy for MP scripting. you can sync that across all clients by doing something similar to this:

Put this in your init.sqf
AUSMD_fnc_syncVariable =
{
     _var = _this select 0;
     _value = _this select 1;
     _var = _value;
};
then to sync your variable across all clients you execute the function using this:
[["yourvariablenamehere",yourvaluehere],"AUSMD_fnc_syncVariable",nil,false] spawn BIS_fnc_MP;

Might not work, maybe it will. let me know if it doesn't and i'll try to find a way to fix it.


EDIT:

Also you can only use publicVariable "varhere";
if you want to sync more than one variable then you need to make another line with publicvariable "varhere"; But personally I found publicVariable to be broken in the way that it doesn't actually sync across all clients hilariously, maybe it was just for what I was using it for (maybe its fixed?).

Sorry for late response, I solved it with publicVariable "myVariable";

Thanks for the help ^^

Added 1 second later:

# austin(medic) : BIS_fnc_MP is your best buddy for MP scripting. you can sync that across all clients by doing something similar to this:

Put this in your init.sqf
AUSMD_fnc_syncVariable =
{
     _var = _this select 0;
     _value = _this select 1;
     _var = _value;
};
then to sync your variable across all clients you execute the function using this:
[["yourvariablenamehere",yourvaluehere],"AUSMD_fnc_syncVariable",nil,false] spawn BIS_fnc_MP;

Might not work, maybe it will. let me know if it doesn't and i'll try to find a way to fix it.


EDIT:

Also you can only use publicVariable "varhere";
if you want to sync more than one variable then you need to make another line with publicvariable "varhere"; But personally I found publicVariable to be broken in the way that it doesn't actually sync across all clients hilariously, maybe it was just for what I was using it for (maybe its fixed?).

Sorry for late response, I solved it with publicVariable "myVariable";

Thanks for the help ^^