{"name":"setWeaponReloadingTime","operator":null,"title":"setWeaponReloadingTime","type":"command","url":"https://community.bistudio.com/wiki/setWeaponReloadingTime","revid":364086,"updated":"2024-05-03T19:33:29Z","groups":["Weapons"],"status":"ok","replaced_by":[],"games":[{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.60"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.60"},"arma3_since":"0.50","branch":null,"locality":{"argument":"local","effect":"local","server_exec":false},"exec":null,"description":"Sets reloading **phase** on the given weapon's current ammo round.\n\n> [!IMPORTANT]\n> This command does **not** change a weapon's (e.g soldier's rifle) *magazine* reloading time but changes **the ammo reloading state** before the next round is shot.","syntaxes":[{"syntax":"vehicle setWeaponReloadingTime [gunner, muzzleName, reloadTime]","since":null,"effect":null,"exec":null,"params":[{"name":"vehicle","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"vehicle: Object"},{"name":"gunner","type":"Object","optional":false,"default":null,"description":"alive and able gunner operating the targeted turret","types":["Object"],"since":null,"text":"gunner: Object - alive and able gunner operating the targeted turret"},{"name":"muzzleName","type":"String","optional":false,"default":null,"description":"turret's muzzle","types":["String"],"since":null,"text":"muzzleName: String - turret's muzzle"},{"name":"reloadTime","type":"Number","optional":false,"default":null,"description":"in range 0..1 where 0: reload complete, 1: reload started","types":["Number"],"since":null,"text":"reloadTime: Number - in range 0..1 where 0: reload complete, 1: reload started"}],"returns":{"type":"Boolean","types":["Boolean"],"description":"true if given weapon is found","text":"Boolean - true if given weapon is found"},"form":"binary","operator":null,"left":{"text":"vehicle","types":["Object"]},"right":{"text":"[gunner, muzzleName, reloadTime]","types":["Array"]}}],"examples":[{"text":"```sqf\n_success = _vehicle setWeaponReloadingTime [gunner vehicle player, currentMuzzle gunner vehicle player, 0.5];\n```","code":["_success = _vehicle setWeaponReloadingTime [gunner vehicle player, currentMuzzle gunner vehicle player, 0.5];"]},{"text":"Boost RPM:\n\n```sqf\nunit addEventHandler [\"Fired\", {\n    _this # 0 setWeaponReloadingTime [_this # 0, _this # 2, 1/3];\n}];\n```","code":["unit addEventHandler [\"Fired\", {\n\t_this # 0 setWeaponReloadingTime [_this # 0, _this # 2, 1/3];\n}];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["weaponReloadingTime","weapons","magazines","selectWeapon","loadMagazine","weaponState","reload"],"notes":[{"user":".kju","date":"","text":"The description is confusing to me. What the command essential does is to set the reloading state/time of the given weapon. For example you can fire a missile, and make the weapon available to fire again instantly if you apply 0.\nOr you can delay or stop the reload event indefinitely. The 0-1 range is a percentage - the reload time is taken from the weapons's config value (either reloadTime or magazineReloadTime - not sure). The effect is one time only each - it does not modify the weapon's general reload time.\n\nWorks also for infantry weapons - probably useful weapons with longer reload time like sniper weapons or launchers:\n player setWeaponReloadingTime [player,currentWeapon player,0];\nNo idea what's point of the return value."},{"user":"Demellion","date":"","text":"Note that **setWeaponReloadingTime** is only having effect on a current weapon state (loaded projectile) so since the projectile is fired the next one will be reverted to a weapon config defaults. To keep the fire rate speed changed over time, use this code:\n\n```sqf\nplayer addEventHandler [\"FiredMan\", {\n    params [\"\", \"_weapon\", \"_muzzle\"];\n    private _type = _weapon call BIS_fnc_itemType;\n    private _time = -1;\n    switch (_type select 1) do {\n        case \"SniperRifle\" : {_time = 0.5};\n        case \"AssaultRifle\" : {};\n        case \"Handgun\" : {};\n        case \"Rifle\" : {};\n        case \"SubmachineGun\" : {};\n        case \"MachineGun\" : {};\n        case \"Mortar\" : {};\n        case \"GrenadeLauncher\" : {};\n        case \"BombLauncher\" : {};\n        case \"MissileLauncher\" : {};\n        case \"RocketLauncher\" : {};\n        case \"Cannon\" : {};\n        case \"Throw\" : {};\n    };\n    if (_time isEqualTo -1) exitWith {};\n    (vehicle player) setWeaponReloadingTime [(vehicle player), _muzzle, _time];\n}];\n```\n\nThis Event Handler makes the gun of specific type shoot at a desired rate on each weapon state (sniper rifle will shoot 50% faster in this example). For more information about weapon kinds are there, visit BIS_fnc_itemType."}],"categories":["Arma 2: Operation Arrowhead: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 3: Scripting Commands","Command Group: Weapons","Introduced with Arma 2: Operation Arrowhead version 1.60","Scripting Commands","Scripting Commands: Local Effect","Take On Helicopters: Scripting Commands"]}