OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: ModestNovice on 25 May 2009, 06:15:57

Title: Object names in MP
Post by: ModestNovice on 25 May 2009, 06:15:57
Hi this is something I have been trying to learn how to fix for quite sometime and despite peoples input still cannot get it to work  :confused:.

What I'm trying to achieve is to add back the vehicleVarName to any objects or vehicles created during the mission. As when you disconnect it seems these objects/vehicles lose their names.

Does anyone know any solutions to this?

Thanks,
DaChevs
Title: Re: Object names in MP
Post by: Spooner on 25 May 2009, 14:02:24
Rather than
Code: [Select]
_vehicle = "frog" createVehicle [0, 0, 0];
_vehicle setVehicleVarName "fred";
use:
Code: [Select]
_vehicle = "frog" createVehicle [0, 0, 0];
_vehicle setVehicleInit "this setVehicleVarName 'fred'";
processInitCommands;
This will also have the side effect of making the varname globally visible.

Title: Re: Object names in MP
Post by: ModestNovice on 26 May 2009, 00:05:25
Roger, but in my case the mission is an RPG, so we have many vehicle names so they generate like:

_frog = "frog" createVehicle [0,0,0];
_frog setVehicleVarName format ["%1%2_%3_Frog",random 500,random 1000,name buyer];

so it will throw an error when it is processInitCommands again.



Title: Re: Object names in MP
Post by: Rommel92 on 26 May 2009, 00:26:25
Code: [Select]
_frog = "frog" createVehicle [0,0,0];
_name = format ["%1%2_%3_Frog",random 500,random 1000,name buyer];
_frog setVehicleInit format["this setVehicleVarName %1",_name];
processInitCommands;

I can't see why this wouldn't work; if it doesn't then try this:

Code: [Select]
_frog = "frog" createVehicle [0,0,0];
_name = format ["%1%2_%3_Frog",random 500,random 1000,name buyer];
_frog setVehicleInit ("this setVehicleVarName " + str(_name));
processInitCommands;
Title: Re: Object names in MP
Post by: ModestNovice on 26 May 2009, 00:51:56
ok, I will try it.
Title: Re: Object names in MP
Post by: Spooner on 27 May 2009, 01:03:17
You would need the later, since it will wrap the name in quotation marks. e.g. str("frog") == """frog"""

You could also use:
Code: [Select]
_frog setVehicleInit format["this setVehicleVarName ""%1""",_name];
Title: Re: Object names in MP
Post by: ModestNovice on 28 May 2009, 22:33:40
thanks (WORKS PERFECTLY :D)