Tow Truck, Toolbox changes, restart timer changes and refuelling changes
#35
(03-17-2019, 07:47 PM)Random Wrote: 1000 dollars for only 15%? That sounds quite stupid to me.. especially as cars get broken really easily etc on the server.

And was the tow truck even tested? You simply can not add a vehicle and create that much hype, and then remove the best part of the update.. I suggest reading the suggestion forums a bit more, to see what the community wants.

I mean I think the idea behind increasing toolbox prices is to make mechanics more used, which is perfectly fine as long as there's some cheaper way to repair vehicles when there aren't any mechanics on (such as the gas stations being able to repair it for way cheaper if there's no mechanics).

The tow truck was tested quite extensively by me after I created it, it was even a test car on the main server at one point. I then got rid of it once I realised it can cause crashes and documented it.



Spoiler: Proof (It only says 8 days ago due to a changelog bug, this is actually late october)
[Image: 8NvrqHi.png]

[Image: 9oMUyih.png]



I even mentioned it in the suggestion and gave advice on how to fix the crashing issues it had.


Spoiler: Proof
[Image: WYVWIy8.png]



Even though it says I made the tow truck script, it really isn't my fault as what I created was a really early prototype which I knew had various bugs. I obviously never finished it as I was demoted a bit after, but I did document my test findings and even gave advice on how to fix it after my demotion. I'm being defensive about this as it is my script and I still take responsibility for stuff i've made even though i'm no longer a dev here. I just want to make it clear it was never ready for public release and I didn't hide the fact it causes crashes at all. Even though this isn't really my fault, I will explain the issue and how to fix it as it is still my script in the end.
 
Here's why the issue occurs:

This version of the tow truck was created when I was experimenting with various methods of getting the tow truck to work. In total, I explored the following methods: Having a hook which you manually connect to a car and then you reel it in (point of weld between rope end and car); having the car welded to the tow truck; having it connected to the car via a rope and finally having the car be a parent of the tow truck for the duration the tow. The one which was added in this update was the last one, because this is the version on the Alpha server so it was just directly copied over. Now those who know GLua are likely screaming due to me trying the parent method. I just want to stress this was only intended as a test due to it being the easiest approach. 

So when someone types the command on a vehicle and it passes all the validation checks, the first thing it does is parent it to tow truck. After doing this, I can easily use Entity:SetLocalPos(Vector) and Entity:SetLocalAngles(Angle) to position the vehicle correctly to make it appear as if it's attached behind. This immediately raises a bug though, due to me setting the position and angles after setting it as a parent, the weight of the object does not adjust accordingly to the new position. You can actually see this in Arny's video. The tow truck is leaning to the left as while the object appears to be directly behind, it was offset slightly when he attached it. This means that even though it looks like it is directly behind, the physics bit hasn't updated so it still thinks the weight is on the left side. 

First issue out of the way, lets go onto why it crashes. Well, simple answer is that SetParent is never meant to be used on these type of objects (http://wiki.garrysmod.com/page/Entity/SetParent). I just tried it as it would make it kinda easier, I was not surprised at all when it didn't work. It crashes when you try to park the vehicle as it freaks out about the once child object no longer being there, the server just really really doesn't like this.

How to fix it:

Well it's as simple as it seems, do not use the parent method. As I suggested in the tow truck suggestion thread currently open, exchange it for a rope connection. You can either parent a prop onto the end of the tow truck to use as an attachment point or just get the position of the end, either works. You can still pretty much use all of my existing code too as that will help set the initial position you need before you can attach a rope (just need modifications like WorldToLocal and LocalToWorld instead of the parent method, this is pretty much the same thing though). The only difference is once you get it into position, you attach a rope from the front of the vehicle to the point you defined on the tow truck (or the prop). You can then remove this constraint after you're done towing. It will look way more realistic as it's a rope (so it moves as the truck moves) and it doesn't cause crashes or weird bugs! If you want to fix it but feel kinda lazy, a weld would work just find and needs no additional points to be calculated for all cars.

Feel free to contact me over DM if you need help.
Pollux
Fearless Management
bork
__________________________________________________________________
The following 4 users Like Pollux's post:
  • TASSIA, Alphaverse, Luna, RoCKy


Messages In This Thread
RE: Tow Truck, Toolbox changes, restart timer changes and refuelling changes - by Pollux - 03-17-2019, 11:10 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)