Jump to content
Sign in to follow this  
Azola21

problems with onplayerrespawn.sqf

Recommended Posts

Hello, I am having an issue where my onplayerrespawn.sqf script is wiping currently logged in players gear and adding the respawn loadout to them whenever a new player joins and respawns. I am not sure what the issue is but I thought that maybe it is because the script is executing server wide rather than locally and just on the player.

 

Here is my script. It is pretty basic.

player enableFatigue false;
player enableStamina false;

player addBackpack "TFA_assault_grn";
player addItemToBackpack "rvg_canOpener";
player addItemToBackpack "rvg_canteenEmpty";
player addItemToBackpack "rvg_purificationTablets";
player addItemToBackpack "rvg_beans";
player addItemToBackpack "rvg_flare";
player addItemToUniform "Chemlight_blue";
player addItemToUniform "FirstAidKit";
player addWeapon "hlc_pistol_Mk25TR"; 
player addHandgunItem "hlc_muzzle_Octane9"; 
player addHandgunItem "hlc_acc_TLR1";
player addMagazines ["hlc_15Rnd_9x19_B_P226", 5];

 

Share this post


Link to post
Share on other sites

No idea why it is doing that. I don't use that file but EHs instead. Try this (put in init.sqf):

player addEventHandler ["Respawn",
{
	// delete dead corpse - remove or comment the line out if you don't want to
	deleteVehicle (_this select 1);
	(_this select 0) enableFatigue false;
	(_this select 0) enableStamina false;
	(_this select 0) addBackpack "TFA_assault_grn";
	{
		(_this select 0) addItemToBackpack _x;
	} forEach ["rvg_canOpener", "rvg_canteenEmpty", "rvg_purificationTablets", "rvg_beans", "rvg_flare"];
	{
		(_this select 0) addItemToUniform _x;
	} forEach ["Chemlight_blue", "FirstAidKit"];
	// add magazines first so one loads in weapon (if that's what you want - else do it the other way)
	(_this select 0) addMagazines ["hlc_15Rnd_9x19_B_P226", 5];
	(_this select 0) addWeapon "hlc_pistol_Mk25TR";
	{
		(_this select 0) addHandgunItem _x;
	} forEach ["hlc_muzzle_Octane9", "hlc_acc_TLR1"];
	(_this select 0) addHandgunItem "hlc_muzzle_Octane9"; 
	(_this select 0) addHandgunItem "hlc_acc_TLR1";
};

 

Share this post


Link to post
Share on other sites
5 minutes ago, HazJ said:

No idea why it is doing that. I don't use that file but EHs instead. Try this (put in init.sqf):


player addEventHandler ["Respawn",
{
	// delete dead corpse - remove or comment the line out if you don't want to
	deleteVehicle (_this select 1);
	(_this select 0) enableFatigue false;
	(_this select 0) enableStamina false;
	(_this select 0) addBackpack "TFA_assault_grn";
	{
		(_this select 0) addItemToBackpack _x;
	} forEach ["rvg_canOpener", "rvg_canteenEmpty", "rvg_purificationTablets", "rvg_beans", "rvg_flare"];
	{
		(_this select 0) addItemToUniform _x;
	} forEach ["Chemlight_blue", "FirstAidKit"];
	// add magazines first so one loads in weapon (if that's what you want - else do it the other way)
	(_this select 0) addMagazines ["hlc_15Rnd_9x19_B_P226", 5];
	(_this select 0) addWeapon "hlc_pistol_Mk25TR";
	{
		(_this select 0) addHandgunItem _x;
	} forEach ["hlc_muzzle_Octane9", "hlc_acc_TLR1"];
	(_this select 0) addHandgunItem "hlc_muzzle_Octane9"; 
	(_this select 0) addHandgunItem "hlc_acc_TLR1";
};

 

Would it be safer to do it in iniplayerlocal or should init be fine?

Cheers by the way I will test this now.

Share this post


Link to post
Share on other sites

Either should work really.

Share this post


Link to post
Share on other sites

Hmm weird, the player respawns with nothing now.Knowing me i am probably doing something wrong.

Share this post


Link to post
Share on other sites

Let me go test, stand by. Ah, my bad! Sorry. I missed ]; at end of that.

player addEventHandler ["Respawn",
{
	// delete dead corpse - remove or comment the line out if you don't want to
	deleteVehicle (_this select 1);
	(_this select 0) enableFatigue false;
	(_this select 0) enableStamina false;
	(_this select 0) addBackpack "TFA_assault_grn";
	{
		(_this select 0) addItemToBackpack _x;
	} forEach ["rvg_canOpener", "rvg_canteenEmpty", "rvg_purificationTablets", "rvg_beans", "rvg_flare"];
	{
		(_this select 0) addItemToUniform _x;
	} forEach ["Chemlight_blue", "FirstAidKit"];
	// add magazines first so one loads in weapon (if that's what you want - else do it the other way)
	(_this select 0) addMagazines ["hlc_15Rnd_9x19_B_P226", 5];
	(_this select 0) addWeapon "hlc_pistol_Mk25TR";
	{
		(_this select 0) addHandgunItem _x;
	} forEach ["hlc_muzzle_Octane9", "hlc_acc_TLR1"];
	(_this select 0) addHandgunItem "hlc_muzzle_Octane9"; 
	(_this select 0) addHandgunItem "hlc_acc_TLR1";
}];

 

Share this post


Link to post
Share on other sites
5 minutes ago, Azola21 said:

Hmm weird, the player respawns with nothing now.Knowing me i am probably doing something wrong.

Try now. Just updated my above post!

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  

×