SA-MP Forums Archive
Track when a vehicle connects to a trailer. - 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: Track when a vehicle connects to a trailer. (/showthread.php?tid=583678)



Track when a vehicle connects to a trailer. - Rokzlive - 30.07.2015

Im trying to find an efficient way to track and see when a player connects their vehicle to a trailer. Unfortunately, samp does not offer a function like this.

How do your guys recommend going about this?


Re: Track when a vehicle connects to a trailer. - Roberto80 - 30.07.2015

Код:
IsAnyTrailerAttachedToVehicle(vehicleid)
{
	new trailerid = GetVehicleTrailer(vehicleid);
	new modelid = GetVehicleModel(trailerid);
	if(modelid == 435 || modelid == 450 || modelid == 591 || modelid == 606 || modelid == 607 ||
	modelid == 610 || modelid == 569 || modelid == 590 || modelid == 584 || modelid == 570 ||
    modelid == 608 || modelid == 611) return true;	

	return false;
}
Try this ^^


Re: Track when a vehicle connects to a trailer. - Vince - 30.07.2015

I'm not exactly sure how this works, but you might give it a shot: https://sampwiki.blast.hk/wiki/OnTrailerUpdate


Re: Track when a vehicle connects to a trailer. - Lorenc_ - 30.07.2015

Quote:
Originally Posted by Vince
Посмотреть сообщение
I'm not exactly sure how this works, but you might give it a shot: https://sampwiki.blast.hk/wiki/OnTrailerUpdate
That will indeed work however it will spam countlessly because it reacts similarly to OnPlayerUpdate.

I would use the callback Vince suggested and probably write instructions as such:

pawn Код:
new
    p_TrailerConnected[ MAX_PLAYERS ];

public OnTrailerUpdate( playerid, vehicleid )
{
    if( p_TrailerConnected[ playerid ] != vehicleid ) {
        // connected, write code here
        p_TrailerConnected[ playerid ] = vehicleid;
    }
    return 1;
}



AW: Track when a vehicle connects to a trailer. - Kaliber - 30.07.2015

You can also trigger this with this: http://pastebin.com/7hmEiSQx

Mediafire: http://www.mediafire.com/download/yp...cd/trailer.inc

For this just use CreateTrailer...and i hope 50 Trailer are enough, you can redefine it in the script

So you have OnTrailerAttached and OnTrailerDetached it can be very usefull, because the player can detach the trailer also without the function DetachTrailerFromVehicle

PS: I didn't tested it...but it should work

Have Fun