Clientside hooks not working

Title says it all.
None of my clientside hooks are being called.

shared.lua:


SWEP.Author = "BackwardSpy"
SWEP.Contact = "Don't"
SWEP.Purpose = "Destruction"
SWEP.Instructions = "Aim away from face"

SWEP.Spawnable = true
SWEP.AdminSpawnable = true

SWEP.ViewModel = "models/Weapons/v_portalgun.mdl"
SWEP.WorldModel = "models/Weapons/w_suitcase_passenger.mdl"

SWEP.Primary.Clipsize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"

SWEP.Secondary.Clipsize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"

if(SERVER) then
	SWEP.Weight = 10
	SWEP.AutoSwitchTo = true
	SWEP.AutoSwitchFrom = true

	function SWEP:Initialize()
		self:SetWeaponHoldType("melee")
	end
end

if(CLIENT) then
	SWEP.PrintName = "PARTICLE CANNON"
	SWEP.Slot = 4
	SWEP.SlotPos = 2
	SWEP.DrawAmmo = true
	SWEP.DrawCrosshair = true
end

function SWEP:PrimaryAttack()
		print("CLIENT:")
		print(CLIENT)
		print("SERVER:")
		print(SERVER)
end

init.lua:


include('shared.lua')
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_init.lua")

cl_init.lua:


include('shared.lua')

Any help is appreciated.

I think it’s probably because you don’t have any hooks.

If I remember correctly, many shared SWEP hooks aren’t called clientside when playing on singleplayer. If you really need the client to do something, use usermessages and **[SinglePlayer

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=G.SinglePlayer)** to check whether you need to send them or not.

_Kilburn: Ok, I thought it may be something like that. Didn’t know how to fix it though!
Problem is, I want to use a particle emitter, which is only clientside.
How can I get it working in singleplayer?



if SinglePlayer( ) then
  self:CallOnClient( "thisfunc", "" )
end


For no args ( you still need to give at least one or the function errors last I used it )

Eg,



function SWEP:PrimaryAttack( )
  if SinglePlayer( ) then
    self:CallOnClient( "PrimaryAttack", "" )
  end
end


I used to use SendLua in this case until I found an alternative better than sticking a bunch of usermessage hooks on the weapon, which happened to be this.

Ah thanks, that seems very useful :smiley:
I’ll give it a go, and post back with results.