Question - REP ++
#1

I want to make a truck sistem like this:
Player enter truck: checkpoint appear , player go with the truck into the checkpoint and then a TRAILER spawns and FALLS down from the sky and auto-attach to the vehicle.
How to do this ? What to use ?
Thanks! REP !!!
Reply
#2

pawn Код:
#include <a_samp>

new Truck; // Vehicle

public OnFilterScriptInit()
{
    CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) // When he enter in vehicle
{
    if(vehicleid = Truck) // If he enter in that vehicle
    {
        SetPlayerCheckpoint(playerid, X, Y, Z, 3.0); // Will sets a checkpoint to him.
    }
    return 1;
}

public OnPlayerEnterCheckpoint(playerid) // He enters in checkpoint
{
    AttachTrailerToVehicle(450, Truck); // Will attach a trailer to his vehicle
    return 1;
}
https://sampwiki.blast.hk/wiki/AttachTrailerToVehicle
https://sampwiki.blast.hk/wiki/OnPlayerEnterCheckpoint
https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle
https://sampwiki.blast.hk/wiki/CreateVehicle
Reply
#3

Quote:
Originally Posted by HY
Посмотреть сообщение
pawn Код:
#include <a_samp>

new Truck; // Vehicle

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) // When he enter in vehicle
{
    if(vehicleid = Truck) // If he enter in that vehicle
    {
        SetPlayerCheckpoint(playerid, X, Y, Z, 3.0); // Will sets a checkpoint to him.
    }
    return 1;
}

public OnPlayerEnterCheckpoint(playerid) // He enters in checkpoint
{
    AttachTrailerToVehicle(450, Truck); // Will attach a trailer to his vehicle
    return 1;
}
And on OnGameModeInit you should add:
pawn Код:
Truck = CreateVehicle(...);
https://sampwiki.blast.hk/wiki/CreateVehicle

Quote:
Originally Posted by HY
Посмотреть сообщение
pawn Код:
if(vehicleid = Truck)
Instead of that use if(vehicleid == Truck) to see whether vehicleid equals with Truck ID. Using only 1 '=' would result in an error.
Reply
#4

And how to destroy the trailer and the truck if player exit vehicle?
Thanks!
Reply
#5

Find OnPlayerExitVehicle with ctrl+f. In there you should check whether vehicleid is equal with Truck, if it is then use DestroyVehicle. I'll let you try to figure it out yourself. Tell me if you can't get it working.. shouldn't require much of thinking

https://sampwiki.blast.hk/wiki/DestroyVehicle
Reply
#6

i tried guys but nothing happens.
I modified the code a little bit because my vehicles are loading from MYSQL , AttachTrailerToVehicle(450, 249);
where 249 = VehicleID from MySQL but nothing happens. No trailer comes up and no trialer is attaching and i added the code with "AttachTrailerToVehicle" but seems to not work
UP!!!
Reply
#7

I tried a new method:
AttachTrailerToVehicle(252, 249);

252 -> TRAILER ID FROM SQL DATABASE (VehicleID)
249 -> TRUCK ID FROM SQL DATABASE (VehicleID)
But i don't want to add trailers in SQL DATABASE , i want that the code spawn trailers and auto attach them and after the transport is done the code destroys them.
Reply
#8

Pls help.
Reply
#9

UP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
How to spawn trailers from the game?
Reply
#10

Quote:
Originally Posted by buburuzu19
Посмотреть сообщение
UP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
How to spawn trailers from the game?
AttachTrailerToVehicle(trailer_id, Truck);
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)