Safkon 2 Posted March 24, 2021 Hello, I try to create my own custom respawn template (https://community.bistudio.com/wiki/Arma_3:_Respawn) and GUI with list of squads, roles and loadouts. Also I create test mission and set respawn = "BASE"; in description.ext. So, I write script (event handler) onPlayerKilled.sqf, which creates my dialog (GUI) where player can join/create squad, select role and respawn position. Then he click "Respawn" button. Summary steps\flow: Player died onPlayerKilled is invoked My GUI is being created Player choose his loadout and respawn position Player press respawn button My respawn script creates new unit (createUnit), wait 1 second for correct init, give selected loadout to unit and give control to player (selectPlayer) My GUI is closing Player spawned on selected position Now I have several problems with correct player respawn on dedicated server. Here are they: After respawn player loses all tasks If someone kills player again - there is no message in system chat (like somebody kills bot/unit) When a player is in a group led by another player - after respawning, the new unit is controlled by the AI, but the player can shoot and look around, but cannot move I read about last problem in comments for selectPlayer: Quote 1) If you switch to a unit that's not local, control over movement will not be given to you immediately. For example, if you switch to an AI unit whose leader is a player, you will not be able to control the movement of your new avatar, as its control remains with the leader unit. You will however be able to look around while the unit walks automatically. but also I read about locality and multiplayer https://community.bistudio.com/wiki/Multiplayer_Scripting#Locality. In "Locality changes" topic It says: Quote locality can also change in the event of a Team Switch or usage of selectPlayer So, selectPlayer changes locality but it still have problem. Also I check locality by owner command, new unit is local. May be because I use createUnit on player machine. This is my short respawn script without extra code: Spoiler // Gets old player unit _deadUnit = player getVariable "respawn_unit"; // Creates new unit _newUnit = (group player) createUnit [_unitType, _pos, [], 5, "NONE"]; sleep 1; // delay for unit "_newUnit" init // Join new unit to player group [_newUnit] joinSilent (group player); // Switch leader to new unit if player was leader if (_deadUnit == leader _deadUnit) then { (group _deadUnit) selectLeader _newUnit; }; [_deadUnit] joinSilent grpNull; // removes dead unit (was player) from group selectPlayer _newUnit; // gives unit control to player Also default BIS respawn logic don't know about my respawn script and try to respawn player by pre-defined scripts for "BASE" respawn type. And I use terrible hack: setPlayerRespawnTime 900; otherwise BIS default logic spawn player in one of markers "respawn_*". Possible I can solve it by property in custom respawn config (CfgRespawnTemplates) Quote // By default onPlayerKilled and onPlayerRespawn function are spawned // set to 1 to run in unscheduled, called functions MUST NOT return an assignment or respawn will breakisCall = 0; I tried to find any BIS scripts with default respawn logic\functions but without success. Is it possible to create custom respawn template and use some BIS respawn functions, which can tell to engine that I spawned player already? It would solve problems with player group (remove old unit, join new) and new unit issues (control, tasks, etc.) Share this post Link to post Share on other sites
Safkon 2 Posted March 24, 2021 Hmm... I think I must to try use onPlayerRespawn event handler, because it has params: Quote params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"]; So, I have _newUnit which spawned by engine. All that remains is to change loadout and correct position. But I think I can get problem with default respawn logic and player position 🤔 Share this post Link to post Share on other sites
Safkon 2 Posted March 24, 2021 Yes, when I started to use onPlayerRespawn it works better. Engine gives me correct unit controlled by player. I had one problem when unit spawn before player press Respawn button, but I solve it by creating cam and attach to head of dead unit. Also for new unit I disable simulation and moved it to a height of 2000 meters My current onPlayerRespawn script: Spoiler /* newUnit: Object oldUnit: Object respawnType: Number respawnDelay: Number */ params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"]; systemChat "onPlayerRespawn"; _oldPos = position _oldUnit; _oldLoadout = getUnitLoadout _oldUnit; _cam = "camera" camCreate (_oldPos); _cam cameraEffect ["Internal", "Back"]; _cam attachTo [_oldUnit, [0,0,0], "head", true]; _newUnit setPos [_oldPos select 0, _oldPos select 1, 2000]; _newUnit setUnitLoadout _oldLoadout; _newUnit enableSimulation false; player setVariable ["respawn_loadout_temp_unit", _newUnit]; createDialog "SSOT_RespawnDialog"; player setVariable ["respawn_unit", _newUnit]; player setVariable ["respawn_delay", _respawnDelay]; waitUntil { sleep 1; isNull findDisplay 30001 }; _newUnit enableSimulation true; // Reset camera and delete _cam cameraEffect ["terminate","back"]; camDestroy _cam; Share this post Link to post Share on other sites