halo.add (turning off)

I made a piece of code to add halos to a player if they type in a public chat comment, server-side I have code, which includes the public command bind and:



function BuildPlayerHalo()
	for _, v in pairs( player.GetAll() ) do
		if v:Alive()  then
			if LocalPlayer():GetPos():Distance(v:GetPos()) <= 1500 then
				halo.Add({v}, Color(255,255,255), 2, 2, 5)
			elseif LocalPlayer():GetPos():Distance(v:GetPos()) <= 400 then
				halo.Add({v}, Color(255,255,255), 2, 2, 2)
hook.Add("PreDrawHalos", "BuildPlayerHalo", BuildPlayerHalo)

function ReceivePlayerHalo()
	local ply = net.ReadEntity()
net.Receive("ReceivePlayerHalo", ReceivePlayerHalo)

This works great, but my issue is, I am making a public command to turn halo OFF, but no idea how to do this.

Any help would be greatly appreciated.

Just remove the hook


Read about removing the hook, but how exactly would I call it? Since the file is server-side, can I just do:

hook.Remove( "BuildPlayerHalo", "RemovePlayerHalo" ) 

Within the server-side bind, and it will remove the hook in the client-side file?

[editline]22nd August 2015[/editline]

Tried it, and it appears to be working. Thanks Exploderguy, sorry for such a noobish question

[editline]22nd August 2015[/editline]

Appears to not work, restarted server, and it will add the halo, but now won’t remove. Hrmm… So I guess the original question applies.

hook.Remove read the args, you are using it wrong

Ah just caught that. Sorry. Been working on this awhile so I’m making dumb mistakes. Thanks for the catch.