Jump to content
Robustcolor

addRespawnPosition duplicating and overwrite names

Recommended Posts

addRespawnPosition function duplicates and overwrite names and it also replaces the editor placed respawn_west markers name when a vehicle is destroyed in the respawn menu.

 

I have two markers on the editor called respawn_west and respawn_west1.

 

I'm also creating different vehicles then adding respawnPositions to them from scripts.

variable _veh is not used in same script.

 

I've tried both of these

_rsp = [west, _veh, "Helicopter"] call BIS_fnc_addRespawnPosition;
_rsp1 = [west, _veh, "Boat"] call BIS_fnc_addRespawnPosition;
_rsp2 = [west, _veh, "Car"] call BIS_fnc_addRespawnPosition;

[west, _veh, "Helicopter"] call BIS_fnc_addRespawnPosition;
[west, _veh, "Boat"] call BIS_fnc_addRespawnPosition;
[west, _veh, "Car"] call BIS_fnc_addRespawnPosition;

When a vehicle is destroyed.

waitUntil {!alive _veh};
[_veh] call BIS_fnc_removeRespawnPosition;

This don't work properly.

Share this post


Link to post
Share on other sites
1 hour ago, Robustcolor said:

This don't work properly

this tells nothing!

 

Also your usage of BIS_fnc_removeRespawnPosition is wrong. read its biki entry.

Share this post


Link to post
Share on other sites

I will try this

 

_rsp = [west, _veh, "Helicopter"] call BIS_fnc_addRespawnPosition;

 

waitUntil {!alive _veh};

 

_rsp call BIS_fnc_removeRespawnPosition;

 

Also, i remember using a script command in initServer for showing the respawnPosition markers a while back, can't find it again. Anyone know?

Share this post


Link to post
Share on other sites
On 7/4/2021 at 9:32 AM, Robustcolor said:

Also, i remember using a script command in initServer for showing the respawnPosition markers a while back, can't find it again. Anyone know?

 

Are you perhaps thinking about the "MenuPosition" respawn template?
https://community.bistudio.com/wiki/Arma_3:_Respawn#Official_Templates

 

Or do you just want to add markers to them on the map? If so any old "tracking marker"-script will do:

Spoiler

// Run on server only
[
	[_veh, _name], 
	{
		params ["_veh", ["_name", ""]];

		private _m = createMarkerLocal [ "resp_" + (_veh call BIS_fnc_objectVar), getPos _veh];

		_m setMarkerTypeLocal "mil_flag";
		_m setMarkerTextLocal _name;
		_m setMarkerColorLocal "ColorBLUFOR";

		while {alive _v} do {
			sleep 0.5; // Change to update as often as you like
			_m setMarkerPosLocal getPos _veh;
		};

		deleteMarkerLocal _m;
	}
] remoteExec ["spawn", [0, -2] select isDedicated, _veh];


// Or if you want to make it CfgRemoteExec safe:
// 		Step 1: Define the remoteExec'd code as a function using the Functions Library, see: https://community.bistudio.com/wiki/Arma_3:_Functions_Library
//		Step 2: On the server exec this
[_veh, _name] remoteExec ["YOUR_fnc_namehere", [0, -2] select isDedicated, _veh];

Note if you are using this for ALOT of vehicles (unlikely); To avoid clogging up the JIP-queue and scheduler I would update all markers in a single loop instead.

 

Share this post


Link to post
Share on other sites

Question, Instead of using this code below i would like to pass my variable _rsp into an killed eventHandler for the created vehicle, how can i fetch the variable inside the EH?

_rsp = [west, _veh, "Helicopter"] call BIS_fnc_addRespawnPosition;
waitUntil {!alive _veh};
_rsp call BIS_fnc_removeRespawnPosition;

 

Example.

_rsp = [west, _veh, "Helicopter"] call BIS_fnc_addRespawnPosition;

_veh addEventHandler ["Killed", {
	_rsp call BIS_fnc_removeRespawnPosition;
}];

 

Share this post


Link to post
Share on other sites

_rsp is a local variable which is not known in a EH.

You have to use a global variable

  • Like 1

Share this post


Link to post
Share on other sites
_veh setVariable ["rsp", [west, _veh, "Helicopter"] call BIS_fnc_addRespawnPosition];
_veh addEventHandler ["Killed", {
	params ["_veh"];
	(_veh getVariable ["rsp,[]]) call BIS_fnc_removeRespawnPosition;
}];

 

  • Like 1

Share this post


Link to post
Share on other sites
28 minutes ago, pierremgi said:

_veh setVariable ["rsp", [west, _veh, "Helicopter"] call BIS_fnc_addRespawnPosition];
_veh addEventHandler ["Killed", {
	params ["_veh"];
	(_veh getVariable ["rsp,[]]) call BIS_fnc_removeRespawnPosition;
}];

 

I was just going to ask if i could attach it to the object in this case _veh with a setVariable command.

 

@pierremgi How can i check if the specific _veh has this variable you wrote with getVariable? I'm just familiar with true/false or isNil with set/get variable.

is a if (!isNil {_veh getVariable "rsp"}) then {}; enough?

 

Thanks.

Share this post


Link to post
Share on other sites

Yes! Anyway, the getVariable fails safe with [] call BIS_fnc_removeRespawnPosition  ([] as default).

Sorry for the typo. I omitted a quote (corrected).

  • Like 1

Share this post


Link to post
Share on other sites
51 minutes ago, pierremgi said:

Yes! Anyway, the getVariable fails safe with [] call BIS_fnc_removeRespawnPosition  ([] as default). 

So if i understand this correct is that _veh setVariable ["rsp", [west, _veh, "Helicopter"] call BIS_fnc_addRespawnPosition]; causes no error with (!isNil {_veh getVariable "rsp"}) check?

Share this post


Link to post
Share on other sites

... And no error without it, as far as you write/test:  _veh getVariable ["rsp",[]]

  • Like 1

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

×