Jump to content
Sign in to follow this  
GabeGuitarded

RespawnInventory Object onPlayerRespawn Property

Recommended Posts

Hey guys,

I've been trying for a few hours (yes, I completely exhausted my search-fu before posting) to get each respawn kit option to call a different script on respawning. This looks like the right way, but I'm not sure if the path I'm giving is wrong, or if the functionality isn't there anymore. Here's the description.ext code:

#define INSTANT 2
#define BASE 3

//Respawn Type
respawn = BASE;

//Respawn Wait Time (s)
respawnDelay = 10;

//Respawn Template Scripts
respawnTemplatesWest[] = { "MenuPosition", "MenuInventory" };

class CfgRespawnInventory
{

[indent]class WEST1
{
[indent]displayName = "CF Spotter";
onPlayerRespawn = "CallCF0.sqf";[/indent]


};
class WEST2
{


[indent]displayName = "CF Sniper";
onPlayerRespawn = "CallCF1.sqf";[/indent]


};
class WEST3
{


[indent]displayName = "CF Helo Pilot";
onPlayerRespawn = "CallCF2.sqf";[/indent]


};[/indent]
};

And here's the folder layout:

MPMissions\CF%20CAS.Altis.pbo\CAFloadouts.sqf

MPMissions\CF%20CAS.Altis.pbo\CallCF0.sqf <--

MPMissions\CF%20CAS.Altis.pbo\CallCF1.sqf <-- these guys refuse to run (no compile errors, they just aren't getting called)

MPMissions\CF%20CAS.Altis.pbo\CallCF2.sqf <--

MPMissions\CF%20CAS.Altis.pbo\description.ext

MPMissions\CF%20CAS.Altis.pbo\init.sqf

MPMissions\CF%20CAS.Altis.pbo\mission.sqm

MPMissions\CF%20CAS.Altis.pbo\RespawnScripts <--- this was where I intended to put the CallCF scripts

Is this actually functional, or is the wiki entry wrong? I'd like to use this setup if it is possible as it makes it easy to keep things portable/modular. If not, pointing me in the direction of the standard practice for accomplishing this would be much appreciated.

Thanks in advance.

Edited by GabeGuitarded

Share this post


Link to post
Share on other sites

I'll paste here my scripts:

description.ext


respawn = "BASE";
respawnDelay = 8;
respawnDialog = 1;
respawnTemplates[] = {"Wave","MenuInventory"};

class CfgRespawnInventory
{
class EE
{
	displayName = "Explosives"; // Name visible in the menu
	icon = "icons\explosion.paa"; // Icon displayed next to the name

	// Loadout definition, uses same entries as CfgVehicles classes
	weapons[] = {
		"srifle_DMR_01_ACO_F",
		"Binocular"
	};
	magazines[] = {
		"10Rnd_762x51_Mag",
		"10Rnd_762x51_Mag",
		"10Rnd_762x51_Mag",
		"10Rnd_762x51_Mag",
		"10Rnd_762x51_Mag",
		"10Rnd_762x51_Mag",
		"10Rnd_762x51_Mag",
		"HandGrenade",
		"APERSTripMine_Wire_Mag",
		"APERSTripMine_Wire_Mag",
		"ATMine_Range_Mag",
		"DemoCharge_Remote_Mag",
	};
	items[] = {
		"FirstAidKit",
		"MineDetector",
		"Toolkit",
	};
	linkedItems[] = {
		"V_Chestrig_khk",
		"H_Watchcap_blk",
		"ItemMap",
		"ItemCompass",
		"ItemWatch",
		"ItemRadio",
	};
	uniformClass = "U_I_CombatUniform";
	backpack = "B_AssaultPack_mcamo";
};

init.sqf

[west, "EE"] call BIS_fnc_addRespawnInventory;

onPlayerRespawn.sqf

if (player == nameoftheunit) then {
script
};

Share this post


Link to post
Share on other sites

Thanks, it looks like that's what I'll have to do for now. Although what I'm aiming to do is get a different function called for each loadout class on the respawn event. The difficulty is that I want to build the loadouts from SQF script rather than typing everything in description.ext, and the loadouts need to be selectable via RespawnInventory.

From the wiki's Respawn page (https://community.bistudio.com/wiki/Arma_3_Respawn):

class CfgRespawnTemplates
{
// Class used in respawnTemplates entry
class myTag_beacon
{
	// Function or script executed upon death. Parameters passed into it are the same as are passed into onPlayerKilled.sqf file


	onPlayerKilled = "\myAddon\scripts\respawnBeacon.sqf";

	// Function or script executed upon respawn. Parameters passed into it are the same as are passed into onPlayerRespawn.sqf file

[b]--> like this, but it doesn't seem to work (is it no longer functional?)[/b]
	onPlayerRespawn = "\myAddon\scripts\respawnBeacon.sqf"; 

	// Default respawn delay (can be overwitten by description.ext entry of the same name)
	respawnDelay = 20;
};
class Spectator
{
	onPlayerRespawn = "BIS_fnc_respawnSpectator";
};
};

Edited by GabeGuitarded

Share this post


Link to post
Share on other sites
Thanks, it looks like that's what I'll have to do for now. Although what I'm aiming to do is get a different function called for each loadout class on the respawn event. The difficulty is that I want to build the loadouts from SQF script rather than typing everything in description.ext, and the loadouts need to be selectable via RespawnInventory.

From the wiki's Respawn page (https://community.bistudio.com/wiki/Arma_3_Respawn):

class CfgRespawnTemplates
{
// Class used in respawnTemplates entry
class myTag_beacon
{
	// Function or script executed upon death. Parameters passed into it are the same as are passed into onPlayerKilled.sqf file


	onPlayerKilled = "\myAddon\scripts\respawnBeacon.sqf";

	// Function or script executed upon respawn. Parameters passed into it are the same as are passed into onPlayerRespawn.sqf file

[b]--> like this, but it doesn't seem to work (is it no longer functional?)[/b]
	onPlayerRespawn = "\myAddon\scripts\respawnBeacon.sqf"; 

	// Default respawn delay (can be overwitten by description.ext entry of the same name)
	respawnDelay = 20;
};
class Spectator
{
	onPlayerRespawn = "BIS_fnc_respawnSpectator";
};
};

I'm sorry I've never used this command. But you could do the following:

if player has X weapon/item then exec script. I suppose that each loadout has a unique weapon/item.

Share this post


Link to post
Share on other sites
I'm sorry I've never used this command. But you could do the following:

if player has X weapon/item then exec script. I suppose that each loadout has a unique weapon/item.

Yeah that's probably the only course of action without getting documentation on that property of RespawnTemplates from BIS. I'm thinking just spawn them with empty inventory except for one very peculiar item, then work it with a switch statement in onPlayerRespawn or set up an event handler for the Respawn event if I need it to work on AI's (this is what I'm doing now).

Loadouts in description.ext:

cfgRespawnTemplates
{

[indent]class WEST1
{
[indent]displayName = "Assault1";
linkedItems[] = { "V_TacVest_brn" };
[/indent]


};
class WEST2
{


[indent]displayName = "Assault2";
linkedItems[] = { "V_tacVest_oli" };[/indent]


};[/indent]
};

In any unit's editor initialization:

this addEventHandler ["Respawn", { null = _this execVM "onAllRespawn.sqf"; } ];

onAllRespawn.sqf is my user-created script. The name could be anything, in any subfolder.

And in onAllRespawn.sqf you could do something like:

private [ "_cNewUnit", "_sScriptName" ];
_cNewUnit = _this select 0;
_sScriptName = "loadoutScript.sqf"; //some other user-made script to handle detailed loadout construction (i.e. with items added specifically to vest, uniform, backpack)

//check if _newUnit has no items (meaning he selected a loadout from the menu, and was meant to be affected by this script
if (count items _newUnit == 0) then
{

[indent]switch (vest _newUnit) //in this case we are using the vest to differentiate loadouts because there are a fair amount of them to choose from, but this could be anything
{
[indent]case "V_TacVest_brn":
{
[indent][_newUnit, 0] execVM _sScriptName;[/indent]


};
case "V_TacVest_oli":
{


[indent][_newUnit, 1] execVM _sScriptName;[/indent]


};[/indent]
};[/indent]
};

Edited by GabeGuitarded

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
Sign in to follow this  

×