A question.
#5

Intriguing question. Something like this might work. Haven't tested it, though.

PHP код:
public OnTrailerUpdate(playeridvehicleid)
{
    
// vehicleid is the id of the trailer
    
new playerVehicle GetPlayerVehicleID(playerid);
    
    if(
playerVehicle
    {
        static 
attachedTrailer[MAX_VEHICLES]; 
        new 
currentTrailer GetVehicleTrailer(playerVehicle);
        
        if(
currentTrailer == vehicleid && attachedTrailer[playerVehicle] == 0)
        {
            
OnVehicleTrailerAttached(playerVehicleplayeridvehicleid);
            
attachedTrailer[playerVehicle] = vehicleid;
        }
        else if(
currentTrailer == && attachedTrailer[playerVehicle] == vehicleid)
        {
            
OnVehicleTrailerDetached(playerVehicleplayeridvehicleid);
            
attachedTrailer[playerVehicle] = 0;
        }
    }
    return 
1;
}
OnVehicleTrailerAttached(vehicleidplayeridtrailerid)
{
    
printf("new trailer with id %d attached to vehicle %d, driven by %d"traileridvehicleidplayerid);
}
OnVehicleTrailerDetached(vehicleidplayeridoldtrailerid)
{
    
printf("old trailer with id %d detached from vehicle %d, driven by %d"oldtraileridvehicleidplayerid);

Important to note is that these custom callbacks will only get called if the player that sends those updates is actually in the driver's cabine. A trailer can also be connected by pushing it but in that case this custom callback will not fire until someone actually enters the driver's cabin.
Reply


Messages In This Thread
A question. - by Sjn - 28.11.2015, 10:41
Re: A question. - by Ahmad45123 - 28.11.2015, 10:54
Re: A question. - by Sjn - 28.11.2015, 11:17
Re: A question. - by Ahmad45123 - 28.11.2015, 11:29
Re: A question. - by Vince - 28.11.2015, 11:48
Re: A question. - by Ahmad45123 - 28.11.2015, 11:56
Re: A question. - by Sjn - 28.11.2015, 12:33

Forum Jump:


Users browsing this thread: 1 Guest(s)