Jump to content
Cotsifis

I'm trying to create a simple "Get loadout trough trigger" Kindda Arsenal, but it seems like the variable i'm using doesn't work for Multiplayer

Recommended Posts

Hey people. So, i've been editing a Liberation mission for me and a couple of friends. However, the modlist we use is a little bit extense, and some mods include gear / equipment from other countries. Furthermore, these mods are necessary for the liberation mission, as the enemy force will be spawned from units from these mods. As i want to make something very standardized, i don't want people using gear from my country and then having somebody using a freaking russian helmet or whatever.

To solve that problem i thought of hiding the arsenal option in the Main base and FOBs (By adding "//" to the arsenal script in the liberations source folder) and instead of having a full arsenal, having a tent with various cabinets and, by these cabinets, there are triggers that, once a player enters it's area, a loadout is assigned to that player.

This is how it works: You enter the trigger Area, the trigger removes all of your gear, equipment and items and assign you new clothes, weapons, gear and items to replace the ones you've had on spawn.

I've tested it, and works great. However, on Multiplayer sessions, it seems it stops working for some reason. i've read something about the player variable not working in multiplayer, because player in MP means everyone connected to the server, and not just the player that stepped on the trigger.

Basically i want this script to be applied only to the one player that steps on that especific trigger, and not the whole player base.

This is how the structure of my script is right now (still broken on MP):

{removeVest _x} forEach thisList;  
{removeBackpack _x} forEach thisList;  
{removeHeadgear _x} forEach thisList;  
{removeUniform _x} forEach thisList;  
{removeAllWeapons _x} forEach thisList;  
{removeAllBinocularItems  _x} forEach thisList;  
{removeGoggles  _x} forEach thisList;  
{_x unassignItem "NVGoggles"} forEach thisList;   
{_x removeItem "NVGoggles"} forEach thisList;  
 
Player addWeapon "bel_fn_cal";
Player addWeapon "Binocular";  
Player addPrimaryWeaponItem "20rd_556x45"; 
Player addWeapon "BAD_M1911"; 
Player addHandgunItem "9Rnd_45ACP_Mag"; 
Player forceAddUniform "BFMexercito_uniform1"; 
Player addVest "MEA_vest_EB_06"; 
Player addBackpack "br_alicepack_med"; 
Player addItemToUniform "ACE_EarPlugs"; 
Player addItemToUniform "ACE_IR_Strobe_Item"; 
for "_i" from 1 to 5 do {Player addItemToUniform "ACE_CableTie";}; 
for "_i" from 1 to 2 do {Player addItemToUniform "ACE_Canteen";}; 
for "_i" from 1 to 2 do {Player addItemToUniform "ACE_MRE_MeatballsPasta";}; 
for "_i" from 1 to 2 do {Player addItemToUniform "ACE_WaterBottle";}; 
Player addItemToUniform "ACE_MapTools"; 
Player addItemToUniform "ACE_microDAGR"; 
Player addItemToUniform "ACE_Flashlight_XL50"; 
Player addItemToUniform "ACE_wirecutter"; 
Player addItemToUniform "ACE_EntrenchingTool";
Player addItemToUniform "ACRE_PRC343"; 
for "_i" from 1 to 6 do {Player addItemToUniform "9Rnd_45ACP_Mag";}; 
for "_i" from 1 to 6 do {Player addItemToVest "20rd_556x45";}; 
Player addItemToBackpack "NVGoggles_INDEP"; 
Player addItemToBackpack "Medikit"; 
for "_i" from 1 to 5 do {Player addItemToBackpack "FirstAidKit";}; 
for "_i" from 1 to 2 do {Player addItemToBackpack "20rd_556x45";}; 
for "_i" from 1 to 4 do {Player addItemToBackpack "HandGrenade";}; 
for "_i" from 1 to 4 do {Player addItemToBackpack "SmokeShell";}; 
Player addHeadgear "EB_helmet_ballistic_C"; 
Player addGoggles "G_Tactical_Clear"; 
Player linkItem "ItemMap"; 
Player linkItem "ItemCompass"; 
Player linkItem "ItemWatch"; 
Player linkItem "ItemRadio"; 

If anyone knows wich variable i can replace for the player, that'd be a great life-saver. Thanks in advance!  

  • Like 1

Share this post


Link to post
Share on other sites

Well, I don't know enough to help you solve it right upon your current codes; Instead, I will show what I use as an external .SQF file, which "undercovers" the player as a civilian and make them a little more stealthy once it's clicked by them (player need to click on an addAction called "James Bond" that is shown when close to a wooden box).
I have got these somewhere here in forums and adapted the code. Note that where I would use "player" as well, now is a specific param "_unit", and "player" is used only at the very end, for calling the script.
This code and technique have been working 100% on a dedicated MP server, and I don't need to add anything else on init/initPlayer/initServer other than the additional .SQF file and an object with this addAction.

 

TAG_fnc_captiveCheck = {

	params ["_unit"];
	_unit setUnitTrait ["CamouflageCoef",0.01];
	_unit setUnitTrait ["AudibleCoef",0.01];
	removeAllWeapons _unit;
	_unit addWeapon "Binocular";
	_unit addWeapon "Item_Binocular";
	_unit setCaptive true;
	systemchat "Disfarçado de civil.";


		_headgearArray = [
			"H_Construction_basic_orange_F",
			"H_Construction_earprot_orange_F",
			"H_Cap_Orange_IDAP_F",
			"H_Hat_tan",
			"H_Bandanna_surfer",
			"H_Cap_red"
			];
		_vestArray = [
			"V_Plain_medical_F",
			"V_Safety_orange_F"
			];
		_uniformArray = [
			"U_C_Scientist",
			"U_C_Poor_2_sick",
			"U_NikosBody",
			"U_C_Poloshirt_redwhite",
			"U_C_Journalist",
			"U_OrestesBody"
			];

		_randomHeadgear = _headgearArray call BIS_fnc_selectRandom;
		_randomVest = _vestArray call BIS_fnc_selectRandom;
		_randomUniform = _uniformArray call BIS_fnc_selectRandom;

		(_unit) addHeadgear _randomHeadgear;
		(_unit) addVest _randomVest;
		(_unit) forceAddUniform _randomUniform;

};

player spawn TAG_fnc_captiveCheck;


So maybe you could test it by removing all that "random" stuff and replacing them by your specific desired items.

  • Thanks 1

Share this post


Link to post
Share on other sites
On 7/7/2024 at 1:41 PM, Cotsifis said:

Hey people. So, i've been editing a Liberation mission for me and a couple of friends. However, the modlist we use is a little bit extense, and some mods include gear / equipment from other countries. Furthermore, these mods are necessary for the liberation mission, as the enemy force will be spawned from units from these mods. As i want to make something very standardized, i don't want people using gear from my country and then having somebody using a freaking russian helmet or whatever.

To solve that problem i thought of hiding the arsenal option in the Main base and FOBs (By adding "//" to the arsenal script in the liberations source folder) and instead of having a full arsenal, having a tent with various cabinets and, by these cabinets, there are triggers that, once a player enters it's area, a loadout is assigned to that player.

This is how it works: You enter the trigger Area, the trigger removes all of your gear, equipment and items and assign you new clothes, weapons, gear and items to replace the ones you've had on spawn.

I've tested it, and works great. However, on Multiplayer sessions, it seems it stops working for some reason. i've read something about the player variable not working in multiplayer, because player in MP means everyone connected to the server, and not just the player that stepped on the trigger.

Basically i want this script to be applied only to the one player that steps on that especific trigger, and not the whole player base.

This is how the structure of my script is right now (still broken on MP):

{removeVest _x} forEach thisList;  
{removeBackpack _x} forEach thisList;  
{removeHeadgear _x} forEach thisList;  
{removeUniform _x} forEach thisList;  
{removeAllWeapons _x} forEach thisList;  
{removeAllBinocularItems  _x} forEach thisList;  
{removeGoggles  _x} forEach thisList;  
{_x unassignItem "NVGoggles"} forEach thisList;   
{_x removeItem "NVGoggles"} forEach thisList;  
 
Player addWeapon "bel_fn_cal";
Player addWeapon "Binocular";  
Player addPrimaryWeaponItem "20rd_556x45"; 
Player addWeapon "BAD_M1911"; 
Player addHandgunItem "9Rnd_45ACP_Mag"; 
Player forceAddUniform "BFMexercito_uniform1"; 
Player addVest "MEA_vest_EB_06"; 
Player addBackpack "br_alicepack_med"; 
Player addItemToUniform "ACE_EarPlugs"; 
Player addItemToUniform "ACE_IR_Strobe_Item"; 
for "_i" from 1 to 5 do {Player addItemToUniform "ACE_CableTie";}; 
for "_i" from 1 to 2 do {Player addItemToUniform "ACE_Canteen";}; 
for "_i" from 1 to 2 do {Player addItemToUniform "ACE_MRE_MeatballsPasta";}; 
for "_i" from 1 to 2 do {Player addItemToUniform "ACE_WaterBottle";}; 
Player addItemToUniform "ACE_MapTools"; 
Player addItemToUniform "ACE_microDAGR"; 
Player addItemToUniform "ACE_Flashlight_XL50"; 
Player addItemToUniform "ACE_wirecutter"; 
Player addItemToUniform "ACE_EntrenchingTool";
Player addItemToUniform "ACRE_PRC343"; 
for "_i" from 1 to 6 do {Player addItemToUniform "9Rnd_45ACP_Mag";}; 
for "_i" from 1 to 6 do {Player addItemToVest "20rd_556x45";}; 
Player addItemToBackpack "NVGoggles_INDEP"; 
Player addItemToBackpack "Medikit"; 
for "_i" from 1 to 5 do {Player addItemToBackpack "FirstAidKit";}; 
for "_i" from 1 to 2 do {Player addItemToBackpack "20rd_556x45";}; 
for "_i" from 1 to 4 do {Player addItemToBackpack "HandGrenade";}; 
for "_i" from 1 to 4 do {Player addItemToBackpack "SmokeShell";}; 
Player addHeadgear "EB_helmet_ballistic_C"; 
Player addGoggles "G_Tactical_Clear"; 
Player linkItem "ItemMap"; 
Player linkItem "ItemCompass"; 
Player linkItem "ItemWatch"; 
Player linkItem "ItemRadio"; 

If anyone knows wich variable i can replace for the player, that'd be a great life-saver. Thanks in advance!  

 

Your code seems fine at a glance. player should be fine, it just needs to be executed on the correct PC.

 

If your trigger is doing nothing the code is either not executing or executing on the server only (where player = host player or null-object) or on another player's machine (that would be strange).

 

What is the trigger settings and condition?

Is it server only?

 

The following trigger config should at least execute your code locally for each player as that player enters the trigger:

Setting: Any player present 

Condition: player in thisList

Server only: Off 

 

With this I recommend changing the removeX commands so they execute only on player i.e. change:

{removeVest _x} forEach thisList; 

to 

removeVest player;

 

To help with troubleshooting you can verify that your code is running by putting a systemChat "Loadout X"; as the first line. If you see the text the problem is in your code, else it's in your trigger.

 

You can also have -showScriptErrors enabled in the A3 launcher. This will show you on screen if your code has errors.

  • 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

×