• Replacing all guns with entity name..
    3 replies, posted
Hello, i'm new to the lua scripting. I'm trying to get all of the entity of weapon_smg to replace with weapon_m4a1. Thanks for the help! EDIT: By the way, I do want to make it in lua code so on round start it replaces it.
I dont quite understand.. So you want a SWEP to override a default weapon in garrysmod? Hm , naming your swep to the weapon you want to override would probably work.
[lua] for k, v in pairs(ents.FindByClass("weapon_smg")) do -- Im not sure if its weapon_smg or weapon_smg1, play around. if(v:IsValid()) then local pos = v:GetPos() local angles = v:GetAngles() v:Remove() local ent = ents.Create("weapon_m4a1") ent:SetModel(bladybladyblah) ent:SetPos(pos) ent:SetAngles(angles) ent:Spawn() ent:Activate() end end [/lua] Remember to run on or after InitPostEntity
Thanks Wilcox, Exactly what I had pictured in my head!
Sorry, you need to Log In to post a reply to this thread.