Jump to content
Sign in to follow this  
silentwisher

Players Loose Access To Bis load-out script

Recommended Posts

So not sure if this is the right forum area.

So whenever our players join the server most of the time they have access to the BIS load-out script. Sometimes however, some players dont see it as an option at all or loose the option after die-ing.

This is what the script is in our init.sqf :

{
   _x allowDamage false;
   _x addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}];
} forEach nearestObjects [getpos player,["B_supplyCrate_F"],15000];

This is our initPlayerLocal.sqf that makes fatigue go away. So would it fix it, if we put the above script in this as well. And if so, how would I go about it?

player enableFatigue false;
player addMPEventhandler ["MPRespawn", {player enableFatigue false}];

Share this post


Link to post
Share on other sites
So not sure if this is the right forum area.

So whenever our players join the server most of the time they have access to the BIS load-out script. Sometimes however, some players dont see it as an option at all or loose the option after die-ing.

This is what the script is in our init.sqf :

{
   _x allowDamage false;
   _x addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}];
} forEach nearestObjects [getpos player,["B_supplyCrate_F"],15000];

This is our initPlayerLocal.sqf that makes fatigue go away. So would it fix it, if we put the above script in this as well. And if so, how would I go about it?

player enableFatigue false;
player addMPEventhandler ["MPRespawn", {player enableFatigue false}];

well tbh I think it would be a lot simpler if you just manually add the addAction to each of the supplycrates, that should fix the issue.

but the only other way that I can think off the top of my head is to make a function and then spawn it with BIS_fnc_MP. Or use BIS_fnc_spawn in tandem with BIS_fnc_MP. But still I suggest just using the 1st method which should definitely be a lot more stable.

---------- Post added at 12:31 ---------- Previous post was at 12:29 ----------

OH another thing is we could make it that the addAction is on the player but the condition side could make it that what ever the player is looking at has to be a supplycrate.

player addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];

simply add it to your init.sqf

---------- Post added at 12:44 ---------- Previous post was at 12:31 ----------

oh and along side add just below that addAction

player addEventHandler ["Respawn", {
(_this select 0) addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
}];

Share this post


Link to post
Share on other sites
well tbh I think it would be a lot simpler if you just manually add the addAction to each of the supplycrates, that should fix the issue.

This is the answer.

But for future reference, when a player respawns they lose everything, their gear, their position (unless you set it so they respawn where they died), and all script-added actions. The only thing they keep is event handlers that have been added to them. The reason they lose the action when they respawn is because you never added the action back after they respawn.

player addMPEventhandler ["MPRespawn",
{
player enableFatigue false;

_x addAction ["<t color='#ff1111'>BIS Arsenal</t>",
{
	["Open",true] spawn BIS_fnc_arsenal;
}];
}];

Share this post


Link to post
Share on other sites

Awesome thanks for the help guys! All seems to be working. This is what my init looks like:

{
   _x allowDamage false;
   _x addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}];
} forEach nearestObjects [getpos player,["B_supplyCrate_F"],15000];

player addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
player addEventHandler ["Respawn", {
   (_this select 0) addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
}];  

////////// ADV_Zeus-Script by Belbo start //////////
if (isServer) then 
{
	//CuratorModuleName = your curator module name; true = boolean, if civilians should be editable by zeus as well - set to false if you don't want civilians to be editable.
[zeus,true] execVM "ADV_zeus.sqf";
};
////////// ADV_Zeus-Script by Belbo end //////////

Edited by silentwisher

Share this post


Link to post
Share on other sites

So there are three options

1. Manually add the addAction to each of the crates in the mission editor by using this in there init line

this addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; this allowDamage false;

2. Use BIS_fnc_MP and create a function to work in tandem or use BIS_fnc_MP and BIS_fnc_spawn.

3. Use this in your init.sqf and it will allow the player to use any supply crate in the mission.

player addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
player addEventHandler ["Respawn", {
   (_this select 0) addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
}]; 

4. Or use what DreadedEntity said but although I don't think it will work but I may be wrong.

Share this post


Link to post
Share on other sites
Or use what DreadedEntity said but although I don't think it will work but I may be wrong.

I was just repeating what you said.

Out of the 4 options given by Lala14, #1 would be the easiest to do, #3 the fastest to implement.

Share this post


Link to post
Share on other sites
Awesome thanks for the help guys! All seems to be working. This is what my init looks like:

{
   _x allowDamage false;
   _x addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}];
} forEach nearestObjects [getpos player,["B_supplyCrate_F"],15000];

player addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
player addEventHandler ["Respawn", {
   (_this select 0) addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
}];  

////////// ADV_Zeus-Script by Belbo start //////////
if (isServer) then 
{
	//CuratorModuleName = your curator module name; true = boolean, if civilians should be editable by zeus as well - set to false if you don't want civilians to be editable.
[zeus,true] execVM "ADV_zeus.sqf";
};
////////// ADV_Zeus-Script by Belbo end //////////

Well with the posted quoted here, all seems to be working now. I will do a full test tomorrow during an OP. As of now I had a member join and die/respawn with no issues now.

Share this post


Link to post
Share on other sites

well actually now that you mentioned that @DreadedEntity it would work if it was placed into the forEach.

anyway @silentWisher. It would most likely be doubling up on actions on the boxes since your giving the addAction to the box and the addAction to the player.

so now here are the two options if you want to go with the init.sqf

option 1 - My Option #3

{
   _x allowDamage false;
} forEach nearestObjects [getpos player,["B_supplyCrate_F"],15000];

player addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
player addEventHandler ["Respawn", {
   (_this select 0) addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
}];  

////////// ADV_Zeus-Script by Belbo start //////////
if (isServer) then 
{
	//CuratorModuleName = your curator module name; true = boolean, if civilians should be editable by zeus as well - set to false if you don't want civilians to be editable.
[zeus,true] execVM "ADV_zeus.sqf";
};
////////// ADV_Zeus-Script by Belbo end //////////

option 2 - DeadedEntity

{
   _x allowDamage false;
   _x addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}];
   player addEventhandler ["Respawn", {      
       _x addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; 
   }];  
} forEach nearestObjects [getpos player,["B_supplyCrate_F"],15000];

////////// ADV_Zeus-Script by Belbo start //////////
if (isServer) then 
{
	//CuratorModuleName = your curator module name; true = boolean, if civilians should be editable by zeus as well - set to false if you don't want civilians to be editable.
[zeus,true] execVM "ADV_zeus.sqf";
};
////////// ADV_Zeus-Script by Belbo end //////////

Share this post


Link to post
Share on other sites

You guys want it to be too complicated, all you have to do is put this in init.sqf:

//all players run init.sqf, even JIP if I'm not mistaken
player addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
player addEventHandler ["Respawn", {
(_this select 0) addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];
//whenever unit respawns this adds the action back
}];

Share this post


Link to post
Share on other sites

So we are doing an OP as we speak, and we had to restart the lobby two times in order for it to work. After that it seems ok. Any idea on why we had issues the first two times?

Share this post


Link to post
Share on other sites
So we are doing an OP as we speak, and we had to restart the lobby two times in order for it to work. After that it seems ok. Any idea on why we had issues the first two times?

You're trying to add the EH and addAction to the player object before the player variable has been initialized on the clients machine. Regarding the restarts, by the time everyone's in and you've restarted, player variable has became valid on all client machines. Thus, it "works fine"... until another person JIPs.

Fix:

if (!isDedicated) then {
waitUntil {!(isNull player) && {time > 0}}; //JIP
player addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
player addEventHandler ["Respawn", {
	(_this select 0) addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];
}];  
};

Edited by Iceman77

Share this post


Link to post
Share on other sites
You're trying to add the EH and addAction to the player object before the player variable has been initialized on the clients machine. Regarding the restarts, by the time everyone's in and you've restarted, player variable has became valid on all client machines. Thus, it "works fine"... until another person JIPs.

Fix:

if (!isDedicated) then {
waitUntil {!(isNull player) && {time > 0}}; //JIP
player addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];  
player addEventHandler ["Respawn", {
	(_this select 0) addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},[],9,true,true,'','cursorTarget isKindOf "B_supplyCrate_F"'];
}];  
};

This works great.

Share this post


Link to post
Share on other sites

Though you may want to throw a distance check in there aswell. Else a player could be 100m away and get the action as long as his cursorTarget was the ammo box =). So...

if (!isDedicated) then {
waitUntil {!(isNull player) && {time > 0}}; //JIP
player addAction [
	"<t color='#ff1111'>BIS Arsenal</t>", 
	{["Open",true] spawn BIS_fnc_arsenal},
	[],
	6,
	true,
	true,
	"",
	"cursorTarget isKindOf 'B_supplyCrate_F' && {_target distance cursorTarget <= 5}"
];  
player addEventHandler ["Respawn", {
	(_this select 0) addAction [
		"<t color='#ff1111'>BIS Arsenal</t>", 
		{["Open",true] spawn BIS_fnc_arsenal},
		[],
		6,
		true,
		true,
		"",
		"cursorTarget isKindOf 'B_supplyCrate_F' && {_target distance cursorTarget <= 5}"
	];  
}];  
};

Edited by Iceman77

Share this post


Link to post
Share on other sites
Though you may want to throw a distance check in there aswell. Else a player could be 100m away and get the action as long as his cursorTarget was the ammo box =). So...

if (!isDedicated) then {
waitUntil {!(isNull player) && {time > 0}}; //JIP
player addAction [
	"<t color='#ff1111'>BIS Arsenal</t>", 
	{["Open",true] spawn BIS_fnc_arsenal},
	[],
	6,
	true,
	true,
	"",
	"_target distance (nearestObject [_target, 'B_supplyCrate_F']) <= 5 && {cursorTarget isKindOf 'B_supplyCrate_F'}"
];  
player addEventHandler ["Respawn", {
	(_this select 0) addAction [
		"<t color='#ff1111'>BIS Arsenal</t>", 
		{["Open",true] spawn BIS_fnc_arsenal},
		[],
		6,
		true,
		true,
		"",
		"_target distance (nearestObject [_target, 'B_supplyCrate_F']) <= 5 && {cursorTarget isKindOf 'B_supplyCrate_F'}"
	];  
}];  
};

why not

_target distance cursortTarget <= 5

Share this post


Link to post
Share on other sites
why not

_target distance cursortTarget <= 5

Edited post #14 to include it.

Edited by Iceman77

Share this post


Link to post
Share on other sites

Just keep in mind it relies heavily on the player's cursor target. So if you've 50 people gearing up at mission start... let's just say to remind your guys to be considerate of ones positioning =). Cheers.

---------- Post added at 14:49 ---------- Previous post was at 14:45 ----------

If players blocking other players cursor target becomes a real pain, you can simply replace the condition with:

"_target distance (nearestObject [_target, 'B_supplyCrate_F']) <= 5"

Which would allow the action based only on the player's distance to any given supply crate. Anyhow idk how many participants you have. Just thought I'd provide a little extra info.

Share this post


Link to post
Share on other sites
Just keep in mind it relies heavily on the player's cursor target. So if you've 50 people gearing up at mission start... let's just say to remind your guys to be considerate of ones positioning =). Cheers.

---------- Post added at 14:49 ---------- Previous post was at 14:45 ----------

If players blocking other players cursor target becomes a real pain, you can simply replace the condition with:

"_target distance (nearestObject [_target, 'B_supplyCrate_F']) <= 5"

Which would allow the action based only on the player's distance to any given supply crate. Anyhow idk how many participants you have. Just thought I'd provide a little extra info.

Alright thanks :D

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  

×