any ideas? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: any ideas? (
/showthread.php?tid=649432)
any ideas? -
PepsiCola23 - 08.02.2018
any ideas on how to automatically re-attach the trailer to a vehicle after it de-attached?
Re: any ideas? -
Eoussama - 08.02.2018
Create an integer variable for each vehicle (
in this case an array) - let's called it
trailerId, and set it to the trailer's ID (
vehicle id because trailers are vehicles) whenever someone attaches a trailer to their vehicles, then to
INVALID_VEHICLE_ID when they detach it.
Create a reoccurring timer, that loops through vehicles and checks if their trailerId equals INVALID_VEHICLE_ID, if not, attach the trailer with that id if it's not attached already.
Re: any ideas? -
PepsiCola23 - 09.02.2018
wouldnt a reoccurring timer that checks trough all vehicles of all players cause some lag?
should i just create a timer that only checks the vehicle to whom you can attach a trailer?would that be more optimized?
Re: any ideas? -
PgMNA - 09.02.2018
you can use timer for it like when player enter vehicle settimer in timer it will check is trailer is attached or not
https://sampwiki.blast.hk/wiki/IsTrailerAttachedToVehicle and if not attached use this
https://sampwiki.blast.hk/wiki/AttachTrailerToVehicle
hope u will understand.