Jump to content
Sign in to follow this  
Socrate

PublicVariable and createVehicle

Recommended Posts

I'm sorry...seems like i've always something to learn!

In my init

T_INIT = false;
T_Server = false; T_Client = false; T_JIP = false;

if (playersNumber east + playersNumber west + playersNumber resistance + playersNumber civilian > 0) then { T_MP = true } else { T_MP = false };

if (isServer) then {
T_Server = true;
if (!(isNull player)) then { 
T_Client = true 

};
T_INIT = true;
} else {
T_Client = true;
if (isNull player) then {
	T_JIP = true;
	[] spawn { waitUntil { !(isNull player) }; T_INIT = true };
} else {
	T_INIT = true;
};
};
//Will wait for the player variabile to be initiliazed
waitUntil { T_INIT };

while { true } do {
	_handle = [] execVM "games\CTF\ctf.sqf";
	waitUntil {scriptDone _handle};
};

So both client and server execute the ctf.sqf and wait it to terminate...right?

Here's the problem : ctf.sqf

//We initialize some global variables for both player and server
playerWithSuitcase = nil;
objectCompleted = false;
suitcase = nil;
teleportWest = nil;
teleportEast = nil;

if(T_Server) then {
suitcase = "Suitcase" createVehicle getMarkerPos (_objMarkerArray select _pos);
publicVariable "suitcase";
teleportWest = "FlagCarrierUSA" createVehicle [getMarkerPos (_objMarkerArray select _nextPos) select 0, ((getMarkerPos (_objMarkerArray select _nextPos) select 1) - 100), getMarkerPos (_objMarkerArray select _nextPos) select 2 ];
teleportEast = "FlagCarrierRU" createVehicle [ getMarkerPos (_objMarkerArray select _nextPos) select 0, ((getMarkerPos (_objMarkerArray select _nextPos) select 1) + 100), getMarkerPos (_objMarkerArray select _nextPos) select 2 ];
publicVariable "teleportWest";
publicVariable "teleportEast";
};

if(T_Client && !T_Server) then {
waitUntil {!isNil("suitcase")};
waitUntil {!isNil("teleportWest")};
waitUntil {!isNil("teleportEast")};

suitcase addAction ["Grab Suitcase", "games\CTF\suitcase\grab.sqf", [], 0, false, true, "Suitcase Grabbed", "true"];
};

if i try to display with an hint command the suitcase variable i get "any"!! the same happen with the teleportWest and East variables.

From the wiki of the publicVariable command:

The only limitation is you cannot transfer references to entities which are local, like scripts, displays, or local objects.

Hwr the object created with the createVehicle is trasferred to all players in MP!!!!

Infact thare's the local command createVehicleLocal...

Can you help me?

the only solution i found is to put these objects in the editor and not to create them by script...hwr i wanted to do everything with scripts...

Edited by Socrate

Share this post


Link to post
Share on other sites
instead of pubvar, try setvehiclevarname

how does it work?!:butbut:

Share this post


Link to post
Share on other sites

OK solved!!!! Thank you shk!! with a little of testing i came to it with this code:

//We create the suitcase and Add grab Action

_Object = "Suitcase" createVehicle getMarkerPos (_objMarkerArray select _pos);

_Object SetVehicleVarName "suitcase";

suitcase = _Object;

PublicVariable "suitcase";

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×