[Help] Trailer Attached
#1

So i've create the job system for truck driver, and now i'm wondering, how can i create if, for example, if the trailer is this

TrailerOne it does some function
TrailerTwo does some other function
TrailerThree does some other function.

so in this command if trailerone is attached it will do some function, others will do some other functions:

pawn Код:
CMD:command(playerid, params[])
{
    // Trailer One
    {
        // Function Here
    }
    // Trailer Two
    {
        // Function Here
    }
    // Trailer Two
    {
        // Function Here
    }
    return 1;
}
Trailers:

Код:
TrailerOne[0] = AddStaticVehicleEx(435,1808.1000000,-2021.4000000,14.2000000,90.0000000,245,245,15); //Trailer 1
TrailerOne[1] = AddStaticVehicleEx(435,1808.1000000,-2021.4000000,14.2000000,90.0000000,245,245,15); //Trailer 1

TrailerTwo[0] = AddStaticVehicleEx(450,1672.6000000,-2075.1000000,14.3000000,270.0000000,93,1,15); //Trailer 2
TrailerTwo[1] = AddStaticVehicleEx(435,1808.1000000,-2021.4000000,14.2000000,90.0000000,245,245,15); //Trailer 1

TrailerThree[0] = AddStaticVehicleEx(591,1808.2000000,-2035.6000000,14.2000000,90.0000000,245,245,15); //Trailer 3
TrailerThree[1] = AddStaticVehicleEx(591,1808.2000000,-2035.6000000,14.2000000,90.0000000,245,245,15); //Trailer 3
Reply
#2

What function do you want it to be doing?
Reply
#3

Well the function is not important, just to detect which trailer is attached.
Reply
#4

https://sampwiki.blast.hk/wiki/IsTrailerAttachedToVehicle ?
Reply
#5

I'm going to guess you created an enum for the trailers at the top of your script.
So you could make something like this.

Код:
enum carTrailers // Enum for carTrailers variable
{
	TrailerOne,
	TrailerTwo,
	TrailerThree,
	
	TrailerFour,
	TrailerFive,
	TrailerSix
}
new Cars[carTrailers];
and then make.

Код:
CMD:command(playerid, params[])
{
	new CarCheck = GetPlayerVehicleID(playerid);
	if (CarCheck == carTrailers[TrailerOne])
	{
	    // Put your function here
	}
}
I think this should work, but not sure as you're not sitting inside the trailer obviously.
Reply
#6

But u setted it like CarCheck = GetPlayerVehicleID(playerid);

it will give the vehicle's id, not check if the trailer is attached, and i did not create the enum, cuz i don't think that i need it, i simply created variable that i use number by number. In this enum u gave me solution for one(maybe) trailer, and i have them few..
Reply
#7

To explain, i want to get Trailer Model, if model is 450 function does something, if model is 435 something other.
Reply
#8

https://sampwiki.blast.hk/wiki/GetVehicleTrailer

Check if the vehicleid the function returned is equal to TrailerOne[0] or TrailerOne[1] and do something. Then check for the rest too.
Reply
#9

Well i just searched trough internet and now im wondering can i create something like this

if( GetVehicleModel( GetVehicleTrailer( GetPlayerVehicleID(playerid) ) ) == 591)

if trailer model is 591 function will continue
Reply
#10

Yes, that would work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)