• How would I change a Weapon's Material?
    2 replies, posted
I want to add custom colored weapons on to my server, like a red deagle or a Ak-47 that looks gold, how would I manage to do that, without adding new models. This code is what I am trying to do to make the m16 gold, but ents.SetMaterial isn't working ;/ if CLIENT then SWEP.PrintName = "M16" SWEP.Slot = 2 SWEP.Icon = "VGUI/ttt/icon_m16" end SWEP.Base = "weapon_tttbase" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.Kind = WEAPON_HEAVY SWEP.WeaponID = AMMO_M16 SWEP.Primary.Delay = 0.19 SWEP.Primary.Recoil = 1.6 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "Pistol" SWEP.Primary.Damage = 23 SWEP.Primary.Cone = 0.018 SWEP.Primary.ClipSize = 20 SWEP.Primary.ClipMax = 60 SWEP.Primary.DefaultClip = 20 SWEP.AutoSpawnable = false SWEP.AmmoEnt = "item_ammo_pistol_ttt" SWEP.UseHands = true SWEP.ViewModelFlip = false SWEP.ViewModelFOV = 64 SWEP.ViewModel = "models/weapons/cstrike/c_rif_m4a1.mdl" SWEP.WorldModel = "models/weapons/w_rif_m4a1.mdl" ents:SetMaterial('cs_italy/yellow') SWEP.Primary.Sound = Sound( "Weapon_M4A1.Single" ) SWEP.IronSightsPos = Vector(-7.58, -9.2, 0.55) SWEP.IronSightsAng = Vector(2.599, -1.3, -3.6) function SWEP:SetZoom(state) if CLIENT then return end if not (IsValid(self.Owner) and self.Owner:IsPlayer()) then return end if state then self.Owner:SetFOV(35, 0.5) else self.Owner:SetFOV(0, 0.2) end end -- Add some zoom to ironsights for this gun function SWEP:SecondaryAttack() if not self.IronSightsPos then return end if self.Weapon:GetNextSecondaryFire() > CurTime() then return end bIronsights = not self:GetIronsights() self:SetIronsights( bIronsights ) if SERVER then self:SetZoom(bIronsights) end self.Weapon:SetNextSecondaryFire(CurTime() + 0.3) end function SWEP:PreDrop() self:SetZoom(false) self:SetIronsights(false) return self.BaseClass.PreDrop(self) end function SWEP:Reload() self.Weapon:DefaultReload( ACT_VM_RELOAD ); self:SetIronsights( false ) self:SetZoom(false) end function SWEP:Holster() self:SetIronsights(false) self:SetZoom(false) return true end
Please use code/lua tags to wrap code. Secondly you can call weapon:SetMaterial( ) to reset the material, and for example a nice looking material is Phoenix Storms Chrome as demonstrated below. weapon:SetMaterial( "phoenix_storms/chrome.vtf" );
Sorry about that, and thanks for the reply!
Sorry, you need to Log In to post a reply to this thread.