Jump to content
Sign in to follow this  
opendome

Loadout Issues and Inventory Issues

Recommended Posts

Hello everyone! Im having some dedicated server JIP issues, whenever another player respawns or joins the server the loadouts sometimes disapear from a player or cause them to execute again, sometimes doubling the inventory.

 

For instance I have this in the init of a player:

 

null = [this] execvm "grenadier.sqf"; this addeventhandler ["respawn","_this execvm 'grenadier.sqf'"];

 

then in the grenadier.sqf I have,

 

 

waitUntil {!isNull player}; 
 
_unit = _this select 0;
 
removeallweapons _unit;
removeallassigneditems _unit;
removeuniform _unit;
removevest _unit;
removebackpack _unit;
removeHeadgear _unit; 
removeGoggles _unit;
 
_unit forceAddUniform "TRYK_U_B_ARO1_BLK_CombatUniform";
_unit addItemToUniform "ACE_EarPlugs";
_unit addItemToUniform "ACE_MapTools";
for "_i" from 1 to 2 do {_unit addItemToUniform "ACE_packingBandage";};
_unit addItemToUniform "ACE_personalAidKit";
for "_i" from 1 to 2 do {_unit addItemToUniform "ACE_quikclot";};
for "_i" from 1 to 2 do {_unit addItemToUniform "ACE_elasticBandage";};
_unit addItemToUniform "ACE_fieldDressing";
_unit addItemToUniform "ACE_tourniquet";
for "_i" from 1 to 3 do {_unit addItemToUniform "ACE_CableTie";};
for "_i" from 1 to 2 do {_unit addItemToUniform "rhsusf_mag_7x45acp_MHP";};
 
_unit addVest "lbt_weapons_coy";
for "_i" from 1 to 5 do {_unit addItemToVest "rhs_mag_30Rnd_556x45_Mk318_Stanag";};
for "_i" from 1 to 4 do {_unit addItemToVest "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red";};
for "_i" from 1 to 4 do {_unit addItemToVest "rhs_mag_M441_HE";};
 
_unit addBackpack "B_Kitbag_rgr";
for "_i" from 1 to 2 do {_unit addItemToBackpack "SmokeShellGreen";};
for "_i" from 1 to 2 do {_unit addItemToBackpack "rhs_mag_m67";};
for "_i" from 1 to 3 do {_unit addItemToBackpack "rhs_mag_m714_White";};
for "_i" from 1 to 3 do {_unit addItemToBackpack "rhs_mag_m713_Red";};
for "_i" from 1 to 3 do {_unit addItemToBackpack "rhs_mag_m715_Green";};
for "_i" from 1 to 10 do {_unit addItemToBackpack "rhs_mag_M441_HE";};
for "_i" from 1 to 2 do {_unit addItemToBackpack "rhs_mag_an_m8hc";};
for "_i" from 1 to 2 do {_unit addItemToBackpack "rhs_mag_m18_red";};
 
_unit addWeapon "rhs_weap_m4a1_m320";
_unit addPrimaryWeaponItem "rhsusf_acc_anpeq15";
_unit addPrimaryWeaponItem "rhsusf_acc_ACOG_d";
_unit addWeapon "rhsusf_weap_m1911a1";
_unit addWeapon "ACE_Vector";
 
_unit linkItem "ItemMap";
_unit linkItem "ItemCompass";
_unit linkItem "tf_anprc148jem_1";
_unit addItem "ItemGPS";
_unit assignItem "ItemGPS";
_unit linkItem "ItemWatch";
 
if(true) exitWith{};
 
also in the inventory of some crates I have in their init:
 
clearWeaponCargo this; clearMagazineCargo this;  this addBackpackCargo ["ACE_TacticalLadder_Pack",20]; this addItemCargo ["ACE_SpraypaintBlack",20]; this addItemCargo ["ACE_SpraypaintGreen",20]; this addItemCargo ["ACE_SpraypaintRed",20]; this addItemCargo ["ACE_SpraypaintBlue",20];
 
both of these work fine in SP and on an arma 2 dedicated server (in the same format, not the items)?
 
Thanks!

Share this post


Link to post
Share on other sites

Before your waituntil put:

if(!IsDedicated) exitWith {};

After _unit = _this select 0 put:

if(player != _unit) exitWith {};

There are more elegant ways to do it but that should get the job done.

Share this post


Link to post
Share on other sites

Thanks for the suggestion! I tried

 

if(!IsDedicated) exitWith {};
 
waitUntil {!isNull player}; 
 
_unit = _this select 0;
 
if(player != _unit) exitWith {};
 
at the top of the script but in the dedicated server the script doesnt do anything now

Share this post


Link to post
Share on other sites

Im thinking it hhas something to do with this in the units init

 

null = [this] execvm "grenadier.sqf"; this addeventhandler ["respawn","_this execvm 'grenadier.sqf'"];

 

as the problem seems to occur when a player joins (which kicks off the script) and when a player respawns (which kicks off the script)?

Share this post


Link to post
Share on other sites

Add statement to prevent execute by anyone for everyone.
LOL that was deep.
 
Ehh is better way :
Move your scripts into initPlayerLocal.sqf
Add if statements

 (typeOf player == "B_Medic_F")

or

switch (typeOf player) do {};

In MP environment handle boxes server side only and use global version of cargo commands.

if (isServer) then {
clearWeaponCargoGlobal this; 
clearMagazineCargoGlobal this; 
this addBackpackCargoGlobal ["ACE_TacticalLadder_Pack",20]; 
this addItemCargoGlobal ["ACE_SpraypaintBlack",20]; 
...
};
  • Like 1

Share this post


Link to post
Share on other sites

haha! Thanks for the reply! I have individual loadouts set for the units and I've never done or used the initPlayerLocal.sqf method before, I was wondering if you had an example of it or if there's another way?

 

Thanks!

Share this post


Link to post
Share on other sites

initPlayerLocal.sqf

if(hasInterface) then {

switch (typeOf player) do {

	case "B_Soldier_GL_F": {
		//grenadier
		removeallweapons player;
		removeallassigneditems player;
		removeuniform player;
		removevest player;
		removebackpack player;
		removeHeadgear player; 
		removeGoggles player;
		player forceAddUniform "TRYK_U_B_ARO1_BLK_CombatUniform";
		player addItemToUniform "ACE_EarPlugs";
		player addItemToUniform "ACE_MapTools";
		for "_i" from 1 to 2 do {player addItemToUniform "ACE_packingBandage";};
		player addItemToUniform "ACE_personalAidKit";
		for "_i" from 1 to 2 do {player addItemToUniform "ACE_quikclot";};
		for "_i" from 1 to 2 do {player addItemToUniform "ACE_elasticBandage";};
		player addItemToUniform "ACE_fieldDressing";
		player addItemToUniform "ACE_tourniquet";
		for "_i" from 1 to 3 do {player addItemToUniform "ACE_CableTie";};
		for "_i" from 1 to 2 do {player addItemToUniform "rhsusf_mag_7x45acp_MHP";};
		 
		player addVest "lbt_weapons_coy";
		for "_i" from 1 to 5 do {player addItemToVest "rhs_mag_30Rnd_556x45_Mk318_Stanag";};
		for "_i" from 1 to 4 do {player addItemToVest "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red";};
		for "_i" from 1 to 4 do {player addItemToVest "rhs_mag_M441_HE";};
		 
		player addBackpack "B_Kitbag_rgr";
		for "_i" from 1 to 2 do {player addItemToBackpack "SmokeShellGreen";};
		for "_i" from 1 to 2 do {player addItemToBackpack "rhs_mag_m67";};
		for "_i" from 1 to 3 do {player addItemToBackpack "rhs_mag_m714_White";};
		for "_i" from 1 to 3 do {player addItemToBackpack "rhs_mag_m713_Red";};
		for "_i" from 1 to 3 do {player addItemToBackpack "rhs_mag_m715_Green";};
		for "_i" from 1 to 10 do {player addItemToBackpack "rhs_mag_M441_HE";};
		for "_i" from 1 to 2 do {player addItemToBackpack "rhs_mag_an_m8hc";};
		for "_i" from 1 to 2 do {player addItemToBackpack "rhs_mag_m18_red";};
		player addWeapon "rhs_weap_m4a1_m320";
		player addPrimaryWeaponItem "rhsusf_acc_anpeq15";
		player addPrimaryWeaponItem "rhsusf_acc_ACOG_d";
		player addWeapon "rhsusf_weap_m1911a1";
		player addWeapon "ACE_Vector";
		player linkItem "ItemMap";
		player linkItem "ItemCompass";
		player linkItem "tf_anprc148jem_1";
		player addItem "ItemGPS";
		player assignItem "ItemGPS";
		player linkItem "ItemWatch";
	};
	
	case "B_Medic_F": {
	
	//medic
	.......
	
	};
	
	
	case ......
	
	default {};


};
};
  • Like 1

Share this post


Link to post
Share on other sites

Great thanks! So it has to depend on unit classname then eh?

 

Also in in the units init it should be

 

null = [this] execvm "initPlayerLocal.sqf"; this addeventhandler ["respawn","_this execvm 'initPlayerLocal.sqf];

 

I didnt notice any dedicated/event handlers too, does that matter if using the initPlayerLocal.sqf?

 

Thanks again!

Share this post


Link to post
Share on other sites

Yep player class name .

But i see you have the respawn eventhandler too if so you can exec the script instead of moving his code into initPlayerLocal.sqf

like this:

 

initPlayerLocal.sqf
 

if (hasInterface) then {
    switch (typeOf player) do {

        case "B_Soldier_GL_F": {
            //grenadier
        [player] execvm "grenadier.sqf";
        player addeventhandler ["respawn",{_this execvm "grenadier.sqf"}];
        
        };
        
        case "B_Medic_F": {
        
        //medic
        .......
        
        };
        
        
        case ......
        
        default {};


    };
};
  • Like 1

Share this post


Link to post
Share on other sites

so something like 

 

null = [this] execvm "initPlayerLocal.sqf"; this addeventhandler ["respawn","_this execvm 'grenadier.sqf];?

 

The only thing is that I have been having the same problem when players respawn (sometimes doubling loadouts, sometimes removing them compltely) and I tried adding

 

if(!IsDedicated) exitWith {};

 
waitUntil {!isNull player}; 
 
_unit = _this select 0;
 
if(player != _unit) exitWith {};
 
to the top of the script but when I tried it on the dedicated server it didn't execute the script at all
 
Thanks!

Share this post


Link to post
Share on other sites

also if I do use the grenadier.sqf still should I change all of the _unit to _player like in the playerlocalinit.sqf?

 

Thanks again! Really appreciate the help!

Share this post


Link to post
Share on other sites

Ok thanks! Also I presume I should take out the if(!IsDedicated) exitWith {}; and the if(player != _unit) exitWith {}; since adding these caused the script not to work?

Share this post


Link to post
Share on other sites

ah ok thanks! SHould I get rid of the

 

waitUntil {!isNull player}; 

 
_unit = _this select 0;
 
as well?

Share this post


Link to post
Share on other sites
 

_unit = _this select 0;

 

should stay you define there the player
  • Like 1

Share this post


Link to post
Share on other sites

Great thanks! Should I still use

 

null = [this] execvm "initPlayerLocal.sqf"; this addeventhandler ["respawn","_this execvm 'grenadier.sqf];?

 

in the units init? Jsut wondering becuase I see theres a respawn handler in there

 

Thanks!

Share this post


Link to post
Share on other sites

Ah so I should use this addeventhandler ["respawn","_this execvm 'grenadier.sqf]; in the init or just leave it blank?

 

edit: just tried it blank and it didnt do anything

Share this post


Link to post
Share on other sites

If you use davidoss' method you shouldn't have anything in your unit's init. They are being executed on each client everytime a client connects. If you have five players on your server, you'll have the loadout script executed five times. Don't put anything in your unit's init unless you really know what you're doing.

Share this post


Link to post
Share on other sites

Just did some testing and it seems to be working perfectly! Thanks so much for your help!!!!!!!

Share this post


Link to post
Share on other sites

So this was working perfectly but now when a player dies they just stare at a black screen? It seems to have happened since the last update?

 

in my  initPlayerLocal.sqf I have

 

if (hasInterface) then {
    switch (typeOf player) do {
 
        case "B_T_Soldier_TL_F": {
 
        [player] execvm "initial.sqf";
        player addeventhandler ["respawn","_this execvm 'initial.sqf'"];
        
        };
        
        case "B_T_Soldier_F": {
 
        [player] execvm "initial.sqf";
        player addeventhandler ["respawn","_this execvm 'initial.sqf'"];
        
        };
 
case "B_T_Engineer_F": {
 
        [player] execvm "initial.sqf";
        player addeventhandler ["respawn","_this execvm 'initial.sqf'"];
        
        };
 
        default {};
 
 
    };
};
 
and in initial.sqf I have
 
_unit = _this select 0;
 
removeallweapons _unit;
removeallassigneditems _unit;
removeuniform _unit;
removevest _unit;
removebackpack _unit;
removeHeadgear _unit; 
 
_unit adduniform "U_B_T_Soldier_AR_F";
_unit addItemToUniform "ACE_microDAGR";
_unit addItemToUniform "ACE_HuntIR_monitor";
_unit addItemToUniform "ACE_EarPlugs";
 
_unit linkItem "ItemMap";
_unit linkItem "ItemCompass";
_unit linkItem "ItemWatch";
 
 
if(true) exitWith{};

Share this post


Link to post
Share on other sites

also Im using

 

//Disable looting corpses
player addEventHandler ["InventoryOpened",{
        if (_this select 1 isKindOf "Man") then {closeDialog 602; true}
}];
 
in the init.sqf and it seems to have broken that too

Share this post


Link to post
Share on other sites

You do not need that. The eventhandler "respawn" can automatically delete the killed corpse of respawned player if you want so.

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  

×