Jump to content
Sign in to follow this  
cychou

unlimited ammo for static weapon with custom reloading delay.

Recommended Posts

Hello, i'm trying to add to static weapon (igla, stinger...etc) unlimited ammo with a specific delay between each round fired.

i already know how to add the unlimited ammo for the unit : this addeventhandler ["fired", {(_this select 0) setvehicleammo 1}]

but i need a solution to add a delay between each round fired to limit spamming.

adding additionnal magazine in the unit init line instead of unlimited ammo doesn't reduce the fire rate.

i know that there is the sleep function. but how could i put both (unlimited ammo + sleep) so i can get unlimited ammo with a slow rate of fire.

what would be the correct code ?

---------- Post added at 01:54 AM ---------- Previous post was at 12:05 AM ----------

ok, after hard time to find something on the forums i found a solution :

the code is put in the unit init (here the Stinger twin launcher static weapon) :

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

this give unlimited ammo, and add a delay between each round fired.

sleep 12 set the required time in seconds between each round fired.

setVehicleAmmo 0.5 this value must be set to 0.5 in order to maintain a constant delay. if the value is set to 1 the delay will break and the weapon will start to spam fire again..

Edited by cychou

Share this post


Link to post
Share on other sites

Hey I use a great script that will Spawn units that will man static weapons that you place down from the editor. The static weapons have unlimited ammo that fire at a normal rate of fire. It also has a function that will respawn the gunner if the man is killed. You can turn that off if you want. I am working on some other stuff that I am having issues and is taking all my time but I will try to post it this weekend if you reply to this post.

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  

×