Jump to content
yawdamper

Question About BIS_fnc_addRespawnPosition

Recommended Posts

Hello. I'm using "BIS_fnc_addRespawnPosition" command in my mission.

 

When I captured to sector, this command will start...Then we can spawn captured sector.

 

But When I Spawn on the captured sector, I always spawn at the same location.I want to "random spawn in the area".

 

I know that must increase the radius that "BIS_fnc_addRespawnPosition" command.

 

This is the question : How can I set BIS_fnc_addRespawnPosition' s radius ???

Share this post


Link to post
Share on other sites


_areaCenter = mySectorModuleObjectName; // Whatever the center of your sector is, probably the sector module?

_radius = 50; // 50 meters

_respawnSpot = _areaCenter getPos [_radius, random 359];

[west,_respawnSpot] call BIS_fnc_addRespawnPosition;

  • Like 1

Share this post


Link to post
Share on other sites
_areaCenter = mySectorModuleObjectName; // Whatever the center of your sector is, probably the sector module?
_radius = 50; // 50 meters

_respawnSpot = _areaCenter getPos [_radius, random 359];

[west,_respawnSpot] call BIS_fnc_addRespawnPosition;

 

Thank you,Its good idea,but I must be changeable.For example when you spawn anywhere,your teammate must spawn another place

Share this post


Link to post
Share on other sites

You'll want to maybe use a custom respawn than since as far as I can tell BIS_fnc_addRespawnPosition doesn't support a radius.  It's either a specific spot or in/near a specific object.

 

You can use the onPlayerRespawn.sqf file to move yourself somewhere random when you respawn.

Share this post


Link to post
Share on other sites

You'll want to maybe use a custom respawn than since as far as I can tell BIS_fnc_addRespawnPosition doesn't support a radius.  It's either a specific spot or in/near a specific object.

 

You can use the onPlayerRespawn.sqf file to move yourself somewhere random when you respawn.

 

Thanks for information. Its #BOHEMIA's fault :) I hope they will fix it at new update.

And ;

 I did it. I used a loop for delete and add new module (random) .

Share this post


Link to post
Share on other sites

Instead of using BIS_fnc_addRespawnPosition when a sector is captured, leave it until a player dies.
All sectors are held in a variable called BIS_fnc_moduleSector_sectors or can be retrieved using [true] call BIS_fnc_moduleSector.
Each sector holds an array of its areas(triggers) in a variable on the sector called "Areas".
Each sector holds the current captured side in a variable on the sector called "Owner".

//initPlayerLocal.sqf

//wait for mission to finish loading
waitUntil { !isNil "bis_fnc_init" };

TAG_fnc_respawnPositions = {
	params[ "_mode", "_sector" ];
	
	//Get player current sector respawn positions
	_respawnPositions = player getVariable [ "respawnPositions", [] ];
	switch ( _mode ) do 
		
		case "ADD" : {
			//Get a random sector area trigger ( as a sector can have multiple areas )
			_sectorTrig = selectRandom ( _sector getVariable "Areas" );
			//Get a random position inside the trigger
			_pos = [ _sectorTrig ] call BIS_fnc_randomPosTrigger;
			//Add a respawn position for this player
			_respawnPos = [ player, _pos ] call BIS_fnc_addRespawnPosition;
			//update current sector respawn positions
			_nul = _respawnPositions pushBack [ _sector, _respawnPos ];
		};
		
		case "REM" : {
			//For each of the players sector respawn positions
			{
				_x params[ "_sec", "_respawnID" ];
				
				//if the sector is the one we are looking for
				if ( _sector isEqualTo _sec ) then {
					//Remove the respawn position
					_respawnID call BIS_fnc_removeRespawnPosition;
					//Update players sector respawns
					_respawnPositions deleteAt _forEachIndex;
				};
			}forEach +_respawnPositions;
		};
		
		case "REM_ALL" : {
			//For each of the players current respawn positions
			{
				_x params[ "_sector", "_respawnID" ];
				//Remove the respawn position
				_respawnID call BIS_fnc_removeRespawnPosition;
			}forEach _respawnPositions;
			//Empty players respawn ARRAY
			_respawnPositions = [];
		};
	};
	
	//Update respawn positions variable on the player
	player setVariable [ "respawnPositions", _respawnPositions ];
};


//When player dies
player addEventHandler [ "Killed", {
	//For every sector
	{
		//If the sector is owned by the players side
		if ( ( _x getVariable "Owner" ) isEqualTo playerSide ) then {
			//Add a respawn position
			[ "ADD", _x ] call TAG_fnc_respawnPositions;
		};
	}forEach BIS_fnc_moduleSector_sectors;
}];


//Once the player has respawned
player addEventHandler [ "Respawn", {
	//Remove all sector respawn positions
	[ "REM_ALL" ] call TAG_fnc_respawnPositions;	
}];

So when the player dies it iterates all known sectors.

If the sector is owned by the players side it chooses a random position within the sectors trigger and places a respawn position for this player.
Once the player respawns all the respawn positions are removed ready to add next time they die.

All sectors also have a scriptedEventHandler that you can subscribe to on the server.

//initServer.sqf

//wait for mission to finish loading
waitUntil { !isNil "bis_fnc_init" };

//Update respawn positions if they change whilst a player is dead
//For every sector
{
	//When the sectors owner changes
	[ _x, "ownerChanged", {
		params[ "_sector", "_owner" ];
		
		//For every client
		{
			//If the player is dead
			if !( alive _x ) then {
				//And the sector is owned by players side
				if ( _owner isEqualTo side group _x ) then {
					//Add a respawn position
					[ "ADD", _sector ] remoteExec [ "TAG_fnc_respawnPositions", _x ];
				}else{
					//Else remove this sectors respawn position
					[ "REM", _sector ] remoteExec [ "TAG_fnc_respawnPositions", _x ];
				};
			};
		}forEach allPlayers;
	}] call BIS_fnc_addScriptedEventHandler;
}forEach BIS_fnc_moduleSector_sectors;

When ever a sector changes ownership, for every dead player add/remove the respawn position based on the players true side (side of group as a dead player is civilian).
Test_Mission

  • Like 3

Share this post


Link to post
Share on other sites

Hi Everyone,

 

I am using the sectors module from the good ol' 2D Editor, but would like the respawn at the sectors to indicate the text I choose and not the coordinates of the VR (see linked picture below). Does anyone know how to do this?

http://steamcommunity.com/sharedfiles/filedetails/?id=732217516

 

I've tried changing the names and description on the sector module, trigger, area with not joy.




			
		

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

×