Home   Help Search Login Register  

Author Topic: Object names in MP  (Read 2274 times)

0 Members and 1 Guest are viewing this topic.

Offline ModestNovice

  • Members
  • *
Object names in MP
« 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
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Object names in MP
« Reply #1 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.

[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ModestNovice

  • Members
  • *
Re: Object names in MP
« Reply #2 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.



"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Rommel92

  • Members
  • *
Re: Object names in MP
« Reply #3 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;

Offline ModestNovice

  • Members
  • *
Re: Object names in MP
« Reply #4 on: 26 May 2009, 00:51:56 »
ok, I will try it.
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Object names in MP
« Reply #5 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];
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ModestNovice

  • Members
  • *
Re: Object names in MP
« Reply #6 on: 28 May 2009, 22:33:40 »
thanks (WORKS PERFECTLY :D)
« Last Edit: 29 May 2009, 06:02:50 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley