RedM Natives

Weapon components

Categoryweapons
Rows790
Notes from the author
		Weapon components fall into two groups: "model-specific" and "shared". "Shared" are divided into "shortarm", "longarm",
		"shotgun" and "melee_blade".
		Be careful, the "FRAME_VERTDATA" component breaks colors for other components. You must remove it for the other
		components to work.





		Example. Create weapon object, load weapon asset (with native 0x72D4CB5DB927009C) if your ped dont equip this type of weapon yet, and then :


		local entity_id = ENTITY_ID_HERE   --  WEAPON_REVOLVER_CATTLEMAN object id here or ped with equipped WEAPON_REVOLVER_CATTLEMAN
		local weapon_object_model_hash = GetHashKey("WEAPON_REVOLVER_CATTLEMAN")
		local weapon_component_hash1 = GetHashKey("COMPONENT_REVOLVER_CATTLEMAN_BARREL_LONG")    		-- model-specific weapon component
		local weapon_component_hash2 = GetHashKey("COMPONENT_SHORTARM_BARREL_MATERIAL_7")				-- shared weapon component
		local weapon_component_hash3 = GetHashKey("COMPONENT_SHORTARM_BARREL_ENGRAVING_2")				-- shared weapon component
		local weapon_component_hash4 = GetHashKey("COMPONENT_SHORTARM_BARREL_ENGRAVING_MATERIAL_3")		-- shared weapon component

		local function apply_weapon_component(weapon_component_hash)
			local weapon_component_model_hash = Citizen.InvokeNative(0x59DE03442B6C9598,weapon_component_hash)  -- GetWeaponComponentTypeModel
			if weapon_component_model_hash and weapon_component_model_hash ~= 0 then
				RequestModel(weapon_component_model_hash)
				local i = 0
				while not HasModelLoaded(weapon_component_model_hash) and i <= 300 do
					i = i + 1
					Citizen.Wait(0)
				end
				if HasModelLoaded(weapon_component_model_hash) then
					Citizen.InvokeNative(0x74C9090FDD1BB48E,entity_id,weapon_component_hash, weapon_object_model_hash, true)  -- GiveWeaponComponentToEntity
					SetModelAsNoLongerNeeded(weapon_component_model_hash)
				end
			end
		end

		apply_weapon_component(weapon_component_hash1)
		apply_weapon_component(weapon_component_hash2)
		apply_weapon_component(weapon_component_hash3)
		apply_weapon_component(weapon_component_hash4)





		To remove weapon component:

		if Citizen.InvokeNative(0x76A18844E743BF91,entity_id, GetHashKey("COMPONENT_SHORTARM_BARREL_ENGRAVING_2") ) then  -- HasWeaponGotWeaponComponent
		  	Citizen.InvokeNative(0xF7D82B0D66777611,entity_id, GetHashKey("COMPONENT_SHORTARM_BARREL_ENGRAVING_2") )   -- RemoveWeaponComponentFromWeaponObject
		end





		local weapon__to__shared_group_of_components = {
			["WEAPON_BOW"]                           = {},
			["WEAPON_FISHINGROD"]                    = {},
			["WEAPON_KIT_BINOCULARS"]                = {},
			["WEAPON_KIT_CAMERA"]                    = {},
			["WEAPON_KIT_METAL_DETECTOR"]            = {},
			["WEAPON_LASSO"]                         = {},
			["WEAPON_MELEE_CLEAVER"]                 = {"MELEE_BLADE",},
			["WEAPON_MELEE_DAVY_LANTERN"]            = {},
			["WEAPON_MELEE_HATCHET"]                 = {"MELEE_BLADE",},
			["WEAPON_MELEE_HATCHET_DOUBLE_BIT"]      = {"MELEE_BLADE",},
			["WEAPON_MELEE_HATCHET_HUNTER"]          = {"MELEE_BLADE",},
			["WEAPON_MELEE_KNIFE"]                   = {"MELEE_BLADE",},
			["WEAPON_MELEE_KNIFE_JAWBONE"]           = {"MELEE_BLADE",},
			["WEAPON_MELEE_KNIFE_SEAN"]              = {"MELEE_BLADE",},
			["WEAPON_MELEE_LANTERN_ELECTRIC"]        = {},
			["WEAPON_MELEE_MACHETE"]                 = {"MELEE_BLADE",},
			["WEAPON_MELEE_TORCH"]                   = {},
			["WEAPON_PISTOL_M1899"]                  = {"SHORTARM",},
			["WEAPON_PISTOL_MAUSER"]                 = {"SHORTARM",},
			["WEAPON_PISTOL_SEMIAUTO"]               = {"SHORTARM",},
			["WEAPON_PISTOL_VOLCANIC"]               = {"SHORTARM",},
			["WEAPON_REPEATER_CARBINE"]              = {"LONGARM",},
			["WEAPON_REPEATER_EVANS"]                = {"LONGARM",},
			["WEAPON_REPEATER_HENRY"]                = {"LONGARM",},
			["WEAPON_REPEATER_WINCHESTER"]           = {"LONGARM",},
			["WEAPON_REVOLVER_CATTLEMAN"]            = {"SHORTARM",},
			["WEAPON_REVOLVER_CATTLEMAN_DUALWIELD"]  = {"SHORTARM",},
			["WEAPON_REVOLVER_CATTLEMAN_MEXICAN"]    = {"SHORTARM",},
			["WEAPON_REVOLVER_DOUBLEACTION"]         = {"SHORTARM",},
			["WEAPON_REVOLVER_DOUBLEACTION_GAMBLER"] = {"SHORTARM",},
			["WEAPON_REVOLVER_LEMAT"]                = {"SHORTARM",},
			["WEAPON_REVOLVER_NAVY_CROSSOVER"]       = {"SHORTARM",},
			["WEAPON_REVOLVER_SCHOFIELD"]            = {"SHORTARM",},
			["WEAPON_RIFLE_BOLTACTION"]              = {"LONGARM",},
			["WEAPON_RIFLE_SPRINGFIELD"]             = {"LONGARM",},
			["WEAPON_RIFLE_VARMINT"]                 = {"LONGARM",},
			["WEAPON_SHOTGUN_DOUBLEBARREL"]          = {"LONGARM",},
			["WEAPON_SHOTGUN_DOUBLEBARREL_EXOTIC"]   = {"LONGARM",},
			["WEAPON_SHOTGUN_FOLDING"]               = {"LONGARM","SHOTGUN",},
			["WEAPON_SHOTGUN_PUMP"]                  = {"LONGARM","SHOTGUN",},
			["WEAPON_SHOTGUN_REPEATING"]             = {"LONGARM","SHOTGUN",},
			["WEAPON_SHOTGUN_SAWEDOFF"]              = {"SHORTARM","SHOTGUN",},
			["WEAPON_SHOTGUN_SEMIAUTO"]              = {"LONGARM","SHOTGUN",},
			["WEAPON_SNIPERRIFLE_CARCANO"]           = {"LONGARM",},
			["WEAPON_SNIPERRIFLE_ROLLINGBLOCK"]      = {"LONGARM",},
			["WEAPON_THROWN_BOLAS_HAWKMOTH"]         = {},
			["WEAPON_THROWN_BOLAS_INTERTWINED"]      = {},
			["WEAPON_THROWN_BOLAS_IRONSPIKED"]       = {},
			["WEAPON_THROWN_DYNAMITE"]               = {},
			["WEAPON_THROWN_MOLOTOV"]                = {},
			["WEAPON_THROWN_THROWING_KNIVES"]        = {},
			["WEAPON_THROWN_TOMAHAWK"]               = {},
			["WEAPON_THROWN_TOMAHAWK_ANCIENT"]       = {},
			["WEAPON_KIT_CAMERA_ADVANCED"]           = {},
			["WEAPON_MELEE_MACHETE_HORROR"]          = {"MELEE_BLADE",},
			["WEAPON_BOW_IMPROVED"]                  = {},
			["WEAPON_RIFLE_ELEPHANT"]                = {"LONGARM",},
			["WEAPON_REVOLVER_NAVY"]                 = {"SHORTARM",},
			["WEAPON_BOW_IMPROVED_MP"]               = {},
			["WEAPON_LASSO_REINFORCED"]              = {},
			["WEAPON_KIT_BINOCULARS_IMPROVED"]       = {},
			["WEAPON_MELEE_KNIFE_TRADER"]            = {"MELEE_BLADE",},
			["WEAPON_MELEE_MACHETE_COLLECTOR"]       = {"MELEE_BLADE",},
			["WEAPON_MOONSHINEJUG_MP"]               = {},
			["WEAPON_THROWN_BOLAS"]                  = {},
			["WEAPON_THROWN_POISONBOTTLE"]           = {},
			["WEAPON_MELEE_KNIFE_HORROR"]            = {"MELEE_BLADE",},
			["WEAPON_MELEE_KNIFE_RUSTIC"]            = {"MELEE_BLADE",},
			["WEAPON_MELEE_LANTERN_HALLOWEEN"]       = {},
		}
410 rows
#keykey2itemc1c2c3c4Note
401MELEE_BLADEGRIP_TINTCOMPONENT_MELEE_GRIP_TINT_A_8
402MELEE_BLADEGRIP_TINTCOMPONENT_MELEE_GRIP_TINT_B_1
403MELEE_BLADEGRIP_TINTCOMPONENT_MELEE_GRIP_TINT_B_2
404MELEE_BLADEGRIP_TINTCOMPONENT_MELEE_GRIP_TINT_B_3
405MELEE_BLADEGRIP_TINTCOMPONENT_MELEE_GRIP_TINT_B_4
406MELEE_BLADEGRIP_TINTCOMPONENT_MELEE_GRIP_TINT_B_5
407MELEE_BLADEGRIP_TINTCOMPONENT_MELEE_GRIP_TINT_B_6
408MELEE_BLADEGRIP_TINTCOMPONENT_MELEE_GRIP_TINT_B_7
409MELEE_BLADEGRIP_TINTCOMPONENT_MELEE_GRIP_TINT_B_8
410MELEE_BLADEGRIP_TINTCOMPONENT_MELEE_GRIP_TINT_GRAY_BIRCH