• Crash Client on disconnect
    3 replies, posted
Hello all, Why this code make my players crash when it click on disconnect or retry ? [b]Context[/b] : When i connect to my server and look at the emitter no problem, i play etc ... but when i click disconnect button later or i type retry command on the console, my gmod crash instantaneously with no error but without this code no crash at all .. but no emitter too... [lua] include("shared.lua") AddCSLuaFile() function ENT:Draw() end function ENT:Initialize() self.Emit = ParticleEmitter(self:GetPos()) self:InitializeAsClientEntity() end function ENT:Think() for i = 1, 10 do local part = self.Emit:Add(self.Material, self:GetPos()) if part then part:SetVelocity(Vector(math.random(-180, 180), math.random(-180, 180), 90):GetNormal() * 80) part:SetStartAlpha(100) part:SetEndAlpha(100) part:SetDieTime(15) part:SetLifeTime(0) part:SetStartSize(1) part:SetEndSize(1) part:SetRoll(math.random(0, 360)) part:SetRollDelta(math.random(-10, 10)) part:SetAirResistance( 100 ) part:SetGravity(Vector(0, 0, -10)) end --self.Emit:Finish() -- CRASH end --self.Emit:Finish() -- CRASH Seems to cause a RunTime Error if part then part:SetNextThink(CurTime() + 1) end end function ENT:OnRemove() if self.Emit then self.Emit:Finish() self.Emit = nil end end [/lua]
function ENT:OnRemove() if self.Emit then [B]self.Emit:Finish() self.Emit = nil[/B] end end
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/InitializeAsClientEntity]Entity:InitializeAsClientEntity[/url]: "Only works on entities fully created clientside, and as such it has currently no use due to the lack of clientside ents.Create". Is this entity fully clientside?
I don't know :/ but thanks for your reply anyway [editline]13th January 2017[/editline] I have tested, no crash for the moment :D
Sorry, you need to Log In to post a reply to this thread.