satexas69 0 Posted April 4, 2007 Below is the respawn script I use : chopperspawn.sqs Because when a chopper respawns, it does NOT keep it's original "NAME" as put in the NAME field, I'd like to assign it upon respawn - In the code below, what do I need to use to make this particular script assign the name "Chopper1" to the respawned unit? (Yes, I understand that this makes it so that ONLY this unit can use this script - due to the fact that names must be unique) <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Call in initline with (120 for 120 seconds, 2 minutes) : ; ; Â [this, 120] exec "chopperspawn.sqs" ; ; Note - This script needs a "GameLogic" trigger named "SERVER" or else spawning will be nuts ; ?! (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 Share this post Link to post Share on other sites
satexas69 0 Posted April 5, 2007 Using that suggestion, I can't seem to get it to work. Syntax Issue? Order of operation issue? Here's a snipit of the last lines of code in the script - with the SetVehicleVarName line being the one that I added : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_newveh = _type createvehicle _startpos _newveh setpos _startpos _newveh setdir _startdir _newveh setVehicleVarName "Heli1" [_newveh, _delay] exec "vehirespawn.sqs" It doesn't ERROR, but it doesn't work by naming the respawned chopper as "HELI1", it's original name. Share this post Link to post Share on other sites
crashdome 3 Posted April 5, 2007 after the line: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_newveh setVehicleVarName "Heli1" you can check if the change has taken effect by using the following code: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint format["Change has occured: %1", (Heli1 == _newveh)] It should display "true" if it works correctly. If you do not see "true" try placing a one second delay before the renaming and maybe even a one second delay before the hint. I am going to guess, if it says "true" there is a bug in your code elsewhere. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted April 6, 2007 On the same tack as crash here, do not underestimate the power of the format command. Simple usage: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _x = 123123; _y = player; _z = "qwer"; _string = format["my text %1 %2 %3", _x, _y, _z]; player sideChat _string; Output: "my text 123123 alpha black 1-1 qwer" If one of the variables you pass the format command is a null value, it should return (roughly) "scalar bool array 0x0000000" Format is about the most useful thing for debugging output you can find. The one thing I disagree with is using it in a hint box. Sidechat, or globalChat is better. This lets you have up to (I think) 8 lines of debugging output on the screen at any one time. simple example: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _newveh setVehicleVarName "Heli1" player sideChat format["heli: %1", Heli1] If heli1 has been set, then it will output the ingame name of the helicopter. If not, it will output the scaler bool array garbage. Share this post Link to post Share on other sites