Think Hook and ulx cloak function dont work.

Hey dear Facepunch Users, today im working on a fix for the camoflage workshop addon.
U know that the original one makes a double ragdoll bug because it calls v:SetNoDraw in a Think Hook.
I fixed the function using the Ulib Invisible Feature.
But now i have to problem if i use the camoflage swep and go out of this mode and want to go into !cloak with ULX it dont works. If i switch the weapon to another weapon of my inventory the ulx !cloak works.
Thats the main function i fixed, only there needs a edit:


if SERVER then
	local function CheckPlayerStill()
	 for k,v in ipairs(player.GetAll()) do
	 if v:GetNWBool("CamoEnabled") then 
		if v:GetVelocity():Length() <= 1 then
		   v:DrawShadow( false )
		   v:SetMaterial( "models/effects/vol_light001" )
		   v:SetRenderMode( RENDERMODE_TRANSALPHA )
		   v:Fire( "alpha", visibility, 0 )
		   v:GetTable().invis = { vis=visibility, wep=v:GetActiveWeapon() }
	           else
		   v:DrawShadow( true )
		   v:SetMaterial( "" )
		   v:SetRenderMode( RENDERMODE_NORMAL )
		   v:GetTable().invis = nil
		end
         elseif !v:GetNWBool("CamoEnabled") then
         activeWeapon = v:GetActiveWeapon():GetClass();
         if activeWeapon == ("weapon_camo") then 
         v:DrawShadow( true )
		v:SetMaterial( "" )
		v:SetRenderMode( RENDERMODE_NORMAL )
		v:GetTable().invis = nil
else
		end

else
		end

	end 
	end
	hook.Add("Think","SetPlayerCamoAlpha",CheckPlayerStill)

What i have to change?

Ok i know that the Think Hooks every Tick from the server so its not possible to change it i guess because the hook calls every second the full function. maybe it could be possible to remove the hook after deactivate the camo think and activate the hook while running the camo thing. Or i can make out of the weapon thing another “if sentence that never used in gmod” does someone know one? No if i add another if sentence it dont works… because it has to call the function one time… maybe a timer… idk how to fix that…

how is that possible?

The weird spacing makes it a bit difficult to read, but I think you localized your function inside some statements, and then added it to the hook outside of that (where it doesn’t exist).

Could have misread it tho

Hey Skere i fixed it on a unclean way i just use a timer that calls when i turn the camo mode off i gonna test it now on my server and if it works i will post it.

Updated Code:

Ok new Bug… if a other user is moving while im going out of this cloak effect i get not uncloaked. what causes this?