OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: ModestNovice on 08 Nov 2008, 19:10:35

Title: Reassinging vehicle name after disconnect
Post by: ModestNovice 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
Title: Re: Reassinging vehicle name after disconnect
Post by: Spooner 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.
Title: Re: Reassinging vehicle name after disconnect
Post by: ModestNovice 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 :(
Title: Re: Reassinging vehicle name after disconnect
Post by: Spooner 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.