Jump to content
Sign in to follow this  
Impavido

Odd ammo crate problem.

Recommended Posts

I have a localized script on a MP client that will add weapons and ammo to the crate in front of the player. It adds the items to the crate and the player can see the items on the GEAR list, but they cannot pick the items up.

Has anybody experienced this problem before?

Share this post


Link to post
Share on other sites
why dont you post the script?

_box = nearestobject [player,"USSpecialWeaponsBox"]

_box addweaponcargo ["M16A2",1];
_box addweaponcargo ["M16A2GL",1];
_box addweaponcargo ["M16A4",1];
_box addweaponcargo ["m16a4_acg",1];
_box addweaponcargo ["m16a4_acg_gl",1];
_box addweaponcargo ["m4a1",1];
_box addweaponcargo ["mp5a5",1];
_box addweaponcargo ["m4a1_aim",1];
_box addweaponcargo ["G36a",1];


_box addmagazinecargo ["30rnd_556x45_stanag",30];
_box addmagazinecargo ["30Rnd_556x45_G36",30];
_box addmagazinecargo ["30rnd_9x19_mp5",16];
_box addmagazinecargo ["1rnd_he_m203",16];
_box addmagazinecargo ["flarewhite_m203",6];
_box addmagazinecargo ["1Rnd_Smoke_M203",6];

I use the nearestobject command to compensate for the init of a newly placed box being only activated on the client of the player who built/placed it.

Share this post


Link to post
Share on other sites

Hi,

you want to fill the ammocrate locally, then you have to create the crate locally with the createVehicleLocal command.

Otherwise you have to put the fill command into the crates init line so it will be filled for everyone.

crate setVehicleInit "this addWeaponCargo ['G36a',1]; ..."; processInitCommands;

Share this post


Link to post
Share on other sites
Hi,

you want to fill the ammocrate locally, then you have to create the crate locally with the createVehicleLocal command.

Otherwise you have to put the fill command into the crates init line so it will be filled for everyone.

crate setVehicleInit "this addWeaponCargo ['G36a',1]; ..."; processInitCommands;

Thanks for the input Bon, but that does not appear to be working. The items stated in the setvehicelinit command do not appear at all.

Share this post


Link to post
Share on other sites
Thanks for the input Bon, but that does not appear to be working. The items stated in the setvehicelinit command do not appear at all.

Ok I tried it out for myself and it worked.

I added an action to the player like this:

_action = player addAction ["fill","fill.sqf",[],-1,false,true,"","(count nearestObjects[position player,['USBasicWeaponsBox'],2])>0"];

Simple effect, when the player is close to a weaponcrate this action appears in his action menu. You didn't say exactly how you called your script, but I assume you do it at least a similar way, perhaps you add the action to the crate itself. However, should be better you show us your script and how it is called.

Listen, if you do it the way I did, you CANNOT give the crate as an argument since the parameter is picked at the moment of action assignment and not in the moment of script execution.

Then I just created the fill.sqf file with the content as written above:

_crate = nearestObjects[position player,["USBasicWeaponsBox"],2] select 0;

_crate setVehicleInit "this addWeaponCargo ['G36a',500]"; processInitCommands;

Works in the editor preview, in singleplayer and in multiplayer as host as well as on dedicated server.

Share this post


Link to post
Share on other sites
Ok I tried it out for myself and it worked.

I added an action to the player like this:

_action = player addAction ["fill","fill.sqf",[],-1,false,true,"","(count nearestObjects[position player,['USBasicWeaponsBox'],2])>0"];

Simple effect, when the player is close to a weaponcrate this action appears in his action menu. You didn't say exactly how you called your script, but I assume you do it at least a similar way, perhaps you add the action to the crate itself. However, should be better you show us your script and how it is called.

Listen, if you do it the way I did, you CANNOT give the crate as an argument since the parameter is picked at the moment of action assignment and not in the moment of script execution.

Then I just created the fill.sqf file with the content as written above:

_crate = nearestObjects[position player,["USBasicWeaponsBox"],2] select 0;

_crate setVehicleInit "this addWeaponCargo ['G36a',500]"; processInitCommands;

Works in the editor preview, in singleplayer and in multiplayer as host as well as on dedicated server.

I just got it working with your suggestions Bon!

The first problem was less so due to your code and more so due to me not using ' or "" inside the string for the setvehicleinit command. So a silly oversight on my part wasted your time.

However I now have it working because of your help. Thank you very much Bon.

Share this post


Link to post
Share on other sites

The first problem was less so due to your code and more so due to me not using ' or "" inside the string for the setvehicleinit command. .

Hi Impravido (and everyone else),

such errors can take hours and hours to be detected, time that can be safed by starting ArmA with the additional command

 -showScriptErrors

in the shortcut.

Use it, it makes life much easier.

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  

×