Solved Get weapon in hand

Discussion in 'Rust Development' started by TheMechanical97, Jan 16, 2016.

  1. Well I need to know whats the weapin in the hand
    OnWeaponFired and make weapon continue shooting until player stop pressing fire button;
    I want to make a semiauto pistol into an automatic one,

    Weapon fired, --- Check if its th pistol, continue firing until stop pressing buton :S

    Any helP?
     
  2. Hey,
    I dont think it is possible to get a gun to keep firing using server scripts, someone else can indeed correct me if i am wrong.

    However, to get the current active item in the hand:
    Code:
    player.GetActiveItem()
    
     
  3. If I want to check if player has in hand the pistol? Tht return an array?
     
  4. Code:
            private void Loaded()
            {
                var _pistolItem = ItemManager.FindItemDefinition("pistol.semiauto");
                foreach (var player in BasePlayer.activePlayerList)
                {
                    if (player.GetActiveItem()?.info.itemid == _pistolItem.itemid)
                    {
                        //do stuff
                    }
                }
            }
    
    Not too sure if this is the best way, but it works.