I’ve written a custom melee weapon replacer for my TTT server. Everythign works fine, you equip the item in the pointshop, it removes the default melee weapon and equips the new one instead. You sell the weapon, you get the default one back etc. When you sell the weapon if dead, you obviously only get the default one back when you’re alive.
The issue I’m having is as follows:
When you load into my server and you’re in the spectate mode (the one you’re in when you join a server while a round is still ongoing) If you sell your weapon at this point in the pointshop, the spectator WILL get the default weapon. He can then fly around and melee people in spectate mode untill the current round has ended. From this point everything functions normally again.
I reckon what I’m missing here is a check to see if he’s in the “joining” spectate mode since IsSpec() is clearly not working on this bit. Any help would be greatly appreciated.
ITEM.Name ='Baseball Bat' ITEM.Price = 5000 ITEM.Model ='models/weapons/w_basebat.mdl' ITEM.WeaponClass = 'weapon_zm_basebat' ITEM.SingleUse = false ITEM.SubCategory = "Melee" function ITEM:OnEquip(ply) ply:StripWeapon('weapon_zm_improvised') ply:Give('weapon_zm_basebat') ply:SelectWeapon('weapon_zm_basebat') end function ITEM:OnHolster(ply) ply:StripWeapon('weapon_zm_basebat') ply:Give('weapon_zm_improvised') ply:SelectWeapon('weapon_zm_improvised') end function ITEM:OnSell(ply) if !ply:IsSpec() or ply:Alive() then ply:StripWeapon('weapon_zm_basebat') ply:Give('weapon_zm_improvised') else ply:StripWeapon('weapon_zm_basebat') end end