Question - REP ++ - 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: Question - REP ++ (
/showthread.php?tid=546556)
Question - REP ++ -
buburuzu19 - 16.11.2014
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 !!!
Re: Question - REP ++ -
HY - 16.11.2014
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
Re: Question - REP ++ -
Capua - 16.11.2014
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
|
Instead of that use if(vehicleid == Truck) to see whether vehicleid equals with Truck ID. Using only 1 '=' would result in an error.
Re: Question - REP ++ -
buburuzu19 - 16.11.2014
And how to destroy the trailer and the truck if player exit vehicle?
Thanks!
Re: Question - REP ++ -
Capua - 16.11.2014
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
Re: Question - REP ++ -
buburuzu19 - 16.11.2014
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!!!
Re: Question - REP ++ -
buburuzu19 - 16.11.2014
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.
Re: Question - REP ++ -
buburuzu19 - 16.11.2014
Pls help.
Re: Question - REP ++ -
buburuzu19 - 16.11.2014
UP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
How to spawn trailers from the game?
Re: Question - REP ++ -
sammp - 16.11.2014
Quote:
Originally Posted by buburuzu19
UP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
How to spawn trailers from the game?
|
AttachTrailerToVehicle(trailer_id, Truck);