Results 1 to 10 of 10

Thread: Unit can't fire after addWeapon?

  1. #1

    Unit can't fire after addWeapon?

    Hi,

    Anyone found that units can't fire after giving them weapons?
    You have to press the set fire button ( burst / full / semi ) before you can shoot.
    Also sometimes the units are not getting any weapon at all.

    This is the code I am using and i'm running it from each units init line.

    Code:
    _unit = _this select 0;
    
    if(isServer) then
    {
    	removeAllWeapons _unit;
    	switch (round random 4) do
    	{
    		case 0:
    		{
    			_unit addMagazine	"30Rnd_762x39_AK47";
    			_unit addMagazine	"30Rnd_762x39_AK47";
    			_unit addMagazine	"30Rnd_762x39_AK47";
    			_unit addWeapon	"AK_47_M";
    		};
    		case 1:
    		{
    			_unit addMagazine	"30Rnd_556x45_Stanag";
    			_unit addMagazine	"30Rnd_556x45_Stanag";
    			_unit addMagazine	"30Rnd_556x45_Stanag";
    			_unit addWeapon	"M4A1";
    		};
    		case 2:
    		{
    			_unit addMagazine	"30Rnd_556x45_Stanag";
    			_unit addMagazine	"30Rnd_556x45_Stanag";
    			_unit addMagazine	"30Rnd_556x45_Stanag";
    			_unit addWeapon	"M16A4";
    		};
    		case 3:
    		{
    			_unit addMagazine	"30Rnd_545x39_AK";
    			_unit addMagazine	"30Rnd_545x39_AK";
    			_unit addMagazine	"30Rnd_545x39_AK";
    			_unit addWeapon	"AK_74";
    		};
    	};
    };

    Regards,

  2. #2
    Code:
    _unit selectWeapon "AK_74_M"
    While weapon classnames often work (because muzzle classnames default to weapon classnames for weapons with only 1 muzzle), I found that the correct syntax for selectWeapon is to give it a MUZZLE classname (ex. weapons with GLs have multiple muzzles, you need to use a muzzle classname for selectWeapon to work for these weapons).

    Also (this might be why your units sometimes don't get weapons), instead of round, use floor. Round will round both up and down (which could give you a 4).

  3. #3
    Private First Class
    Join Date
    Jun 18 2009
    Posts
    38
    Author of the Thread
    Thanks Big Dawg. The round thing was kind of obivious


    ---------- Post added at 09:24 PM ---------- Previous post was at 09:23 PM ----------

    Ah one more thing. Am I right to check that only the server will be giving out weapons?

  4. #4
    Well, addWeapon/addMagazine effects are public in MP (could you imagine what it'd be like if they weren't lol), so it shouldn't matter where you execute it, but yea he server seems logical (you don't want it running on each client and giving everybody extra ammo).

  5. #5
    Private First Class
    Join Date
    Jun 18 2009
    Posts
    38
    Author of the Thread
    Sorry I did ask this in another post but it's lost in a sea of topics now

    In my DM mission I have only added units set as playable ( which I believe is the correct way? )

    When the mission starts the player isn't given any weapons for some reason, however, any AI that are playing do seem to be given the weapons from the script.

    As a test I just replaced _unit with player in the script and now the player will be given the weapons but the AI not...

    This one is driving me mad.

  6. #6
    Where are you calling the script from?

  7. #7
    Private First Class
    Join Date
    Jun 18 2009
    Posts
    38
    Author of the Thread
    Units init line

  8. #8
    Try changing isServer to 'local _unit'.

  9. #9
    Private First Class
    Join Date
    Jun 18 2009
    Posts
    38
    Author of the Thread
    OK. Will that still give weapons to AI aswell?
    I can't test at the minute.

  10. #10
    It should.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •