Trailers
#1

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

you need this

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

and this

https://sampwiki.blast.hk/wiki/AttachTrailerToVehicle
Reply
#3

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

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

Maybe someone else has an idea for this?
Reply
#6

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

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
Reply
#8

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...
Reply
#9

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
Reply
#10

PHP код:

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

try that.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)