Jump to content
Sign in to follow this  
HaZZarD

custom loadout wont work in MP for non-host players

Recommended Posts

ok guys , I have this problem making me mad , if I fix this than my mission will finally be polished so I thanks you all in advance : )

this is the mission Steam Workshop link for more info : http://steamcommunity.com/sharedfiles/filedetails/?id=176607977

so I made this mission 4vs1 PvP , the one alone is an officer and I changed his loadout to a custom one , this is what I have done so far :

in the officer Init I have this :

dummy = [officer,"marker"] execVM "marker.sqf"; officer setIdentity "Wardak";  null = [this] execVM "officersetup.sqf";   this addeventhandler ["respawn","_this execVM 'officersetup.sqf'"];

while in my mission folder this :

officersetup.sqf

//////////////////////////////////////////////////////////////////
// Having fun with LoadOuts
//////////////////////////////////////////////////////////////////

waitUntil {!isNull player};       //to prevent MP / JIP issues

this = _this select 0;




this addGoggles "G_Aviator";

this addPrimaryWeaponItem "acc_flashlight";  

this addhandgunitem "muzzle_snds_L";


This addweapon "Rangefinder" ; 

this setFace "PersianHead_A3_02";




if(true) exitWith{};

to me seems all ok and in fact when I host the PvP in multy when I play as officer all is fine and I have my nice and useful custom loadout with the flashlight to use at night

but then when other players play as the officer they say me they have no flashlight , and I was like O___O I said them I tested it several times and all was ok so I asked for a screenshots and here the proof

screenshot when I play online as officer :

http://cloud-2.steampowered.com/ugc/921273104949428123/B21D90A01B95A67A89C7E5D3552B9D5081D3C12B/

screenshot when another player play as officer:

http://cloud-2.steampowered.com/ugc/902132806528297636/1E6951DA3B2400264A633B08A2487AF8FB78FDC8/

what I did wrong ? how can I fix this ?

Edited by HaZZarD

Share this post


Link to post
Share on other sites

Try to replace “this†with “officerâ€. If it won’t help, you can also try to call officersetup.sqf from init.sqf.

Share this post


Link to post
Share on other sites

I would use 'player' instead of 'this'. Don't know if that would work, but you can give it a try until someone better gives a better answer.

Share this post


Link to post
Share on other sites

You probably don't want to use player nor officer, otherwise the whole point of one script for many is lost. Even though this isn't being used that way it's being called that way.

waitUntil {!isNull player};       //to prevent MP / JIP issues

_unit = _this select 0;
_unit addGoggles "G_Aviator";
_unit addPrimaryWeaponItem "acc_flashlight";  
_unit addhandgunitem "muzzle_snds_L";
_unit addweapon "Rangefinder";
_unit setFace "PersianHead_A3_02";

Share this post


Link to post
Share on other sites
You probably don't want to use player nor officer, otherwise the whole point of one script for many is lost. Even though this isn't being used that way it's being called that way.

waitUntil {!isNull player};       //to prevent MP / JIP issues

_unit = _this select 0;
_unit addGoggles "G_Aviator";
_unit addPrimaryWeaponItem "acc_flashlight";  
_unit addhandgunitem "muzzle_snds_L";
_unit addweapon "Rangefinder";
_unit setFace "PersianHead_A3_02";

ok I'll try to change " this " with " _unit " and then I'll report back

thanks

Share this post


Link to post
Share on other sites

I tried and ....IT WORKED :D:D

damn kylania you are a PRO ! second time you save the day

Share this post


Link to post
Share on other sites

[ONE MORE PROBLEM]

It worked but sometime I have weird issues O__O , I made all the custom loadouts with the "_unit" as suggested by Sir kylania .

The problem here is that it work 80%/90% of the time but there is also that 20%/10% where the loadout wont load , look like the init of the unit fail to be read , is this possible ? uhm :confused2:

how can I be 100% sure to load this line EVERY time I host the mission ?

dummy = [officer,"marker"] execVM "marker.sqf"; officer setIdentity "Wardak";  null = [this] execVM "officersetup.sqf";   this addeventhandler ["respawn","_this execVM 'officersetup.sqf'"];

Edited by HaZZarD

Share this post


Link to post
Share on other sites
The problem here is that it work 80%/90% of the time but there is also that 20%/10% where the loadout wont load , look like the init of the unit fail to be read , is this possible ? uhm :confused2:

waitUntil {!isNull player}; doesn't prevent sync/JIP problems in my experience, in fact I've never gotten them to work in an assured way. I'm most confused by the fact that so few people seem to have problems regarding this.

The only solution I currently have hopes for is calling the loadout from a function, as I pondered in my own thread, but since I haven't been able to give that multiple tests, I can't really recommend it. In case you want to give it a try, do this:

1) Add the following to your description.ext

class CfgFunctions
{
class new
{
	class loadout
	{
		class officerSetup { file = "officersetup.sqf" };
	};
};
};

2) In the unit's initialisation box, instead of "null = [this] execVM "officersetup.sqf"", use this:

nul = [this] call new_fnc_officerSetup;

The reasoning for using a Functions Library function is in the thread I linked: It's processed first for everyone, so it should be least likely to fail.

I'd love to hear more on this issue, if anyone has any information.

Share this post


Link to post
Share on other sites

thanks mate , yeah this is an Huge problem and must be discussed more , the fact that the init can randomly fail is unbelievable

the random errors like this one are the hardest one because you test the mission and maybe 80% of the time it work but then you release the mission to the public and between lot of matches the bug occur and it ruin the whole experience and people get angry telling you that the mission is bugged :S

I'll test your method and report back

Share this post


Link to post
Share on other sites

I was having the same kind of trouble with a COOP mission intended for dedicated servers. Was tearing out what little hair I had left until I came across Magirot's code above, which worked an absolute treat. Mate, you are a legend!!

Share this post


Link to post
Share on other sites

hi gruukh , can you upload a template mission about what you have done with loadouts ? :)

because I am not sure about what to put in the description and how should I make the loadout.sqf : (

in class CfgFunctions I already have this

class CfgFunctions
{

#include "VAS\cfgfunctions.hpp"
#include "VVS\Functions.h"



};



class RscPicture 
{
type = CT_STATIC;
idc = -1;
style = 48;
colorBackground[] = {0, 0, 0, 0};
colorText[] = {1, 1, 1, 1};
font = "PuristaMedium"; //Typeface
sizeEx = 0;
};

class RscTitles 
{
#include "=BTC=_Logistic\=BTC=_Lift\=BTC=_Hud.h"
};

so I don't know where and how to put the

class CfgFunctions
{
class new
{
	class loadout
	{
		class officerSetup { file = "officersetup.sqf" };
	};
};
};

in the init of the unit I want to load the gear on respawn I guess this is ok ?

this addeventhandler ["respawn","_this call new_fnc_officerSetup'"];

about the officer.sqf I know the old method that was something like this

// Having fun with LoadOuts
//////////////////////////////////////////////////////////////////

waitUntil {!isNull player};       //to prevent MP / JIP issues

this = _this select 0;




this addGoggles "G_Aviator";

this addPrimaryWeaponItem "acc_flashlight";  

this addhandgunitem "muzzle_snds_L";


This addweapon "Rangefinder" ; 

this setFace "PersianHead_A3_02";


if(true) exitWith{};

but I don't know how to make the .sqf with the new method .

thanks in the advance for the help , it's already a good news knowing you find a way to solve this bad issue : )

Edited by HaZZarD

Share this post


Link to post
Share on other sites

i'm not sure how this will play with VAS as I almost never use it, but I have the following in my description.ext:

class CfgFunctions{
class new
{
	class loadout
	{
		class StdLoadout { file = "scripts\loadout.sqf" };
		class SniperLoadout { file = "scripts\loadout1.sqf" };
	};
};

My loadout.sqf is like this (loadout1.sqf is similar, different weapons):

waitUntil {!isNull player};       //to prevent MP / JIP issues
_unit = _this select 0;
removeallweapons _unit;
_unit addmagazine "30Rnd_65x39_caseless_mag";
_unit addweapon "arifle_MXC_Holo_pointer_snds_F";
_unit addPrimaryWeaponItem "UU_TSS_H_Optic";
_unit addWeapon "launch_NLAW_F";
_unit addmagazine "16Rnd_9x21_Mag";
_unit addweapon "hgun_P07_snds_F";
_unit addMagazines ["30Rnd_65x39_caseless_mag",4];
_unit addMagazines ["16Rnd_9x21_Mag",2];
_unit addMagazines ["HandGrenade",2];
_unit addItem "NVGoggles";
_unit assignItem "NVGoggles";
removeBackpack _unit; 
_unit addBackpack "B_AssaultPack_blk";
backpa = unitBackpack _unit;
clearMagazineCargo backpa;
backpa addmagazineCargoGlobal ["30Rnd_65x39_caseless_mag",2];
backpa addMagazineCargoGlobal ["DemoCharge_Remote_Mag",1];
backpa addMagazineCargoGlobal ["NLAW_F",1];
backpa addItemCargoGlobal ["FirstAidKit",2];

And i have the following in the init lines of each unit:

nul = [this] call new_fnc_StdLoadout;

OR

nul = [this] call new_fnc_SniperLoadout;

depending on the unit type.

I noticed that you have

[color=#3E3E3E]this addeventhandler ["respawn","_this call new_fnc_officerSetup'"];[/color]

in the init line, i think it should be:

[color=#3E3E3E]this addeventhandler ["respawn","_this call new_fnc_officerSetup"];[/color]

Typo perhaps. I rarely include respawn so not of much help there sorry mate, but I think what you have will work.

Hope this helps. I can post a download link to the mission if you need it when I get home - let me know.

Edited by gruukh
edited to remove typo in pasted script loadout.sqf

Share this post


Link to post
Share on other sites

If you're using "_unit" (and not player) and you're running it from init line you should not need (in fact it might even break stuff) to wait until "player" is not null.

Hypotethical: JiP joins -> his unit is initialized, during this time it might belong to the server, or the client. Hence why both should be able to give him loadout.

If you have waitUntil not isNull player, the (dedicated) server will be stuck forever, and other players (yes init runs for everyone) will not be able to give the unit any loadout.

Share this post


Link to post
Share on other sites

thanks gruukh :)

I really would like a working template for respawn and custom gear , something that never fail , I tried lot of solutions but I always get that random problem where the loadout fail to load : (

this is my number one problem with the Arma III editor and I never solved it since I started making mission in Arma III , really a nightmare O__O

Edited by HaZZarD

Share this post


Link to post
Share on other sites
waitUntil {!isNull player}; doesn't prevent sync/JIP problems in my experience, in fact I've never gotten them to work in an assured way. I'm most confused by the fact that so few people seem to have problems regarding this.

Waiting until the player variable exists works fine aslong as the code is being ran on the client where player variable can be valid. I've never had any issues with it. Unless as cuel points out he's running this from the init line of the unit and not using player variable, then it isn't even needed. The loadout will be there in any case as it's reffering to the unit and not the player.

Also, if you're doing side checks right away, before the player has boots on the ground, then JIP "player" always defaults to west side initially. Which can pose some problems, making you think something else is wrong. In that case I always wait until time > 1 after the null check.

Edited by Iceman77

Share this post


Link to post
Share on other sites

I have a same problem with my loadout.sqf when a player join the game all players lose their uniform...

Anyone find a solution ?

Share this post


Link to post
Share on other sites

For weeks now I try and try again from after the Ptach, but I can not find a solution.

on 'hint slot launch the command:

"

nul = [this] execVM "" equip \ mitragliere.sqf ""; this AddEventHandler ["" respawn "", "" _this execVM 'equip \ mitragliere.sqf' ""];

this is my file:

// 2RGT OBERST per ARMA3 //

// Personaggio MITRAGLIERE//

if (isServer) then {

waitUntil {!isNull _unit};

};

_unit = _this select 0;

// Remove original equipment

removeAllWeapons _unit;

removeUniform _unit;

removeHeadgear _unit;

removeVest _unit;

removeBackpack _unit;

removeallassigneditems _unit;

// Aggiunta giberna tattica, mimetica e backpack

_unit addVest "V_PlateCarrier1_PMC_rgr";

_unit addUniform "U_PMC_CombatUniformLS_IndPBSBB";

_unit addHeadgear "H_mas_it_Woolhat";

_unit addbackpack "B_Carryall_oli";

// configurazione arma primaria

_unit addMagazines ["200Rnd_65x39_cased_Box", 5];

_unit addMagazines ["200Rnd_65x39_cased_Box_Tracer", 2];

_unit addWeapon "LMG_Mk200_MRCO_F";

_unit addPrimaryWeaponItem "acc_flashlight";

_unit addPrimaryWeaponItem "optic_Arco";

//_unit addPrimaryWeaponItem "muzzle_snds_M";

// configurazione arma secondaria

_unit addMagazines ["9Rnd_45ACP_Mag", 2];

_unit addWeapon "hgun_ACPC2_snds_F";

// equipaggiamento soldato

_unit addMagazines ["handgrenade", 4];

_unit addMagazines ["smokeshell", 2];

//_unit addMagazines ["SmokeShellGreen", 1];

//_unit addMagazines ["SmokeShellBlue", 2];

//_unit addItem "nvgoggles";

_unit addItem "ItemCompass";

_unit addItem "itemgps";

_unit addItem "itemmap";

//_unit addItem "ACRE_PRC148";

_unit addItem "ACRE_PRC343";

_unit addItem "itemwatch";

_unit addWeapon "Rangefinder";

_unit addGoggles "G_Tactical_Black";

//_unit assignitem "nvgoggles";

_unit assignitem "itemcompass";

_unit assignitem "itemgps";

_unit assignitem "itemmap";

_unit assignitem "ACRE_PRC343";

_unit assignitem "itemwatch";

// oggetti nel backpack

(unitBackpack _unit) additemCargo ["FirstAidKit",10];

(unitBackpack _unit) addmagazineCargo ["200Rnd_65x39_cased_Box", 6];

if(true) exitWith{};

it has always worked before the patch and now I'm in my underwear when I play in MP :(

Edited by 2rgt oberst

Share this post


Link to post
Share on other sites
waitUntil {!isNull player}; doesn't prevent sync/JIP problems in my experience, in fact I've never gotten them to work in an assured way. I'm most confused by the fact that so few people seem to have problems regarding this.

We use this for our missions:

init.sqf

JIP = {
if (!isDedicated) then {
	waitUntil {(!isNull player) && (player == player) && (time > 5)};
};
};

// More init stuff

Then just call the function whenever required:

[] call JIP;
// Do something

After quite a bit of testing, this method appears to work very well.

P.S

if(true) exitWith{};

This line does nothing, exitWith{} is used to exit loops and does not work as a means to exit a script. Besides, the script will end anyway once it reaches the last line of code (unless you are running it in a loop of course) ;)

Edited by GDSN

Share this post


Link to post
Share on other sites
We use this for our missions:

init.sqf

JIP = {
if (!isDedicated) then {
	waitUntil {(!isNull player) && (player == player) && (time > 5)};
};
};

// More init stuff

Then just call the function whenever required:

[] call JIP;
// Do something

After quite a bit of testing, this method appears to work very well.

P.S

This line does nothing, exitWith{} is used to exit loops and does not work as a means to exit a script. Besides, the script will end anyway once it reaches the last line of code (unless you are running it in a loop of course) ;)

thanks mate , can I have one of your mission to use as template ? : ))

Share this post


Link to post
Share on other sites
thanks mate , can I have one of your mission to use as template ? : ))

If you mean a template for a loadout script, sure. Here's an updated version of my loadout script (not been tested in a dedicated environment yet, but should work all the same). You can find it here:

GDSN Class Loadout Script

It's a bit specific to what we want, but you can pick out the pieces that are relevant to you ;)

J

Share this post


Link to post
Share on other sites
If you mean a template for a loadout script, sure. Here's an updated version of my loadout script (not been tested in a dedicated environment yet, but should work all the same). You can find it here:

GDSN Class Loadout Script

It's a bit specific to what we want, but you can pick out the pieces that are relevant to you ;)

J

thanks for the help ! +rep&beer for you ;)

Share this post


Link to post
Share on other sites
If you mean a template for a loadout script, sure. Here's an updated version of my loadout script (not been tested in a dedicated environment yet, but should work all the same). You can find it here:

GDSN Class Loadout Script

It's a bit specific to what we want, but you can pick out the pieces that are relevant to you ;)

J

I saw the file with the script ...... great job!

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  

×