Track when a vehicle connects to a trailer.
#1

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?
Reply
#2

Код:
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 ^^
Reply
#3

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

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;
}
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)