Pointshop weapons spawning as spectator

I have added some alternative weapon_zm_improvised models to the pointshop to replace the crowbar. They all seem to function just like I would have hoped except from the fact the sometimes spectators have them equipped on death. The code for the replacement melee weapons is just your typical weapon_zm_improvised script with the loadouts removed, names and models changed.

ITEM.Name = ‘Sledgehammer’
ITEM.Price = 300000
ITEM.Model = ‘models/weapons/w_sledgehammer.mdl’
ITEM.WeaponClass = ‘weapon_zm_sledgehammer’
ITEM.SingleUse = false

function ITEM:OnEquip(ply)
ply:StripWeapon(‘weapon_zm_improvised’)
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end

function ITEM:OnHolster(ply)
ply:StripWeapon(self.WeaponClass)
ply:Give(‘weapon_zm_improvised’)
ply:SelectWeapon(‘weapon_zm_improvised’)
end

function ITEM:PlayerSpawn(ply)
ply:StripWeapon(‘weapon_zm_improvised’)
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)

Code from: http://forum.facepunch.com/showthread.php?t=1286904

I’m not sure but I think the bug is similar to how the trails sometimes stay on.

So, essentially I’m left with a load of traitors getting the crap beaten out of them by invisible people with lightsabers and bats. I’ve had a few ideas on how to fix this but don’t have enough knowledge in Lua to carry them through without being told the code to remove/add.

So my solutions to this are:

  1. Disable pointshop while in spectate mode (opening the pointshop as a spectator seems to make the weapon appear)
  2. Something that makes the swep do no damage if they’re spectator if ( player:Team() != TEAM_SPECTATOR ) then SWEP.Primary.Damage = 50 (probably a load of rubbish since I guessed this up)
  3. Fill up the spectators crowbar slot with something similar to weapon_zm_holstered that just does nothing

As I said, I don’t have very much knowledge with Lua and I’m not desperate for a fix since I can just remove them until I have one or figure out a way myself so please don’t abuse me if I’ve said something blatantly stupid to a coder. Anyhow, I’m grateful for any sort of support and I congratulate anyone who has read to the end of this.


function ITEM:PlayerSpawn(ply)
ply:StripWeapon('weapon_zm_improvised')
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)

For some reason I have noticed this code runs everytime any player spawns.

-snip-

You already have that in there :v

remove the playerspawn hook.

Ah thanks for the suggestions guys :slight_smile: And also on a side note, I’m a fan of your work matt. You have helped out a lot on Facepunch and that is really respectable :slight_smile: