Jump to content
Sign in to follow this  
celery

Unlimited ammo made simple!

Recommended Posts

I just thought I'd share this. :)

Put this in the init field of the desired unit:

this addEventHandler ["Fired",{[_this select 0,getNumber (configFile/"CfgAmmo"/(_this select 4)/"explosive")] spawn {if (_this select 1==1) then {sleep 0.75};_this select 0 setVehicleAmmo 1}}]

And it will have unlimited ammo with no need to reload, no scripts or anything else required! Works on vehicles, too. There is a check for explosive ammo to limit the full auto spammage of rocket and grenade launchers, but the sleep time can be edited or deleted. :p

Share this post


Link to post
Share on other sites
this addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}]

Share this post


Link to post
Share on other sites
this addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}]

Yes, that is the simple version. The one in the first post is an all-purpose one that takes launchers into account.

Share this post


Link to post
Share on other sites

yes, sorry, i didnt get it first. so without the explosives ammo check people could use grenade launchers like gatling guns? never tried that before, must be pretty cool ^^

Share this post


Link to post
Share on other sites
this addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}]

is there a way to put this on trigger for only active player (me) and not my other unit?

i created a mission i don't want to put this script to every units cause i don't want them can use unlimited ammo when i'm not playing them so a trigger like radio call could be useful

Share this post


Link to post
Share on other sites
is there a way to put this on trigger for only active player (me) and not my other unit?

i created a mission i don't want to put this script to every units cause i don't want them can use unlimited ammo when i'm not playing them so a trigger like radio call could be useful

// This is used in the init of the unit in the mission.
this addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}];

// This is used to add the eventhandler at a later time.
_unitname addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}];

Share this post


Link to post
Share on other sites

Thanks for sharing Celery...and Bon as well for his little snippet!

Share this post


Link to post
Share on other sites
I just thought I'd share this. :)

Put this in the init field of the desired unit:

this addEventHandler ["Fired",{[_this select 0,getNumber (configFile/"CfgAmmo"/(_this select 4)/"explosive")] spawn {if (_this select 1==1) then {sleep 0.75};_this select 0 setVehicleAmmo 1}}]

And it will have unlimited ammo with no need to reload, no scripts or anything else required! Works on vehicles, too. There is a check for explosive ammo to limit the full auto spammage of rocket and grenade launchers, but the sleep time can be edited or deleted. :p

this addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}]

Why isn't this working for me? When I click on OK, another box appears with nothing but another OK button, and then I click on that, and I'm still on the menu to edit the unit.

Share this post


Link to post
Share on other sites

I'm trying to get a vehicle to respawn with infinite ammo. I'm using http://www.armaholic.com/page.php?id=6080#comments Can't figure out how to get

this addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}] 

to stick in the vehicle init after it respawns. This is the full code I'm trying to use

veh = [this, 1, "this addEventHandler [""Fired"",{(_this select 0) setVehicleAmmo 1}]"] execVM "vehicle.sqf" 

Share this post


Link to post
Share on other sites

Hi mate... the instructions there say ...

If you you want to set the INIT field of the respawned vehicle, first set all other

values, then set INIT commands. Those must be inside quotations.

Like this:

veh = [this, 15, 10, 5, TRUE, FALSE, "this setDammage 0.5"] execVM "vehicle.sqf"

So..I think you need to do exactly that.... fill out all the missing fields (in red) and it might work.

Share this post


Link to post
Share on other sites
Hi mate... the instructions there say ...

If you you want to set the INIT field of the respawned vehicle, first set all other

values, then set INIT commands. Those must be inside quotations.

Like this:

veh = [this, 15, 10, 5, TRUE, FALSE, "this setDammage 0.5"] execVM "vehicle.sqf"

So..I think you need to do exactly that.... fill out all the missing fields (in red) and it might work.

The problem is that since he chose quotes to surround the object being passed, the "interpreter" or whatever you want to call it, screws up when it comes across the second quotation mark. I will highlight where I am talking about.

veh = [this, 10, 120, 0, TRUE, FALSE, "this addEventHandler ["Fired",{[_this select 0,getNumber (configFile/"CfgAmmo"/(_this select 4)/"explosive")] spawn {if (_this select 1==1) then {sleep 0.75};_this select 0 setVehicleAmmo 1}}]"] execVM "vehicle.sqf";

The error I get says "missing ]"

Any help would be appreciated. I am new to all this scripting, but would it be possible to concatenate that whole thing into a string variable, then would the following work?

veh = [this, 10, 120, 0, TRUE, FALSE, "this addEventHandler [sTRING_VARIABLE]"] execVM "vehicle.sqf";

Share this post


Link to post
Share on other sites

Quotes within quotes need to be double quotes eg "whatever ;hint ""example"";" or replace the internal quotes with ' eg "whatever ;hint 'example';"

I prefer single as it's easier to read.

veh = [this, 10, 120, 0, TRUE, FALSE, "this addEventHandler ['Fired',{[_this select 0,getNumber (configFile/'CfgAmmo'/(_this select 4)/'explosive')] spawn {if (_this select 1==1) then {sleep 0.75};_this select 0 setVehicleAmmo 1}}]"] execVM "vehicle.sqf";

Share this post


Link to post
Share on other sites

how would i go about making a rocket launcher full auto from a debug in game on A3 cause i want to mess around with friends, i know this is the wrong place to post it however i cant make new threads and there is no related threads in A3

Share this post


Link to post
Share on other sites

Execute this code from debug console:

(vehicle player) addEventHandler ["Fired", {_ammo = getNumber (configFile >> "CfgMagazines" >> (_this select 5) >> "count"); (_this select 0) setAmmo [_this select 1, _ammo]}];

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  

×