• Replace primary weapon with bought weapon from Point shop TTT
    3 replies, posted
Hi guys i need some help with my Lua i have made a point shop on my server and have added a weapon (G3SG1) but when i buy it if i have a Primary weapon already on me it takes the points away and doesnt give me the gun but when i drop the Primary weapon and then purchase the gun i get the gun. Is there a way to purchase the gun and it will drop your old Primary weapon? Thanks my current code is below. [CODE] ITEM.Name = 'G3SG1' ITEM.Price = 5 ITEM.Model = 'models/weapons/w_snip_g3sg1.mdl' ITEM.WeaponClass = "weapon_ttt_g3sg1" ITEM.SingleUse = true function ITEM:OnBuy(ply) ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) end [/CODE]
--snip Outdated code that doesn't work (if it even did in the first place)
The spoon-feeding technique. lol
[QUOTE=Yashirmare;49241404][code] ITEM.Name = 'G3-SG1' ITEM.Price = 5 ITEM.Model = 'models/weapons/w_snip_g3sg1.mdl'' ITEM.WeaponClass = 'weapon_ttt_g3sg1' ITEM.NoPreview = true function ITEM:OnEquip(ply) local slotstrip = 3 for k,v in pairs(ply:GetWeapons())do if v.Slot == slotstrip then ply:StripWeapon(v) end end ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end [/code] Enjoy.[/QUOTE] THANKS SO MUCH YASHIRMARE i literally love you man [editline]4th December 2015[/editline] [QUOTE=Yashirmare;49241404][code] ITEM.Name = 'G3-SG1' ITEM.Price = 5 ITEM.Model = 'models/weapons/w_snip_g3sg1.mdl'' ITEM.WeaponClass = 'weapon_ttt_g3sg1' ITEM.NoPreview = true function ITEM:OnEquip(ply) local slotstrip = 3 for k,v in pairs(ply:GetWeapons())do if v.Slot == slotstrip then ply:StripWeapon(v) end end ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end [/code] Enjoy.[/QUOTE] It works mint i can sell the gun back i can holster it and equip it from store. Really sorry but there is another issue it still doesnt replace the primary weapon with the G3 but will still take the points. but works fine if the players hands are empty. Really sorry appreciate your help immensely.
Sorry, you need to Log In to post a reply to this thread.