SA-MP Forums Archive
Trailers - 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: Trailers (/showthread.php?tid=656262)



Trailers - Skylt - 11.07.2018

Hi, I want to make a system of separate loads for a given semi-trailer. Ex. for articulated loads such as sugar, fruits, vegetables etc.
For Tanker Trailer, liquid loads

This is my current code for loads


https://pastebin.com/zSywXZQM

I guess I have to use it IsTrailerAttachedToVehicle(GetPlayerVehicleID(play erid))) but how?


Re: Trailers - Florin48 - 11.07.2018

you need this

https://sampwiki.blast.hk/wiki/Vehicles:Trailers

and this

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


Re: Trailers - Skylt - 11.07.2018

Can you show me an example? Because I do not know how to take it for it


Re: Trailers - Florin48 - 11.07.2018

I'm sorry, I do not know an example and so hard to try to do one.


Re: Trailers - Skylt - 11.07.2018

Maybe someone else has an idea for this?


Re: Trailers - ItsRobinson - 11.07.2018

First you need to declare the trailers when you create them. For example:

PHP код:

new TruckingTrailers[3];
TruckingTrailers[0] = CreateVehicle(/*vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay, addsiren=0*/); //fruit trailer 
Then check to see what trailer is by using something like this:

PHP код:

if(GetVehicleTrailer(GetPlayerVehicleID(playerid)) == TruckingTrailers[0])
{
    
//trailer is fruit trailer

Use IsTrailerAttachedToVehicle to check if the vehicle has ANYTHING attached to it.

For example,

PHP код:

if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)) != 1)
    return print(
"no trailer"); //obviously you can change what happens if there is no trailer attached. 



Re: Trailers - Skylt - 11.07.2018

Okay, I managed to submit something like that but after entering the pickup and entering the command, nothing happens.
I removed the pickups from the code for better visibility

Code: https://pastebin.com/hsQPYA2D


Re: Trailers - Sew_Sumi - 11.07.2018

Quote:
Originally Posted by Skylt
Посмотреть сообщение
I removed the pickups from the code for better visibility
Yet you ignore the indentation which actually makes it harder to read than just having a declaration of an array/enum...


Re: Trailers - Skylt - 11.07.2018

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Yet you ignore the indentation which actually makes it harder to read than just having a declaration of an array/enum...
Version with pickups; https://pastebin.com/zWhG6SGd


Re: Trailers - ItsRobinson - 11.07.2018

PHP код:

for(new i3i++)
{
    if(
GetVehicleTrailer(GetPlayerVehicleID(playerid)) == TruckingTrailers[i])
    {
        
ShowPlayerDialog(playeridTowarDIALOG_STYLE_LIST"Commodity""Wood\nFruits""Zapakuj""Anuluj");
        break;
    }

try that.