Jump to content
opendome

Need some help with loadout scripts

Recommended Posts

Hey everyone! So I made a few loadout scripts which I want to execute when the mission loads and when the units respawn (so they re-spawn with the same equipment from the beginning of the mission)

 

This is an example of one of my scripts (m110.sqf)

 

 

waitUntil {alive player};

 
_unit = player;
 
removeAllWeapons _unit;
removeBackpack _unit;
 
{_unit addMagazine "ACE_Battery_Rangefinder"} foreach [1];
{_unit addMagazine "ACE_20Rnd_762x51_S_M110"} foreach [1,2,3,4];
{_unit addMagazine "ACE_20Rnd_762x51_T_M110"} foreach [1,2,3,4];
_unit addWeapon "ACE_M110";
_unit addWeapon "ACE_Kestrel4500";
_unit addWeapon "ACE_Rangefinder_OD";
_unit addWeapon "ACE_Rucksack_MOLLE_Brown";
_unit addWeapon "GBL_camelbak";
{_unit addMagazine "HandGrenade_West"} foreach [1];
{_unit addMagazine "SmokeShellRed"} foreach [1];
{_unit addMagazine "ACE_Bandage"} foreach [1,2];
{_unit addMagazine "ACE_Morphine"} foreach [1,2];
{_unit addMagazine "ACE_Epinephrine"} foreach [1];
{_unit addMagazine "ACE_Medkit"} foreach [1,2];
{_unit addMagazine "7Rnd_45ACP_1911"} foreach [1];
 
{_unit addMagazine "GBL_US_MRE_MexicanStyleChickenStew"} foreach [1,2];
_unit addWeapon "Colt1911";
[_unit, "ACE_Morphine", 4] call ACE_fnc_PackMagazine;
[_unit, "ACE_Bandage", 4] call ACE_fnc_PackMagazine;
[_unit, "ACE_Medkit", 2] call ACE_fnc_PackMagazine;
[_unit, "ACE_20Rnd_762x51_S_M110", 3] call ACE_fnc_PackMagazine;
[_unit, "GBL_US_MRE_SpaghettiMeatSauce", 4] call ACE_fnc_PackMagazine;
[_unit, "7Rnd_45ACP_1911", 3] call ACE_fnc_PackMagazine;
[_unit, "HandGrenade_West", 1] call ACE_fnc_PackMagazine;
[_unit, "SmokeShellRed", 1] call ACE_fnc_PackMagazine;
[_unit, "GBL_Waterbottle", 6] call ACE_fnc_PackMagazine;
[_unit, "ACE_Battery_Rangefinder", 1] call ACE_fnc_PackMagazine;
_unit setVariable ["ACE_weapononback", "ACE_M136_CSRS"];

 

then in the units init I have

 

this addeventhandler ["respawn","_this execvm 'rifle.sqf'"]; [this] exec "rifle.sqf";

 

so it works perfectly for whoever is hosting but players trying to join crash before the mission loads. Im thinking

 

"waitUntil {alive player};

 
_unit = player;"
 
is the issue. Whats the appropriate thing to use here?
 
Thanks!

Share this post


Link to post
Share on other sites
waitUntil {alive player};

 

_unit = _this select 0; // Edit- Maff.

 

removeAllWeapons _unit;

removeBackpack _unit;

 

{_unit addMagazine "ACE_Battery_Rangefinder"} foreach [1];

{_unit addMagazine "ACE_20Rnd_762x51_S_M110"} foreach [1,2,3,4];

{_unit addMagazine "ACE_20Rnd_762x51_T_M110"} foreach [1,2,3,4];

_unit addWeapon "ACE_M110";

_unit addWeapon "ACE_Kestrel4500";

_unit addWeapon "ACE_Rangefinder_OD";

_unit addWeapon "ACE_Rucksack_MOLLE_Brown";

_unit addWeapon "GBL_camelbak";

{_unit addMagazine "HandGrenade_West"} foreach [1];

{_unit addMagazine "SmokeShellRed"} foreach [1];

{_unit addMagazine "ACE_Bandage"} foreach [1,2];

{_unit addMagazine "ACE_Morphine"} foreach [1,2];

{_unit addMagazine "ACE_Epinephrine"} foreach [1];

{_unit addMagazine "ACE_Medkit"} foreach [1,2];

{_unit addMagazine "7Rnd_45ACP_1911"} foreach [1];

 

{_unit addMagazine "GBL_US_MRE_MexicanStyleChickenStew"} foreach [1,2];

_unit addWeapon "Colt1911";

[_unit, "ACE_Morphine", 4] call ACE_fnc_PackMagazine;

[_unit, "ACE_Bandage", 4] call ACE_fnc_PackMagazine;

[_unit, "ACE_Medkit", 2] call ACE_fnc_PackMagazine;

[_unit, "ACE_20Rnd_762x51_S_M110", 3] call ACE_fnc_PackMagazine;

[_unit, "GBL_US_MRE_SpaghettiMeatSauce", 4] call ACE_fnc_PackMagazine;

[_unit, "7Rnd_45ACP_1911", 3] call ACE_fnc_PackMagazine;

[_unit, "HandGrenade_West", 1] call ACE_fnc_PackMagazine;

[_unit, "SmokeShellRed", 1] call ACE_fnc_PackMagazine;

[_unit, "GBL_Waterbottle", 6] call ACE_fnc_PackMagazine;

[_unit, "ACE_Battery_Rangefinder", 1] call ACE_fnc_PackMagazine;

_unit setVariable ["ACE_weapononback", "ACE_M136_CSRS"];

 

this addeventhandler ["respawn","_this execvm 'rifle.sqf'"]; [this] exec "rifle.sqf";

 

Why are you using exec after the eventHandler? Should this not be execVM also?

 

I also notice that you are running a script called rifle.sqf but in your post you have called it m110.sqf. Maybe you should double check your script names. 

Share this post


Link to post
Share on other sites

Thanks for the reply! Yea thats what I need help with I think, should it be

 

 

 

this addeventhandler ["respawn","_this execvm 'rifle.sqf']; [this] execvm "rifle.sqf";

?

 

Also I changed it too

 

 

waitUntil {alive player};

 
_unit = _this select 0;
 
removeAllWeapons _unit;
removeBackpack _unit;
 
{_unit addMagazine "ACE_Battery_Rangefinder"} foreach [1];
{_unit addMagazine "ACE_20Rnd_762x51_S_M110"} foreach [1,2,3,4];
{_unit addMagazine "ACE_20Rnd_762x51_T_M110"} foreach [1,2,3,4];
_unit addWeapon "ACE_M110";
_unit addWeapon "ACE_Kestrel4500";
_unit addWeapon "ACE_Rangefinder_OD";
_unit addWeapon "ACE_Rucksack_MOLLE_Brown";
_unit addWeapon "GBL_camelbak";
{_unit addMagazine "HandGrenade_West"} foreach [1];
{_unit addMagazine "SmokeShellRed"} foreach [1];
{_unit addMagazine "ACE_Bandage"} foreach [1,2];
{_unit addMagazine "ACE_Morphine"} foreach [1,2];
{_unit addMagazine "ACE_Epinephrine"} foreach [1];
{_unit addMagazine "ACE_Medkit"} foreach [1,2];
{_unit addMagazine "7Rnd_45ACP_1911"} foreach [1];
 
{_unit addMagazine "GBL_US_MRE_MexicanStyleChickenStew"} foreach [1,2];
_unit addWeapon "Colt1911";
[_unit, "ACE_Morphine", 4] call ACE_fnc_PackMagazine;
[_unit, "ACE_Bandage", 4] call ACE_fnc_PackMagazine;
[_unit, "ACE_Medkit", 2] call ACE_fnc_PackMagazine;
[_unit, "ACE_20Rnd_762x51_S_M110", 3] call ACE_fnc_PackMagazine;
[_unit, "GBL_US_MRE_SpaghettiMeatSauce", 4] call ACE_fnc_PackMagazine;
[_unit, "7Rnd_45ACP_1911", 3] call ACE_fnc_PackMagazine;
[_unit, "HandGrenade_West", 1] call ACE_fnc_PackMagazine;
[_unit, "SmokeShellRed", 1] call ACE_fnc_PackMagazine;
[_unit, "GBL_Waterbottle", 6] call ACE_fnc_PackMagazine;
[_unit, "ACE_Battery_Rangefinder", 1] call ACE_fnc_PackMagazine;
_unit setVariable ["ACE_weapononback", "ACE_M136_CSRS"];

 

yea I have several version of the same script (rifle.sqf is the rifleman version, m110.sqf is the marksman version, etc)

 

Thanks!!!

Share this post


Link to post
Share on other sites

That looks a little more like it. I haven't really used eventHandlers before. Is the script firing on respawn?

 

If you're using ACE, why not use the "Respawn with same weapons/mags" module?

I remember it duplicating backpack gear sometimes so you need to check that out.

Share this post


Link to post
Share on other sites

So it does fire at the begging and on respawn, the problem is that when other players try and join the mission they crash. Whoever hosting has it work perfectly but those trying to join the mission crash when the mission is almost done loading. I also tried when I try "this addeventhandler ["respawn","_this execvm 'rifle.sqf']; [this] execvm "rifle.sqf";" I get "Type Script, Expect Nothing".

 

I can use the respawn with same weapons and mags as a last resort but what I want is for my units to have a fresh custom loadout when they re spawn instead of the same loudout they had when they died.  Its sort of supposed to be like getting freshly deployed when a player respawns.

 

Also just for extra information Im trying to get this working on a dedicated server

Share this post


Link to post
Share on other sites

Does anyone have any ideas? We've been trying to fix this all week and nothing seems to work :(

Share this post


Link to post
Share on other sites

We both overlooked something.

null = [this] execvm "rifle.sqf";

I also moved the addEventHandler to the end of the script.

 

Try it now.

Share this post


Link to post
Share on other sites

Hey bud! Thanks for your help! Really appreciate it!!!

 

So in the unit init it should be 

 

 

 

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

 

then the rifle.sqf should be something like 

 

 

waitUntil {alive player};



_unit = _this select 0;



removeAllWeapons _unit;

removeBackpack _unit;



{_unit addMagazine "ACE_Battery_Rangefinder"} foreach [1];

{_unit addMagazine "ACE_20Rnd_762x51_S_M110"} foreach [1,2,3,4];

{_unit addMagazine "ACE_20Rnd_762x51_T_M110"} foreach [1,2,3,4];

_unit addWeapon "ACE_M110";

_unit addWeapon "ACE_Kestrel4500";

_unit addWeapon "ACE_Rangefinder_OD";

_unit addWeapon "ACE_Rucksack_MOLLE_Brown";

_unit addWeapon "GBL_camelbak";

{_unit addMagazine "HandGrenade_West"} foreach [1];

{_unit addMagazine "SmokeShellRed"} foreach [1];

{_unit addMagazine "ACE_Bandage"} foreach [1,2];

{_unit addMagazine "ACE_Morphine"} foreach [1,2];

{_unit addMagazine "ACE_Epinephrine"} foreach [1];

{_unit addMagazine "ACE_Medkit"} foreach [1,2];

{_unit addMagazine "7Rnd_45ACP_1911"} foreach [1];



{_unit addMagazine "GBL_US_MRE_MexicanStyleChickenStew"} foreach [1,2];

_unit addWeapon "Colt1911";

[_unit, "ACE_Morphine", 4] call ACE_fnc_PackMagazine;

[_unit, "ACE_Bandage", 4] call ACE_fnc_PackMagazine;

[_unit, "ACE_Medkit", 2] call ACE_fnc_PackMagazine;

[_unit, "ACE_20Rnd_762x51_S_M110", 3] call ACE_fnc_PackMagazine;

[_unit, "GBL_US_MRE_SpaghettiMeatSauce", 4] call ACE_fnc_PackMagazine;

[_unit, "7Rnd_45ACP_1911", 3] call ACE_fnc_PackMagazine;

[_unit, "HandGrenade_West", 1] call ACE_fnc_PackMagazine;

[_unit, "SmokeShellRed", 1] call ACE_fnc_PackMagazine;

[_unit, "GBL_Waterbottle", 6] call ACE_fnc_PackMagazine;

[_unit, "ACE_Battery_Rangefinder", 1] call ACE_fnc_PackMagazine;

_unit setVariable ["ACE_weapononback", "ACE_M136_CSRS"];

 

?

 

Thanks again!!!!

Share this post


Link to post
Share on other sites

also I was wondering if it would be an addMPEventHandler or not since its a multiplayer mission on a dedicated server?

 

Thanks again!!!

Share this post


Link to post
Share on other sites

That's it.

Is it working for you?

 

As far as I know there's no real difference between addEventHandler and addMPEventHandler. I could be wrong though.

 

EDIT;

 

Killzone Kid MP EHs are added on every PC and execute on every PC, apart from MPRespawn, that only executes at the locality where unit respawns.

Share this post


Link to post
Share on other sites

I just gave it a shot and it crashed again :( here Im going to try it with the MP event handlers

Share this post


Link to post
Share on other sites

Post your .RPT file or any error messages you or others are getting.

Share this post


Link to post
Share on other sites

You are using the wrong Syntax for the Event handler.

 

You have

addeventhandler ["STRING","STRING"];

when it should be

addEventHandler ["STRING", {CODE}];

Example:

_this addeventhandler ["respawn",{nil = _this execvm 'rifle.sqf'}];

Share this post


Link to post
Share on other sites

You are using the wrong Syntax for the Event handler.

 

You have

addeventhandler ["STRING","STRING"];
when it should be

addEventHandler ["STRING", {CODE}];
Example:

_this addeventhandler ["respawn",{nil = _this execvm 'rifle.sqf'}];

i think u r right but in the init line it shoul look:

this addeventhandler ["respawn",{nil = _this execvm 'rifle.sqf'}];

 

_d = this addEventHandler ["respawn",{_d = _this execvm 'rifle.sqf'}];

Edited by sarogahtyp

Share this post


Link to post
Share on other sites

So it turns out it was arma 2 launcher that was causing my crahses for some weird reason

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

×