Jump to content

Recommended Posts

So I have a script. It is not my script and I believe it was modified form ALiVE or some other mod. this is part of it:

Spoiler

if (isServer) then {

private ["_veh", "_abandonDelay", "_abandonDistance", "_abandonNotification", "_moveDistance", "_deadDelay", "_startLocation",
			"_respawnCount", "_vehInit", "_safeZones", "_dir", "_pos", "_vehtype", "_vehName", "_lastDriver", "_abandonTime", "_deadTime",
			"_originalStartPosition", "_originalStartDirection", "_vehSide", "_notify", "_notifyUnits", "_notifyGroup" ];

_veh = [_this, 0, objNull, [objNull] ] call BIS_fnc_param;
_abandonDelay = ( [_this, 1, 0.25, [0] ] call BIS_fnc_param ) * 60;
_abandonDistance = [_this, 2, 50, [0] ] call BIS_fnc_param;
_abandonNotification = [_this, 3, false, [ false, objNull, grpNull, sideUnknown ] ] call BIS_fnc_param;		//(group), person, side
_moveDistance = [_this, 4, 5, [0] ] call BIS_fnc_param;
_deadDelay = ( [_this, 5, 0.25, [0] ] call BIS_fnc_param ) * 60;
_startLocation = [_this, 6, true, [true] ] call BIS_fnc_param;
_respawnCount = [_this, 7, -1, [0] ] call BIS_fnc_param;
_vehInit = [_this, 8, {}, [{}] ] call BIS_fnc_param;
if ( [_this, 9, false, [true] ] call BIS_fnc_param ) then {
	_veh call _vehInit;
};

 

it is a vehicle respawn script, that checks if the vehicle abandoned, destroyed and so on.

What I cannot understand, what is called by "_veh call _vehInit;"? Because it is clearly a local variable, initialized from parameters with which this function called, and had a "true" or "false" value. How it can be called?

Share this post


Link to post
Share on other sites

If you look at the line where it is initialised then u see that there was used a BIS function. That function does a lookup for the 9th parameter (index 8) of the parameter array (_this) which was passed to the script. Those 9th parameter is just code ([{}]) and code can be just called...

sent from mobile using Tapatalk
 

  • Like 1

Share this post


Link to post
Share on other sites

:smile_o: Thats NSLVR script. See last sentence in OP of this thread

On 07/11/2013 at 11:32 PM, iceman77 said:

@sarogahtyp is correct. It uses the vehicle as passed in param 0 and the code passed in param 8 ( code to be init on respawning vehicle ) but if param 9 is True it will also run the respawn code on passed vehicle immediately.

Saves doing something like this in the vehicles init...

this setVehicleVarName "MyVehicle";
this call BIS_fnc_objectVar;
this setObjectTextureGlobal[ 0, "someTexture" ];

[ this, /*lots of params*/, {
	_this setVehicleVarName "MyVehicle";
	_this call BIS_fnc_objectVar;
	_this setObjectTextureGlobal[ 0, "someTexture" ];
} ] call NSLVR_fnc_vehRespawn;

Where you repeat the code twice, once in init and then again in a code block to repeat for when the vehicle respawns.

Instead...

[ this, /*lots of params*/, {
	_this setVehicleVarName "MyVehicle";
	_this call BIS_fnc_objectVar;
	_this setObjectTextureGlobal[ 0, "someTexture" ];
}, true ] call NSLVR_fnc_vehRespawn;

Code written out once, automatically run on the vehicle as soon as you start the respawn function up.

  • Like 1

Share this post


Link to post
Share on other sites
11 hours ago, Larrow said:

:smile_o: Thats NSLVR script.

Ah, of course. The only hits I got were the EVO GitHub and this topic for some reason. 

Share this post


Link to post
Share on other sites
17 hours ago, Larrow said:

 Thats NSLVR script.

Yes, I think so. But it was modified to meet some respawn conditions.

 

Thank you, everyone, who answered me, that was very kind of you.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×