• Few lua errors with the Spiderman SWEP
    8 replies, posted
Already asked in the questions that don't deserve a thread, thread but seemed to get no response, anyway I'm using the Spiderman SWEP on my server but I'm getting bombarded with errors which are that bad that it actually causes the server to lag for a good 3-4 seconds. I'm trying to use the Spiderman SWEP on my server and I'm being spewed with errors every now and then. I've managed to find the source but I can't seem to fix it. [img]http://puu.sh/83BgD.png[/img] [code] if (!endpos) then if self.Tr.HitPos then -- Line 114 endpos = self.Tr.HitPos end end [/code] The only thing I thought that might fix it would be to check if Tr exists with the following: [code] if (!endpos) then if Tr then if self.Tr.HitPos then endpos = self.Tr.HitPos end end end [/code] but then I just get bombarded with other errors. [img]http://puu.sh/83Bvn.png[/img] With the code being: [code] function ENT:SetEndPos( endpos ) self.Entity:SetNetworkedVector( 0, endpos ) self.Entity:SetCollisionBoundsWS( self.Entity:GetPos(), endpos, Vector() * 0.25 ) -- Line 9 end [/code] Anyone got any ideas? Here's the entire code incase someone needs context: [url]http://pastebin.com/yMeBUXum[/url] The init.lua/cl_init.lua don't contain anything relevant just HUD info or including clientside/serverside files.
Insted of your Tr check actually do something about it: [lua] if (!endpos) then if not self.Tr then self:DoTrace() end -- Check if the trace exists, otherwise dispatch a new one if self.Tr.HitPos then endpos = self.Tr.HitPos end end [/lua] Additionally, you were checking for a variable, not the trace stored in "self.Tr". If you forget about setting the endpos it seems to bugger some stuff up later, try this.
[QUOTE=Internet1001;44573291]Insted of your Tr check actually do something about it: [lua] if (!endpos) then if not self.Tr then self:DoTrace() end -- Check if the trace exists, otherwise dispatch a new one if self.Tr.HitPos then endpos = self.Tr.HitPos end end [/lua] Additionally, you were checking for a variable, not the trace stored in "self.Tr". If you forget about setting the endpos it seems to bugger some stuff up later, try this.[/QUOTE] Thanks for your help, seems like that's one error down but there's many to go: [img]http://puu.sh/8cKF1.png[/img] Looks like the person who coded it seems to have relied on self.speed seems to just be a static variable, so replacing that gets me to here: [img]http://puu.sh/8cKUy.png[/img] Looking into it there's a bunch of variables which are set once it's position is updated and these don't get set when it fails with the original error I provided. 93-97 [code] self:DoTrace() self.speed = 10000 self.startTime = CurTime() self.endTime = CurTime() + self.speed self.dt = -1 [/code] I noticed the code you provided a new trace is carried out when the previous one fails to exist, would it be the same instance with this, setting the variables where they don't exist?
I downloaded the addon though the workshop and it works perfectly. Perhaps the creator updated it and fixed your problem already? Anyway, he removed the ability to jump using right mouse, so I replaced it. You can get it here: [url]http://pastebin.com/hk7GGPM0[/url] It's the shared.lua.
[QUOTE=Internet1001;44577449]I downloaded the addon though the workshop and it works perfectly. Perhaps the creator updated it and fixed your problem already? Anyway, he removed the ability to jump using right mouse, so I replaced it. You can get it here: [url]http://pastebin.com/hk7GGPM0[/url] It's the shared.lua.[/QUOTE] The only difference seems to be I missed out SWEP:Deploy() on my version. It only seems to occur once my server is full (16/16) or when there's a load of people on and it's been up for around 15-20 minutes. I don't suppose it could possibly be when the player dies whilst using the SWEP?
By the way Adzter, how is it going with the gamemode?
[QUOTE=Icejjfish;44577840]By the way Adzter, how is it going with the gamemode?[/QUOTE] It's just this little obstacle I've got overcome, the rest shouldn't be too bad.
Good :D
Thanks to Internet1001 I've managed to get it sorted, for future reference all that was needed to fix it was to put [code]if not inRange or not self.Tr or not self.startTime or not self.Beam then return end[/code] just under [code] function SWEP:UpdateAttack() [/code]
Sorry, you need to Log In to post a reply to this thread.