Jump to content
Sign in to follow this  
cruoriss

lbData Sring to Object (on dedicated)

Recommended Posts

Hey,

I'm trying to dynamicly fill a listbox with multiple vehicles .

So i used lbData to store the vehicle VarName to use it after : works fine in the editor but not at all on dedicated without even testing jip .

Like in this thread : http://forums.bistudio.com/showthread.php?170867-lbData-gt-String-to-Object

I use

_obj = missionNamespace getVariable [_objString, objNull]; 

(tried call compile too) but both commands break the vehicle VarName on dedicated server .

Here is the full code :

_lbPos = lbCurSel 4603;
_selectedMHQ = lbData [4603, _lbPos];
_MHQ = missionNamespace getVariable [_selectedMHQ, objNull];

systemChat format ["%1", _selectedMHQ];
systemChat format ["%1", _MHQ];

The first systemChat (direct lbData return in string) works perfectly but the other one breaks on dedicated server .

And also both code used to create the dialog + vehicle :

{
if (//code) then {
               //lbAdd code and display name
	_varName = _x getVariable "AOW_MHQ_VARNAME";
	_x setVehicleVarName _varName;
	lbSetData [4603, _index_mhq, _varName];
	systemChat format ["%1", _varName];
	systemChat format ["%1", _x]; // Both syst chat works well on dedicated
};
} forEach vehicles;

_vehMHQ = createVehicle [ASORVS_CurrentVehicle, ASORVS_VehicleSpawnPos, [], 0, "CAN_COLLIDE"];

       _vehMHQ_var = [] call AOW_fnc_getFreeNames; // Used to generate a random name

       _vehMHQ setVehicleVarName _vehMHQ_var;
       _varName = vehicleVarName _vehMHQ;
       _vehMHQ setVariable ["AOW_MHQ_VARNAME", _varName, true];

Thanks

EDIT : All this code is called client side

Edited by Cruoriss

Share this post


Link to post
Share on other sites
// Both syst chat works well on dedicated

Except it shouldn't work at all.

Share this post


Link to post
Share on other sites
Except it shouldn't work at all.

Why ?

Btw in my tests i had the whole thing working if I used a static name for the created vehicle that i "publicVariable'd" .

But since i want to be able to create multiple vehicles it wasn't good .

Share this post


Link to post
Share on other sites

He's saying there's noway systemChat will display as there is no display on a DS. (no UI).

Share this post


Link to post
Share on other sites
He's saying there's noway systemChat will display as there is no display on a DS. (no UI).

I meant when playing on a dedicated server i can see the messages while being a client, the dialog insn't created directly on the server .

Share this post


Link to post
Share on other sites
I meant when playing on a dedicated server i can see the messages while being a client, the dialog insn't created directly on the server .

Well it wasn't obvious from your post that this is what you meant. Are you creating vehicle in preinit?

Share this post


Link to post
Share on other sites
Well it wasn't obvious from your post that this is what you meant. Are you creating vehicle in preinit?

My bad i should have said while playing on dedicated .

No, they are created later using a vehicle spawner called by client .

Share this post


Link to post
Share on other sites

I like to use BIS_fnc_objectVar instead of setVehicleVarName (it does it for you). It has always worked for me when I require vehicles to have a name. It can accept a pre-made name or create one for you. It will then return that name in string format. Use call compile or getVar to access that vehicle.

let function assign a name:

_varName = _object call BIS_fnc_objectVar;
_vic = call compile _varName;

or

assign the name yourself

_varName = [_object,"TheName"] call BIS_fnc_objectVar;
_vic = missionNamespace getVariable _varName;

Share this post


Link to post
Share on other sites
I like to use BIS_fnc_objectVar instead of setVehicleVarName (it does it for you). It has always worked for me when I require vehicles to have a name. It can accept a pre-made name or create one for you. It will then return that name in string format. Use call compile or getVar to access that vehicle.

let function assign a name:

_varName = _object call BIS_fnc_objectVar;
_vic = call compile _varName;

or

assign the name yourself

_varName = [_object,"TheName"] call BIS_fnc_objectVar;
_vic = missionNamespace getVariable _varName;

Damn, BIS_fnc_objectVar is my new best friend .

It perfectly fix my dedicated environement issues and also works for jip .

Thanks a lot

(Btw i looked at what it was in the function viewer and i saw that it pubVar'd a local variable ... that was the part i was stuck at and thought it was impossible to do so, BIS black magic i guess)

Share this post


Link to post
Share on other sites
let function assign a name:

Code:

_varName = _object call BIS_fnc_objectVar;

_vic = call compile _varName;

or

assign the name yourself

Code:

_varName = [_object,"TheName"] call BIS_fnc_objectVar;

_vic = missionNamespace getVariable _varName;

No need to call compile the var, it is a global var (missionNamespace) holding a reference to the object.

So either

_varName = _object call BIS_fnc_objectVar;
myObject = missionNamespace getVariable _varName;

OR

_name = "MyObjectsName"
_object setVehicleVarName _name;
missionNamespace setVariable [ _name, _object ];
publicVariable _name;

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  

×