Jump to content
Rosso777

PUID Spawning configuration

Recommended Posts

Hey guys. I run a small private dedicated server for my family, so there's only 3 of us who play on the server. I am trying to reconfigure the respawn so that it identifies the player's UID and then spawns them in their own personal spawn location (within an array of possibilities). I know the general idea of how the IF-THEN format should go, but I am braindead on how to configure this. (Admittedly, this is a (albeit SAD) deconstruction of the ExileMod respawn code, if it looks familiar to anyone).

 

So, I have the list for each player's camps, identified by the _private PLAYERNAMECampSpawns but I'm not sure on how to set that to an array that the system will know to 1) identify the player by UID, then 2) identify their list of potential spawn points. I was going to go down the route of: _spawnAreaPosition = getMarkerPos _PLAYERNAMECampSpawns for each player (there's only three of us so no major effort), but I know there is a way to keep it cleaner and more efficient (maybe at this point in my learning I shouldn't care about such things and just work on getting things to WORK 🙂). 

If anyone can offer any guidance here, even a BIKI link to get me a bit further, I'd be grateful. Thanks as always.

 

Note: This is just a PIECE of the script; didn't want to be obnoxious with the post size.

 

Spoiler

 

private["uid","_sessionID","_requestingPlayer","_spawnLocationMarkerName","_newPlayer","_accountData","_direction","_position","_spawnAreaPosition","_spawnAreaRadius","_player"];


_sessionID = _this select 0;
_requestingPlayer = _this select 1;
_spawnLocationMarkerName = _this select 2;
_newPlayer = _this select 3;
_accountData = _this select 4;
_UID = _this select 5;
_direction = random 360;

 

    _UID = getPlayerUID _requestingplayer;
    _spawnAreaPosition = getMarkerPos _CampSpawns;
    _spawnAreaRadius = getNumber(configFile >> "CfgSettings" >> "SpawnSettings" >> "spawnZoneRadius");
    _position = [_spawnAreaPosition, _spawnAreaRadius] call Client_util_math_getRandomPositionInCircle;
    while {surfaceIsWater _position} do
    {
        _position = [_spawnAreaPosition, _spawnAreaRadius] call Client_util_math_getRandomPositionInCircle;
    };
};

 

private _RossCampSpawns = selectRandom
                                            [
                                                 "1000, 1000, 0",

                                                  "2000, 2000, 0"
                                            ];

 

private _BertCampSpawns = selectRandom
                                            [

                                                 "3000, 3000, 0",

                                                  "4000, 4000, 0"
                                            ];

 

private _PopCampSpawns = selectRandom
                                            [

                                                 "5000, 5000, 0",

                                                  "6000, 6000, 0"
                                            ];

 

Share this post


Link to post
Share on other sites

Well, if it's only 3 of you you may as well keep it simple. Run this in onPLayerRespawn.sqf:

switch (getPlayerUID player) do {
	case "3168468746512": {player setPos (selectRandom [_pos1,_pos2]);};
	case "5413546843212": {player setPos (selectRandom [_pos3,_pos4]);};
	case "6544164161261": {player setPos (selectRandom [_pos5,_pos6]);};
	default {player setPos [0,0,0];};
};

Just a point too, your use of selectRandom is going to return a string, but positions are arrays. So it should be written like this:

selectRandom [[1000,2000,0],[3000,4000,0]]

 

Share this post


Link to post
Share on other sites
50 minutes ago, beno_83au said:

Well, if it's only 3 of you you may as well keep it simple. Run this in onPLayerRespawn.sqf:


switch (getPlayerUID player) do {
	case "3168468746512": {player setPos (selectRandom [_pos1,_pos2]);};
	case "5413546843212": {player setPos (selectRandom [_pos3,_pos4]);};
	case "6544164161261": {player setPos (selectRandom [_pos5,_pos6]);};
	default {player setPos [0,0,0];};
};

Update: Okay, so I created a file named onPlayerRespawn.sqf and added it to my mission file. It literally ONLY has the following code in it (a modified version of the above). When a player respawns, he respawns ANYWHERE on the map randomly, including outside the borders. For the test, I am p1. Not sure what I am missing.

My version:

 

switch (getPlayerUID player) do {
    case "7656119797729xxxx": {player setPos (selectRandom [[1291,12685,0],[16490,19125,0]]);};      //p1
    case "7656119800446xxxx": {player setPos (selectRandom [_pos3,_pos4]);};    //p2
    case "7656119808028xxxx": {player setPos (selectRandom [_pos5,_pos6]);};    //p3
    default {player setPos [7000,7000,0];};
};

@beno_83au, do I need to leave it as _pos1, _pos2... and then identify those _pos as specific coords?

Share this post


Link to post
Share on other sites
55 minutes ago, Rosso777 said:

do I need to leave it as _pos1, _pos2... and then identify those _pos as specific coords?

No, you can just put the positions in as you have done there for p1.

 

Quote

When a player respawns, he respawns ANYWHERE on the map randomly, including outside the borders.

Is there any other part of your code that's moving them? Or maybe it's something in the Exile coding that's doing it? It's been a while since I ran an Exile server though (ran a PvE one for my kids when they pretty young) and I can't remember how their spawning works. If you want to confirm for yourself that the switch does work though, create a blank mission with the onPlayerRespawn.sqf and play it as an MP game with respawns. But for your server, spawning the switch and putting a sleep infront of it should patch your problem if you can't find the source:

 

nul = [] spawn {
	sleep 5; //whatever is the smallest amount of time that works, probably a lot less than 5 seconds though
	switch (getPlayerUID player) do {
		case "3168468746512": {player setPos (selectRandom [_pos1,_pos2]);};
		case "5413546843212": {player setPos (selectRandom [_pos3,_pos4]);};
		case "6544164161261": {player setPos (selectRandom [_pos5,_pos6]);};
		default {player setPos [0,0,0];};
	};
};

 

Share this post


Link to post
Share on other sites

Tried the above code and still no luck. I haven’t gone as far as creating a fresh mission and testing the switch, but I will try to this weekend. 

Share this post


Link to post
Share on other sites

UPDATE: I discovered that my previous issue which would not allow the aforementioned suggestion to work was that my Mission.sqm was missing a SpawnZone. It had a SpawnZoneIcon but no actual zone. I am hoping to test the above code this weekend and report back results.

  • Like 1

Share this post


Link to post
Share on other sites

UPDATE 2: The code above works perfectly. The only reason it does not work for my situation is that it causes each player to spawn at one of their "personal" locations every time they join the server (instead of only when they die/respawn).

 

Is there a way to make this script work only after a player actually dies/respawns?

Share this post


Link to post
Share on other sites

It's been a good while since I've had my head in Exile scripts, but it sounds like it's forcing respawn when the player joins the server. If that's the case then maybe adding a Killed EH in onPlayerRespawn would work. So that the player joins, the get force respawned, then the EH adds itself......

 

onPlayerRespawn.sqf

player addEventHandler ["Killed",{
	waitUntil {lifeState player != "DEAD-RESPAWN"};
	//code
}];

You might need to mess around with the wait condition a little to get it right, but that should be a good start.

  • 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

×