SA-MP Forums Archive
[Help] Trailer Attached - 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: [Help] Trailer Attached (/showthread.php?tid=512024)



[Help] Trailer Attached - ShoortyFl - 08.05.2014

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



Re: [Help] Trailer Attached - Andreas1331 - 08.05.2014

What function do you want it to be doing?


Re: [Help] Trailer Attached - ShoortyFl - 08.05.2014

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


Re: [Help] Trailer Attached - Kyance - 08.05.2014

https://sampwiki.blast.hk/wiki/IsTrailerAttachedToVehicle ?


Re: [Help] Trailer Attached - Andreas1331 - 08.05.2014

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.


Re: [Help] Trailer Attached - ShoortyFl - 08.05.2014

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..


Re: [Help] Trailer Attached - ShoortyFl - 08.05.2014

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


Re: [Help] Trailer Attached - Konstantinos - 08.05.2014

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.


Re: [Help] Trailer Attached - ShoortyFl - 08.05.2014

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


Re: [Help] Trailer Attached - Konstantinos - 08.05.2014

Yes, that would work.