thegunnysgt 1 Posted August 19, 2007 Just as the title says... I am running a script that respawns a vehicle, the vehicle is named within the editor, but when it respawns the new vehicle isn't named. In the Init field I have this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">v = [this, "vehicle name", x] execVM "Respawn.sqf" Within the script it gets the vehicle name using: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_name_vcl = _this select 1; Then after the "CreateVehicle" command in the script, I have: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vcl setVehicleVarName _name_vcl; The problem for some reason is the newly created vehicle isn't getting the old vehicle's name. Share this post Link to post Share on other sites
dr_eyeball 16 Posted August 19, 2007 I had the same issue recently using vrs.sqf (vehicle respawn script). I fixed it by doing the following. I replaced the old code (which removes the old vehicle & recreates it): <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> deleteVehicle _vcl; _vcl = _type createVehicle _pos; with code to store it's name, delete, recreate, then put back the name: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _name = vehicleVarName _vcl; deleteVehicle _vcl; _vcl = _type createVehicle _pos; if (_name != "") then { _vcl setVehicleVarName _name; call compile format["%1 = _vcl", _name]; // debug if (vehicleVarName _vcl != _name) then { player sideChat "vehicleVarName does not match "+_name } else { player sideChat "vehicleVarName changed "+_name }; }; The tricky part was to include the part: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call compile format["%1 = _vcl", _name]; I don't see why it should be necessary, since I thought setVehicleVarName would do just that. Share this post Link to post Share on other sites
thegunnysgt 1 Posted August 19, 2007 Works perfect...Thanks. Now I am at another stump with the vehicle when it respawn. I have the vehicle calling a script within its Init Line, but when it respawns it stops calling the script and doesn't call it again. My guess is the Init Line clears. How can I fix it. Share this post Link to post Share on other sites
dr_eyeball 16 Posted August 19, 2007 It depends on what your initialization field does/calls, but you could try this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_code = "[this] execVM 'initMyVehicle.sqf'; "; _vehicle setVehicleInit _code; processInitCommands; clearVehicleInit _vehicle; Assuming the init code is the same for all. I don't know how to check what the initialization field value was before it's cleared. Share this post Link to post Share on other sites
Synide 0 Posted August 19, 2007 I don't see why it should be necessary, since I thought setVehicleVarName would do just that. it's necessary because... the 'name' of a vehicle is not the name of the vehicle object... setVehicleVarName & vehicleVarName are class methods that set & get the class property that holds the name of the vehicle. These class methods do not automatically equate the instance of that object to the name provided. when you first launch a mission and a vehicle has a name provided through the editor or setVehicleVarName method the engine automatically equates the instance to that name also. On subsequent respawns of this vehicle a 'new' instance of the vehicle type is created. the property name is being set by setVehicleVarName but you must also tell the ArmA engine that this new vehicle object instance IS equal to this name. get it? it's exactly the same with playable character objects except the ArmA engine does the equating portion also automatically for you... whereas for npc objects it does not... Share this post Link to post Share on other sites
ArMoGaDoN 0 Posted August 19, 2007 re: playable character / npc thing above: I recently wroite a simple GPS script, and the playable character 'Editor Name' for the character's object does NOT get automatically carried over after a respawn, only the player's in-game name does. After many attempts to get it working 'properly' using the character editor-name, I finally gave up then I changed to running a trigger and using 'list' in a loop to track characters after a respawn. Sux - really this naming thing SHOULD retain the name after respawn, else the editor-name is rendered almost pointless in a multiplayer context. Perhaps this should also be added to the to-do list..? Share this post Link to post Share on other sites
Synide 0 Posted August 19, 2007 WarWolf @ Aug. 20 2007,01:28)]re: playable character / npc thing above:I recently wroite a simple  GPS script, and the playable character 'Editor Name' for the character's object does NOT get automatically carried over after a respawn, only the player's in-game name does. After many attempts to get it working 'properly' using the character editor-name, I finally gave up then I changed to running a trigger and using 'list' in a loop to track characters after a respawn. Sux - really this naming thing SHOULD retain the name after respawn, else the editor-name is rendered almost pointless in a multiplayer context.  Perhaps this should also be added to the to-do list..? then you must be doing something awkward mate... 'cause I just retested this again... (previously tested under 1.02)... Note:- all the following commands were run as interactive script typed into a multiplayer debugger console and run whilst playing a MP mission on a dedicated (remote) server. The mission had 6 playable character units and featured base respawn. the command 'units group player' initially and the result was... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[W1,W2,W3] units W4, W5 & W6 were a group with leader as W4. their locallity was the dedi server. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Me = W1 (object reference name - defined in editor)     typeOf W1 = SoldierWSniper     typeOf player = SoldierWSniper     typeName W1= OBJECT     typeName player= OBJECT     alive W1 = true     alive player = true     local W1 = true     local player = true     name W1 = Synide     name player = Synide     vehicleVarName W1 = W1     vehicleVarName player = W1 AI = W2 (object ref. name as defined in editor)    note: this unit is marked playable and is it's leader is W1.(so me - which made it local to my computer)     typeOf W2 = SoldierWSniper     typeName W2 = OBJECT     alive W2 = true     local W2 = true     name W2 = Matthew Martin (A name that was arbitrarily assigned by the server)     vehicleVarName W2 = W2 AI = W4 (object ref. name as defined in editor)     typeOf W4 = SoldierWSniper     typeName W4 = OBJECT     alive W4 = true     local W4 = false     name W4 = Austin Young (A name that was arbitrarily assigned by the server)     vehicleVarName W4 = W4 At this point the script command... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">W2 setDamage 1; was run and the result was that W2 died... (the respawnDelay was set to 10 seconds) when the W2 unit respawned these were the results of typing the commands above again... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">     typeOf W2 = SoldierWSniper     typeName W2 = OBJECT     alive W2 = true     local W2 = true     name W2 = Matthew Martin (same name again...)     vehicleVarName W2 = W2 At this point the following script commands were typed with the results noted... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">     typeOf W4 = SoldierWSniper     typeName W4 = OBJECT     alive W4 = true     local W4 = false     name W4 = Jonathan Lewis (A name that was arbitrarily assigned by the server)     vehicleVarName W4 = W4 ... then... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">W4 setDamage 1 was run and the result was that W4 died... when the W4 unit respawned these were the results of typing the commands... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">     typeOf W4 = SoldierWSniper     typeName W4 = OBJECT     alive W4 = true     local W4 = false     name W4 = Matthew Martin (same name again...)     vehicleVarName W4 = W4 Note:- no monitoring script was present in the mission to 'set' the vehicleVarName after the character units respawned. draw your own conclusions... With vehicles though... you have to equate the 'name' to the new object instance after respawn as well as setting 'vehicleVarName'. Share this post Link to post Share on other sites
thegunnysgt 1 Posted August 20, 2007 I think I got it working, haven't fully tested it yet. How can I get this statement to work?<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(getmarkerpos "wfirepoint") == [0,0] : goto "exit" What I want to do is when it returns the markers position I want it to compare it to [0,0], and if the returned values don't match those of [0,0] to go to "exit". How can I get it to work so it says not equal to? Share this post Link to post Share on other sites
Synide 0 Posted August 20, 2007 I think I got it working, haven't fully tested it yet.How can I get this statement to work?<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(getmarkerpos "wfirepoint") == [0,0] : goto "exit" What I want to do is when it returns the markers position I want it to compare it to [0,0], and if the returned values don't match those of [0,0] to go to "exit". Â How can I get it to work so it says not equal to? replace '==' with '!=' Share this post Link to post Share on other sites
thegunnysgt 1 Posted August 20, 2007 I tried replacing "==" with "!=" and it came up with "! |#| =" when I went to test it in the editor. Share this post Link to post Share on other sites
dr_eyeball 16 Posted August 20, 2007 You cannot compare arrays using "==" or "!=". You need to compare each pair of elements individually. Eg: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_a = (getmarkerpos "wfirepoint"); ? ((_a select 0 == 0) && (_a select 1 == 0)) : goto "exit" or <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_a = (getmarkerpos "wfirepoint"); _b = [0,0]; ? ((_a select 0 == _b select 0) && (_a select 1 == _b select 1)) : goto "exit" Personally, I use a function to compare arrays. Share this post Link to post Share on other sites
Synide 0 Posted August 20, 2007 @thegunnysgt... sorry, mate... teach me to read your posts a bit more carefully next time... dr_eyeball is quite correct... Share this post Link to post Share on other sites
zaphod 0 Posted August 20, 2007 i use a funktion for comparing arrays, too... but in most cases, a solution with "{_x==_y} count _array" will do the job ... and don't forget there's a "find" option for arrays, that can avoid a complete comparison too. by using these inbuild functions you can reduce the usage of a complete comparison function to a minimum. Regards, zap Share this post Link to post Share on other sites
ArMoGaDoN 0 Posted August 20, 2007 Weird this was then, will have to retest again if I can remember all the code I junked before I changed to repeating trigger instead. I was referring to the dude by editor-name, in a looping script, and it all worked just fine until the respawn, then the respawned just vanished off the scope, running exact same code. Could it have crunched while 'in the nether regions' of life and death between dying and respawning? Perhaps. Will look again. Thanks for the replies guys. Share this post Link to post Share on other sites
thegunnysgt 1 Posted August 21, 2007 You cannot compare arrays using "==" or "!=". You need to compare each pair of elements individually.Eg: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_a = (getmarkerpos "wfirepoint"); ? ((_a select 0 == 0) && (_a select 1 == 0)) : goto "exit" or <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_a = (getmarkerpos "wfirepoint"); _b = [0,0]; ? ((_a select 0 == _b select 0) && (_a select 1 == _b select 1)) : goto "exit" Personally, I use a function to compare arrays. It worked...Thanks. Share this post Link to post Share on other sites
Rawhide 2 Posted August 21, 2007 Hi, I'm also stuck with the same problem. For different purposes, I'm using two scripts for respawning two helicopters and a Harrier. I need to change so that the text in the initialization field and the name of the vehicle exists in the respawned vehicle. Even though I guess the answer is somewhere above in this thread, I don't know where to place what in the two scripts. I'm in the script learning process here... If anyone would be so kind, it would be much appreciated! These are the scripts: The helicopters (mh6a and mh6b) respawn script: Quote[/b] ]?! (local server): exit~3 _vehicle = _this select 0 _delay = _this select 1 _empty = true _disabled = false _moved = false _startpos = getpos _vehicle _startdir = getdir _vehicle _type = typeof _vehicle #waiting ~2 _newpos = getpos _vehicle ?! (_newpos select 0 in _startpos) or not (_newpos select 1 in _startpos): _moved = true ?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not (isnull commander _vehicle): _empty = false ? (isnull driver _vehicle) and (isnull gunner _vehicle) and (isnull commander _vehicle): _empty = true ?! (canmove _vehicle) or (canfire _vehicle): _disabled = true ? (canmove _vehicle) and (canfire _vehicle): _disabled = false ? (_disabled) and (_empty): goto "spawn" ? (_moved) and (_empty): goto "spawn" goto "waiting" #spawn ~_delay ?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not(isnull commander _vehicle): _empty = false ?! (_empty): goto "waiting" deletevehicle _vehicle ~0.5 _newveh = _type createvehicle _startpos _newveh setpos _startpos _newveh setdir _startdir [_newveh, _delay] exec "vehirespawn.sqs" exit The Harrier (har1) respawnscript: Quote[/b] ]//BEGIN vrs.sqf//By KaRRiLLioN //IMPORTANT: ADD A GAMELOGIC NAMED Server //to the mission to prevent multispawn private ["_vcl","_respawndelay","_dir","_pos","_type& quot;,"_run","_crewWait","_wait","_delay"]; if (!local Server) exitWith {}; _vcl = _this; _respawndelay = 10; _dir = Getdir _vcl; _pos = Getpos _vcl; _crewWait = 30; _wait = 0; _type = typeOf _vcl; _run = TRUE; sleep 1; for [{}, {_run}, {_run}] do { while {canMove _vcl && count crew _vcl < 1} do { _wait = Time + _crewWait; sleep 1; }; while {Count crew _vcl > 0 && Alive _vcl} do { _wait = Time + _crewWait; sleep 1; }; while {canMove _vcl && count Crew _vcl < 1 && Time < _wait} do { sleep 1; }; _delay = Time + _respawnDelay; while {!canMove _vcl && count Crew _vcl < 1 && Time < _delay} do { sleep 1; }; if (count Crew _vcl < 1) then { deleteVehicle _vcl; _vcl = _type createVehicle _pos; _vcl setdir _dir; sleep 1; _vcl setvelocity [0,0,0]; _vcl setpos _pos; sleep 1; _vcl setvelocity [0,0,0]; //code to remove bombs and fuel following respawn _vcl setFuel 0.1; _vcl removeMagazine "6Rnd_GBU12_AV8B"; _vcl removeMagazine "300Rnd_25mm_GAU12"; }; }; -Rawhide Share this post Link to post Share on other sites
thegunnysgt 1 Posted August 21, 2007 Well the I am running three scripts for a vehicle that is respawning. I ended up getting the vehicle to respawn and retain its name thanks to Dr. Eyeball. Then the remaining two scripts that I run for the vehicle I have running in a repeating script that is being run in a game logic that is used for the repawn scripts. Hope that helps, but keep in mind that I have not fully tested this myself, from what I have tested it works for me. But you may have something entirely different setup for your mission. Share this post Link to post Share on other sites
Rawhide 2 Posted August 22, 2007 This did the trick for me. Thanks to [ACAT]Shiva who worked it out. Notice the: _name = vehicleVarName _vcl; and _vcl setVehicleVarName _name; <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_vcl","_respawndelay","_dir","_pos","_type","_run","_crewWait","_wait","_delay","_name"]; if (!local Server) exitWith {}; _vcl = _this; _respawndelay = 10; _dir = Getdir _vcl; _pos = Getpos _vcl; _crewWait = 30; _wait = 0; _type = typeOf _vcl; _run = TRUE; sleep 1; for [{}, {_run}, {_run}] do { while {canMove _vcl && count crew _vcl < 1} do { _wait = Time + _crewWait; sleep 1; }; while {Count crew _vcl > 0 && Alive _vcl} do { _wait = Time + _crewWait; sleep 1; }; while {canMove _vcl && count Crew _vcl < 1 && Time < _wait} do { sleep 1; }; _delay = Time + _respawnDelay; while {!canMove _vcl && count Crew _vcl < 1 && Time < _delay} do { sleep 1; }; if (count Crew _vcl < 1) then { _name = vehicleVarName _vcl; deleteVehicle _vcl; _vcl = _type createVehicle _pos; if (_name != "") then { _vcl setVehicleVarName _name; call compile format["%1 = _vcl", _name]; }; //code to remove bombs and fuel following respawn _vcl setFuel 0.1; _vcl removeMagazine "6Rnd_GBU12_AV8B"; _vcl removeMagazine "300Rnd_25mm_GAU12"; }; }; -Rawhide Share this post Link to post Share on other sites
insomnianshadow 0 Posted October 1, 2007 After I got "respawning vehicles being renamed to their initial editor name" working with my respawn script I then ran into troubles getting it to work while being a client connected to a dedicated server... But thanks to sickboy it finally does the trick   (your contributions to this forums are amazing, so keep it up) He proposed me to change this part of the script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vcl setVehicleVarName _name; call compile format["%1 = _vcl", _name]; to: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vcl setVehicleInit format["this setVehicleVarName '%1'; %1 = this", _name]; processInitCommands; Works like a charm now being distributed to all clients So hand this man a beer I take the bill  Share this post Link to post Share on other sites