TTT SWEP:Deploy not being called on client

I’m trying to make a system where when a donator picks up a supported weapon the weapon turns gold. I figured the best way to implement this would be to modify weapon_tttbase so that

function SWEP:Deploy()
   return true


function SWEP:Deploy()
   if CLIENT then
     if self.GoldDonationAmount and self.Owner:GetDonationAmount()>=self.GoldDonationAmount then
     return true

(there’s also some code for world models, but that seems to be working fine so don’t worry about that)

Right, so here’s the issue. SWEP:Deploy is never called clientside. It is, however, called serverside. I tried placing the code in SWEP:Think instead, and this worked to an extent but A) it’s messy/laggy, B) the weapon only starts thinking AFTER the deploy animation is finished, resulting in a texture pop and C) some weapons override SWEP:Think because by default it’s empty in weapon_tttbase.

So my question is, basically, is there either a way to fix SWEP:Deploy not being called clientside (it says it should be shared on the wiki) and if not, is there some other hook I can use to achieve my goal? I’m thinking I might try hooking gamemode:Think() next, but ideally I’d like to not have to.

(I know that GetViewModel() and SetMaterial() are also shared, but they don’t do anything if I call them on the server so idk what the purpose of that is)


Try running the set material in SWEP:Initialize?

SWEP:Initialize won’t work because at that point the SWEP doesn’t have an owner.
SWEP:Equip won’t work either because I need to change the view material every time the weapon is deployed though, otherwise when switching weapons the view material is carried between them. (View material is per player not per weapon for some stupid reason)

function SWEP:Think( )
  self.BaseClass:Think( self )
  self.LastOwner = self.LastOwner or NULL

  if CLIENT and self.Owner ~= self.LastOwner then
    self.Owner = self.LastOwner
    self:Deploy( )

Something like that is what you will need to do - you could also use SWEP:CallOnClient if you don’t want to wrangle it yourself.

What’s the latency like with CallOnClient?

EDIT: I couldn’t get CallOnClient working so I bit the bullet and used gamemode think. It works perfectly now, shame it has to run code every frame but it’s fairly lightweight so I doubt it’ll be an issue.

You do call on client like this:
function SWEP:Deploy()
self:CallOnClient(“Deploy”, “”)
– stuff