Jump to content
Sign in to follow this  
Ray0210

Ammo disappeared while playing created mission

Recommended Posts

Hey guys,

I am very new to this forum or any forum, so let me know if I am at the right place and such. And also I am pretty new to editing in general, I just know the basics.

I have been editing 4 Missions now and when I hit preview they work just how I want them to work. I exported them and started playing them with my friends. But about 30 seconds after the mission starts our custom loadouts just vanish, at least the ammo. The magazines and grenades.

So after this problem I just put in ammo crates to resupply at the start of the mission. we played for a while and right after a savegame trigger it disappeared again. I must have done something wrong I guess but I have no clue what it is.

Thanks in advance guys!

Share this post


Link to post
Share on other sites

Hi Ray, idk if i can help you but lets see what we can do.

1st, what tool are you using that is giving you troubles as your thread is in this section, and imo if your posting here then your having issues with a tool no?

2, what missions have you edited?

3, what have you done in terms of setting up a custom loadout where you can have a custom loadout, are you using a script, or just putting together your gear at an ammo box?

Share this post


Link to post
Share on other sites

Thanks for your reply. And I just used the ingame editor, no scripts or anything special. I created a co-op mission for me and some friends. I now see why you think about any tools I might be using, i did not notice that at first.

I put the following loadout in the units init line:

removeallweapons this;

removeallassigneditems this;

removeuniform this;

removevest this;

removebackpack this;

this adduniform "U_B_CombatUniform_mcam";

this addvest "V_TacVest_oli";

this addheadgear "H_HelmetSpecB";

this addmagazine "30Rnd_65x39_caseless_mag";

this addmagazine "30Rnd_65x39_caseless_mag";

this addmagazine "30Rnd_65x39_caseless_mag";

this addmagazine "30Rnd_65x39_caseless_mag";

this addmagazine "30Rnd_65x39_caseless_mag";

this addmagazine "30Rnd_65x39_caseless_mag";

this addmagazine "30Rnd_65x39_caseless_mag_Tracer";

this addmagazine "30Rnd_65x39_caseless_mag_Tracer";

this addweapon "arifle_MX_GL_F";

this addprimaryweaponitem "acc_pointer_IR";

this addprimaryweaponitem "muzzle_snds_H";

this addprimaryweaponitem "optic_Aco";

this addmagazine "16Rnd_9x21_Mag";

this addmagazine "16Rnd_9x21_Mag";

this addweapon "hgun_P07_snds_F";

this addmagazine "1Rnd_HE_Grenade_shell";

this addmagazine "1Rnd_HE_Grenade_shell";

this addmagazine "1Rnd_Smoke_Grenade_shell";

this addmagazine "1Rnd_Smoke_Grenade_shell";

this addmagazine "HandGrenade";

this addmagazine "HandGrenade";

this additem "ItemWatch";

this additem "ItemRadio";

this additem "NVGoggles";

this additem "Binocular";

this additem "ItemCompass";

this additem "ItemGPS";

this additem "ItemMap";

this assignitem "Binocular";

this assignitem "NVGoggles";

this assignitem "ItemCompass";

this assignitem "ItemGPS";

this assignitem "ItemMap";

this assignitem "ItemRadio";

this assignitem "ItemWatch";

And like I said it does work in the preview and also when I start up the mission by myself. We only lose our ammo when we start it up together, me, my friends as well as the AI in our group.

Share this post


Link to post
Share on other sites

Hi, ok, from what I understand what you build in the editor is local to the player only, and i think you need a global variable, I cant really say

as I'm not a scripter, although i have dabbled in scripts.

It could be something else probably not what I said above.

What might be easier is to actually create an ammo/gear script where you put one code to call the script vs adding the code in your previous post to every unit.

How are you hosting the mission to play?

Share this post


Link to post
Share on other sites

Ok I can try that tomorrow. I think I need some time for this since i never made a script yet. Seems I am going to watch some tutorials again:p

And I actually know only one way to host a mission. I go to multiplayer, hit "new" and change the name. The I change it to "internet", not lan. And since the end of gamespy we use hamachi.

I hope this answers you question.

Share this post


Link to post
Share on other sites

Ok so I got the scripts working. At least when trying the mission in SP it works. I'm going to try out this mission friday with a friend, let's hope it works!!

Thanks alot so far!

Share this post


Link to post
Share on other sites

So I tried the mission last night with a friend. And it's not working a 100%. It worked for my unit but not for the units my friend used.

I created 3 seperate scripts for 3 units, the teamleader a marksman and a rifleman, and I put a code in the init line of these 3 units. So one that calls the scipt for the teamleader, one that calls the script for the marksman and one for the rifleman.

So we started the mission with just the two of us, and he did not have the correct gear and I did. After that we tried it again but now with the 3rd unit as AI. The same thing happend but only the AI player also had my gear instead of the gear I put in the rifleman script. So I thought, maybe I need to incorporate all tree loadouts in one script. Is that maybe what I did wrong here? Ans if so, how do I do that?

I will show how I did the script next.

// LOADOUT - TEAM LEADER

_unit = _this select 0;

removeallweapons _unit;

removeallassigneditems _unit;

removeallcontainers _unit;

//Gear

_unit addHeadGear "H_Watchcap_blk";

_unit addUniform "U_I_G_Story_Protagonist_F";

_unit addGoggles "G_Bandanna_blk";

_unit addbackpack "B_Parachute";

_unit addweapon "Rangefinder";

_unit additem "ItemCompass";

_unit assignItem "ItemCompass";

_unit additem "ItemMap"; _unit assignItem "ItemMap";

_unit additem "ItemRadio"; _unit assignItem "ItemRadio";

_unit additem "ItemWatch"; _unit assignItem "ItemWatch";

_unit additem "NVGoggles_OPFOR"; _unit assignItem "NVGoggles_OPFOR";

//Ammo

_unit addmagazines ["30Rnd_65x39_caseless_mag",6];

// Primary

_unit addweapon "arifle_MX_Black_F";

_unit addPrimaryWeaponItem "muzzle_snds_H";

_unit addprimaryweaponitem "optic_tws";

_unit addprimaryweaponitem "acc_pointer_IR";

_unit addVest "V_Chestrig_blk";

_unit addmagazines ["DemoCharge_Remote_Mag",6];

_unit addmagazines ["16rnd_9x21_mag",3];

//Secondary

_unit addweapon "hgun_P07_F";

_unit addHandgunItem "muzzle_snds_L";

And for calling the script I put: nul = [this] execVM "teamleader.sqf"; in the init line of the teamleader. And changed teamleader with marskman and rifleman for there scripts.

Share this post


Link to post
Share on other sites

Just a thought, another idea is for the AI to use the script, and you two being the players use something like VAS where you just go to an ammobox at the start of the mission

and create the loadout, gear, weapons you want, and then save it.

Ray check out this thread, there is another member with the same issue that seems to have gotten the issue solved:

http://forums.bistudio.com/showthread.php?181165-Custom-Loadout-not-working-on-more-than-one-player&p=2741027#post2741027

Edited by Günter Severloh

Share this post


Link to post
Share on other sites

Add a locality check to the start of the scripts.

if (!local _unit) exitWith{};

This will prevent them from running on clients where the unit isn't local.

Share this post


Link to post
Share on other sites

Hi ray, all you need to do is just go to armaholic, and download VAS or ASOR gear selector, they are very good and easy to use

Share this post


Link to post
Share on other sites
Hi ray, all you need to do is just go to armaholic, and download VAS or ASOR gear selector, they are very good and easy to use

I think these are terrible, capable of stalling any mission. People usually just can't choose whether or not to take that shorter sleeve uniform or not - god forbid their sunglasses don't match the camo. Plus, if your storyline involves a tactical insertion and whatnot, it's totally immersion breaking to stop and go stare at a crate.

So, these have been pretty much banned from my community, since they're just not viable in a more serious operation - or any mission, really, that's where we stand.

Of course needs vary according to your mission, but I suggest what L3TUC3 said. There're many ways to do that, filtering by locality.

One method I used is in this post. It was intended to solve uniform problems related to JIP, but does a good job avoiding other buggy nonsense.

Share this post


Link to post
Share on other sites
I think these are terrible, capable of stalling any mission. People usually just can't choose whether or not to take that shorter sleeve uniform or not - god forbid their sunglasses don't match the camo. Plus, if your storyline involves a tactical insertion and whatnot, it's totally immersion breaking to stop and go stare at a crate.

So, these have been pretty much banned from my community, since they're just not viable in a more serious operation - or any mission, really, that's where we stand.

Of course needs vary according to your mission, but I suggest what L3TUC3 said. There're many ways to do that, filtering by locality.

One method I used is in this post. It was intended to solve uniform problems related to JIP, but does a good job avoiding other buggy nonsense.

I actually really like the new Arsenal Virtual Ammobox function if you absolutely have a need to allow some customization. It's pretty easy to restrict to only approved items and easy to set up.

https://community.bistudio.com/wiki/Arsenal

init.sqf

["Preload"] call BIS_fnc_arsenal;                        //preload the arsenal for clients

if (isServer) then {                                         //only the server needs to do this

clearItemCargoGlobal policebox;               //remove the items from ammobox called 'policebox'  
clearMagazineCargoGlobal policebox;        //remove the magazines too
clearWeaponCargoGlobal policebox;         //and the guns
};

[policebox,["H_Cap_police","V_TacVest_blk_POLICE","V_Rangemaster_belt","G_Aviator","U_Marshal"],true] call BIS_fnc_addVirtualItemCargo; //we only want the players to have cop-like gear and uniforms
[policebox,["hgun_Pistol_heavy_02_Yorris_F","SMG_01_F"],true] call BIS_fnc_addVirtualWeaponCargo;                      //and only these weapons
[policebox,["6Rnd_45ACP_Cylinder","30Rnd_45ACP_Mag_SMG_01"],true] call BIS_fnc_addVirtualMagazineCargo;         //and the ammo for it
["AmmoboxInit",policebox] call BIS_fnc_arsenal;                                                                                            //once setting the stuff, initialize the arsenal box 

Just a simple example for dirty harry.

Share this post


Link to post
Share on other sites

Depending on the ammobox used i.e. "Box_NATO_AmmoVeh_F" you may also need to remove backpacks with

clearBackpackCargoGlobal policebox;

Share this post


Link to post
Share on other sites

Hi guys, thanks for the replies. I have some options to work with now. Altough I have an additional question about I set up my script. Could it be that the scripts did not work in multiplayer because I did not have waituntil {!isnull player}; _unit = _this select 0;" at the top of the script? I just immediately began with the removal of the default loadout and adding the custom loadout. But doesn't this very line mean the script will start working when a human player takes control of the unit or something? Like I mentioned earlier, I know nothing about scripting. So maybe someone knows a good link where I can learn some of these things.

@ L3TUC3 I also don't really understand your post about locality, what does it do and how?

BTW. The insertion in this particular is by parachute. So a VAS or ammobox on the ground basically ruins the mission start.

Edited by Ray0210

Share this post


Link to post
Share on other sites
I actually really like the new Arsenal Virtual Ammobox function if you absolutely have a need to allow some customization. It's pretty easy to restrict to only approved items and easy to set up.

https://community.bistudio.com/wiki/Arsenal

Oh, yeah, I'm using this for resupplying after a certain point in a mission. Much, much better. Good thing not to have uniforms to choose from. :D

Share this post


Link to post
Share on other sites
Hi guys, thanks for the replies. I have some options to work with now. Altough I have an additional question about I set up my script. Could it be that the scripts did not work in multiplayer because I did not have waituntil {!isnull player}; _unit = _this select 0;" at the top of the script? I just immediately began with the removal of the default loadout and adding the custom loadout. But doesn't this very line mean the script will start working when a human player takes control of the unit or something? Like I mentioned earlier, I know nothing about scripting. So maybe someone knows a good link where I can learn some of these things.

@ L3TUC3 I also don't really understand your post about locality, what does it do and how?

BTW. The insertion in this particular is by parachute. So a VAS or ammobox on the ground basically ruins the mission start.

Locality is a bit of a tricky concept to wrap your head around at first. At it's basic it's which client machine "owns" control of an object and where the scripting command can be executed and how the effects are broadcasted. It can get rather complicated until you understand the mechanics of how the server and client control concepts interact.

For example, let's take the addMagazine and addMagazineGlobal scripting command and compare it's effect when used in a object's (object1, objects can be just about anything units/vehicles/boxes/lampposts etc) editor init box with three clients: Host (a.ka. the server), player1, player2. Init will execute for server and clients pretty much no matter what unless you indicate that it shouldn't.

First addMagazine:

addMagazine will only work if the target is local, but it's effects are global.

Init means that this will execute upon loading the unit into the mission, usually at mission start. It loads the object, and reads a script to execute:

object1 addMagazine "pistolmag";

This will add a pistol magazine to object1, assuming it's got an inventory.

First the server will execute as it's the first to load in the unit. It checks to see if it has possession of the target (object1), then adds the ammo to it, then tells all the other connected clients (global), "I (server) added 1 pistolmag to object1 I have control over, you guys (player1,player2) can now see this". It worked because object1 is local the host.

Then player1 connects and will also execute the init:

object1 addMagazine "pistolmag";

However, object1 is under control by the host (the object is not local for player1). addMagazine in this case will do nothing. The same goes for when player2 loads into the game. Since nothing happened, there is nothing to broadcast globally and there's only 1 pistolmag in object1. The same goes for player2.

In the end there is only 1 magazine in object1's inventory.

Then addMagazineGlobal. This command is different to addMagazine in that the object does not have to be local. This command can be executed on any client and will work.

First the server executes object1's init:

object1 addMagazineGlobal "pistolmag";

This will add a pistol magazine to object1, assuming it's got an inventory. Locality doesn't matter, so it adds the magazine and then tells player1 and player2 there's now 1 more magazine in object1.

Then player1 executes:

object1 addMagazineglobal "pistolmag";

Since locality doesn't matter, player 1 connecting/loading in also adds a magazine to object1. Then tells the server and player2 it added it.

Then player2 executes:

object1 addMagazineglobal "pistolmag";

The same thing as player1 happens, but it gets broadcasted to player1 and the host.

In the end there are now 3 magazines in object1.

Works as intended. However, we don't want everyone to add pistolmagazines when they connect. Just the server. We add a server check to do this.

if (isServer) then { object1 addMagazineGlobal "pistolmag"; };

Now only the server can add one pistolmag at the start of a mission.

Edited by L3TUC3

Share this post


Link to post
Share on other sites

Thank you very much for this explanation, it really makes a lot of sense. I think I understand how I might have to do this now.

If I understand you correctly I put the following in the init.sqf for my 3 player mission, just to be sure I get it.

if (isServer) then {

removeWeaponGlobal;

removeItemGlobal;

removeUniformGlobal;

removeVestGlobal;

removeBackpackGlobal;

player1 addHeadGearGlobal "H_Watchcap_blk";

player1 addUniformGlobal "U_I_G_Story_Protagonist_F";

player1 addGogglesGlobal "G_Bandanna_blk";

player1 addbackpackGlobal "B_Parachute";

player1 addvestGlobal "V_Chestrig_blk";

};

And so on for all 3 players I want a custom gear for?

@rakowozz

I also like the link you posted, I think I might try both just to see what happens ans what works best for me if both work.

But thanks a lot for all of your help guys!

Edited by Ray0210

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  

×