Home   Help Search Login Register  

Author Topic: Reassinging vehicle name after disconnect  (Read 1484 times)

0 Members and 1 Guest are viewing this topic.

Offline ModestNovice

  • Members
  • *
Reassinging vehicle name after disconnect
« on: 08 Nov 2008, 19:10:35 »
Hello I am having problems making a vehicle get its name back after I leave game.

What happens is that the car is created and given a name publicly. But after I disconnect  and come back, this vehicle loses its name. Is there any way I can return the name?

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: Reassinging vehicle name after disconnect
« Reply #1 on: 08 Nov 2008, 19:16:52 »
Don't use a publicVariable EH to set the name. Rather, use setVehicleInit/processInitCommands, which will be synced and run on JIP.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ModestNovice

  • Members
  • *
Re: Reassinging vehicle name after disconnect
« Reply #2 on: 08 Nov 2008, 19:25:16 »
thanks for quick reply.

Will test right now.


nvr mind, mess up on my part.

hmmm, it not working. I have it assign like this.

Code: [Select]
_vehicle = lbData [_list, _index];
Tveh = _vehicle;

_veh setVehicleInit "
this addaction [""[Vehicle Stats]"", ""D_Functions\vehicle_stats.sqf"", [], 2];
letters = [""A"",""B"",""C"",""D"",""E"",""F"",""G"",""H"",""I"",""J"",""K"",""L"",""M"",""N"",""O"",""P"",""Q"",""R"",""S"",""T"",""U"",""V"",""W"",""X"",""Y"",""Z""];
let1 = letters select (floor(random count letters));
let2 = letters select (floor(random count letters));
Vname = format[""%1%2_%3_%4"", let1,let2, Tveh, (ceil(random 500))];
this setVehicleVarName Vname;
";
processinitCommands;

but it doenst have the same name :(
« Last Edit: 08 Nov 2008, 20:00:09 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

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Reassinging vehicle name after disconnect
« Reply #3 on: 08 Nov 2008, 20:28:33 »
You need to randomise the values before adding the vehicleInit, otherwise the random value will be different on every machine! You should therefore format the code you are putting in the init with random numbers, so the same values will be used on every machine.

You also shouldn't send code through init if you can avoid it, since it is rather inefficient. Rather, make a function when the mission starts and call that from the vehicleInit.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)