canuckbrian

Restrict Spawn Selection Based On Corpse Location

6 posts in this topic

Hello,

I posted this over in the Spawning & Loadout forum, but it's not getting much action over there.

I'm looking for some help. I've been trying to get my spawn selection to only show spawn points that are a certain distance away from the player's corpse.

I've been attempting to achieve this by overwriting "ExileClient_gui_selectSpawnLocation_show.sqf", this is the block of code that finds and populates the spawn selection list:

Spoiler

lbClear _listBox;
{
	if (getMarkerType _x == "ExileSpawnZone") then
	{
		_listItemIndex = _listBox lbAdd (markerText _x);
		_listBox lbSetData [_listItemIndex, _x];
	};
}
forEach allMapMarkers;
_numberOfSpawnPoints = {getMarkerType _x == "ExileSpawnZone"} count allMapMarkers;
if (_numberOfSpawnPoints > 0) then 
{
	_randNum = floor(random _numberOfSpawnPoints);
	_randData = lbData [24002,_randNum];
	_randomSpawnIndex = _listBox lbAdd "Random";
	_listBox lbSetData [_randomSpawnIndex, _randData];
};

 

I know what needs to be done... just no idea how to do it. I can read the code and understand what it does, but I cannot write code nearly well enough to do something like this.

When a player dies, according to "ExileClient_object_player_event_onKilled.sqf" it creates a maker with the type of "KIA" and the name of "Death%1" where %1 is the time of death. What needs to happen is while ExileClient_gui_selectSpawnLocation_show.sqf is populating the list of respawn locations, it needs to compare the coordinates of the ExileSpawnZone markers vs the KIA marker and if they're within a certain distance of each other (say 5KM) then don't add it to the list. I'm assuming you could use the getMarkerPos command to get the location of the KIA marker and the ExileSpawnZone marker and compare the distances. I just have no idea how to code this properly.

Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites

I'm new to scripting but might try this: O.o

if (getMarkerType _x == "ExileSpawnZone") && (ExileClientLastDeathMarker distance < 5000) then
	{
		_listItemIndex = _listBox lbAdd (markerText _x);
		_listBox lbSetData [_listItemIndex, _x];
	};

 

Share this post


Link to post
Share on other sites
Advertisement

This is what I get when I use that:

21:43:11 Error in expression <&& (ExileClientLastDeathMarker distance < 5000) then
{
_listItemIndex = _listBox>
21:43:11   Error position: << 5000) then
{
_listItemIndex = _listBox>
21:43:11   Error Invalid number in expression
21:43:11 File mpmissions\Exile.Napf\overwrites\exile_client\code\ExileClient_gui_selectSpawnLocation_show.sqf, line 29

 

Share this post


Link to post
Share on other sites

You get that error because ExileClientLastDeathMarker is not a number but a marker object.

Try this instead

lbClear _listBox;
{
	if (getMarkerType _x == "ExileSpawnZone" && ((getMarkerPos ExileClientLastDeathMarker) distance (getMarkerPos _x)) > 5000) then
	{
		_listItemIndex = _listBox lbAdd (markerText _x);
		_listBox lbSetData [_listItemIndex, _x];
	};
}
forEach allMapMarkers;
_numberOfSpawnPoints = {getMarkerType _x == "ExileSpawnZone" && ((getMarkerPos ExileClientLastDeathMarker) distance (getMarkerPos _x)) > 5000} count allMapMarkers;
if (_numberOfSpawnPoints > 0) then 
{
	_randNum = floor(random _numberOfSpawnPoints);
	_randData = lbData [24002,_randNum];
	_randomSpawnIndex = _listBox lbAdd "Random";
	_listBox lbSetData [_randomSpawnIndex, _randData];
};

 

3 people like this

Share this post


Link to post
Share on other sites

@Janski

Thanks for this. I put it on my test server and started it up, no errors in the server's RPT. I am at work so I can't join it to actually test if it works, but I will when I get home in 9-10 hours. Will report back and let you know.

1 person likes this

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.