Weapon set material

How to set the material of the active weapons?
That’s what tasted:



--print( ply:GetActiveWeapon())
local wpp = ply:GetActiveWeapon()
wpp:SetMaterial("models/dog/eyeglass")


Sorry for my English.

SetMaterial is for entities only afaik, to set weapon mats you need to edit the vtf?

I found this script.
But I need to simplify it.



local month=tonumber(os.date("%m",time))

local day=tonumber(os.date("%d",time))

function IsChristmas()

local time=os.time()

if month==1 or month==12 then

if month==1 and day<=8 or month==12 and day>=18 then

return true

end

end

return false

end

WeaponsMaterials={}

WeaponsMaterials["Carbonic"]=Material("models/combine_mine/combine_mine03")

WeaponsMaterials["BlackPlastic"]=Material("models/weapons/c_arms_citizen/c_arms_citizen_glove")

WeaponsMaterials["BlueSteel"]=Material("models/props_combine/combine_light001a")

WeaponsMaterials["GreenMasked"]=Material("models/weapons/v_rocket_launcher/rocket launcher sheet")

WeaponsMaterials["YellowEnergy"]=Material("models/items/combinerifle_ammo")

WeaponsMaterials["Asimov"]=Material("models/weapons/skins/asimov")

WeaponsMaterials["Orange"]=Material("models/weapons/skins/awporange")

if SERVER then

hook.Add("WeaponEquip","PS_WeaponsWorldSkins",function(weapon)

timer.Simple(0.1,function()

if weapon:IsValid() then

local Owner=weapon:GetOwner()

local WeaponClass=weapon:GetClass()

if PS!=nil then

if PS.WeaponsSkins!=nil then 

if PS.WeaponsSkins[Owner]!=nil then 

if PS.WeaponsSkins[Owner][WeaponClass]!=nil then 

if PS.WeaponsSkins[Owner][WeaponClass]["MaterialName"]!=nil then

weapon:SetMaterial(tostring(WeaponsMaterials[PS.WeaponsSkins[Owner][WeaponClass]["MaterialName"]]))

end

end

end

end

end

end

end)

end)

end

if CLIENT then

hook.Add("PreDrawViewModel","PS_WeaponsViewSkins",function(vm,ply,weapon)

local LP=LocalPlayer()

if LocalPlayer():GetActiveWeapon():IsValid() then

local LPW=LocalPlayer():GetActiveWeapon():GetClass()

local LPV=LocalPlayer():GetViewModel()

if PS!=nil then

if PS.WeaponsSkins!=nil then 

if PS.WeaponsSkins[LP]!=nil then 

if PS.WeaponsSkins[LP][LPW]!=nil then 

if PS.WeaponsSkins[LP][LPW]["MaterialName"]!=nil then 

for k,v in pairs(LPV:GetMaterials()) do

if v!="models/weapons/v_models/hands/v_hands" then

render.MaterialOverrideByIndex(k-1,WeaponsMaterials[PS.WeaponsSkins[LP][LPW]["MaterialName"]])

end

end

end

end

end

end

end

end

end)



hook.Add("PostDrawViewModel","PS_WeaponsViewSkins",function(vm,ply,weapon)

local LP=LocalPlayer()

if LocalPlayer():GetActiveWeapon():IsValid() then

local LPW=LocalPlayer():GetActiveWeapon():GetClass()

if PS !=nil then

if PS.WeaponsSkins!=nil then 

if PS.WeaponsSkins[LP]!=nil then 

if PS.WeaponsSkins[LP][LPW]!=nil then 

if PS.WeaponsSkins[LP][LPW]["MaterialName"]!=nil then 

render.ModelMaterialOverride()

end

end

end

end

end

end

end)

if false then

hook.Add("PostDrawViewModel","ChristmasWeaponsSkin",function(vm,ply,weapon)

for I=1,vm:GetBoneCount() do

if vm:GetBoneName(I)!="__INVALIDBONE__" and not string.find(vm:GetBoneName(I), "arm", 1, true) and not string.find(vm:GetBoneName(I), "Hand", 1, true) and not string.find(vm:GetBoneName(I), "Finger", 1, true) and  not string.find(vm:GetBoneName(I), "Bone", 1, true) then

local bone = vm:LookupBone(vm:GetBoneName(I))

if not bone then return end

local m = vm:GetBoneMatrix(bone)

if not m then return end

local pos, ang = m:GetTranslation(), m:GetAngles()

if weapon.ViewModelFlip then

ang.r = -ang.r

end

local GlowColor=Color(math.abs(math.cos(I))*255,math.abs(math.sin(I))*255,math.abs(math.sin(I)*-1)*255)

local GlowSize=math.max(math.abs(math.cos(CurTime()+(I*100)))*6.5,1)

render.SetMaterial(Material("sprites/light_glow02_add"))

render.DrawSprite((pos),GlowSize,GlowSize,GlowColor)

render.SetMaterial(Material("sprites/sent_ball"))

render.DrawSprite((pos), 0.35, 0.35,GlowColor)

end

end

end)

end

end


And now in english. :v:

I found this script.
But I need to simplify it.

Then simplify it, we wont do it for you, this forum is not for C+P.

Weapons are entities.

Op, give us all the code you used originally. Including file location.

I always thought weapons differ from ents >-< Dayum I haz to learn moar!

I need to change the material through PointShop

then paste your pointshop code here?! We dont want to know WHERE you change it, we want the CODE which shows HOW you do it completely.