Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

Entity:AddEFlag(EFL_NO_THINK_FUNCTION) doesn't work for SWEPs #4717

Open VaasKahnGrim opened 4 years ago

VaasKahnGrim commented 4 years ago

Entity:AddEFlags(EFL_NO_THINK_FUNCTION) does not seem to work with SWEPs

I used the following inside my SWEP base on my test server and despite adding the flag the entity still continued to run its think function.

SWEP.CoolRate = 1
SWEP.CoolDown = 0
SWEP.ShouldThink = false
function SWEP:Initialize()
    self:SetHoldType(self.HoldType)

    if not self.ShouldThink then
        print("Disabling Think Function")
        self:AddEFlags(EFL_NO_THINK_FUNCTION)
    end
end
function SWEP:Think()
    if not self.ShouldThink then --Just in case the initialize function failed
        self:AddEFlags(EFL_NO_THINK_FUNCTION)
    end

    if CurTime() >= self.CoolDown then
        --Entity Logic here
        print("SWEP is Thinking")
        self.CoolDown = CurTime()+self.CoolRate
    end
end
robotboy655 commented 4 years ago

This ties into next think not working, SWEP Think function is not a real engine think function.

So the underlying issue is a duplicate of https://github.com/Facepunch/garrysmod-issues/issues/3269

VaasKahnGrim commented 4 years ago

so basically another instance of not wanting to bother getting a proper Think and NextThink for SWEPs and Nextbots implemented.....got it