Trailers that respawn
#1

Hey guys im new to scripting and this is probably something quite easy but Iv searched around heaps and just cannot get the answer and I hope I can find what i need here.
Im working on a RP gamemode and its all going well, iv got one concern right now that i need to fix which is indeed the trailers.
In the gamemode theres a delivery job involving trucks and trailers and what my problem is, is when the trailer detached from the truck it doesnt respawn, even when its in water it never comes back. So what im asking is, If there is a way to make the trailer respawn if its not attached to the truck after about 1 min?
Im working on the zgaming roleplay gamemode if that helps. Thanks guys, apreciate it ALOT!
Reply
#2

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

yeah i saw this but i wasnt sure exactly where to put it or how to go about respawning the trailer, the closest iv got to respawning it is when you deliver the packages it gets the trailer like this:
Код:
new currenttrailer;
    currenttrailer = (GetVehicleTrailer(GetPlayerVehicleID(playerid)));
    SetVehicleToRespawn(currenttrailer);
	SetVehicleToRespawn(GetPlayerVehicleID(playerid));
im not entirely sure about checking oter than that. :/
Reply
#4

Can anyone help me out please?
all i want is for a check to see if a trailer is attatched to the job trucks. I belive the variable of the 3 trucks are:
jCars[1],jCars[2] and jCars[3] and the trailers jTrailers[1], jTrailers[2] and jTrailers[3].
I want to make the trailers of the trucking job respawn if they disconnect from the truck after 1 min but if player reconnects it wont respawn. Thanks guys i really need this and cant figure it out.
Reply
#5

Do this.

You must have scripted the trailers' coordinates under OnGameModeInit, right? And it must be AddStaticVehicle and the coordinates in front right?

You can make it respawn. Check this, this is adding a Hydra to the game with a respawn time of 60 seconds.

Код:
public OnGameModeInit( )
{
    CreateVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60);
    return 1;
}
Like the same way, replace 520 with the ID of the trailer, then replace the X,Y,Z coordinates with your trailer coordinates and then the two colours, and at last your vehicle's delay until the car is respawned without a driver in seconds.

If you still can't understand me, check the differences with AddStaticVehicle and CreateVehicle in here:
https://sampwiki.blast.hk/wiki/CreateVehicle
https://sampwiki.blast.hk/wiki/AddStaticVehicle

Thanks,
Captain_Mani
Reply
#6

hey mani apreciate the reply!

I am incredibly stupid and blind! I had already done this i just wasnt waiting the length of time id set out.. I am grateful you posted because i wouldnt have double checked or even checked at all if you didnt reply. Thank you VERY much! I fully understood everything you said btw, i was just blinded my stupidity. Thanks mate.

Quick question though if someone can help instead of me starting a new thread, I want to redesign my trucking system. I dont know where to put code to always check if something going on.. so How would i go about checking whether any of the three trailers iv setup for the job is connected to one of the three trucks and if so it continues with a bunch of code iv got saved into a command. I want to make the trucking as less command dependant as possible and want the player to drive to the trailer, connect it up and drive to the marker on his/her Mary way. Thanks
Reply
#7

No problem
Reply
#8

quick edit in the post above if you dont mind taking a look? Id be so grateful if you could helpout.
Reply
#9

Can you describe more on what you want?
Reply
#10

Sure, at the moment you pickup the truck & trailer from the same position in the truck depot west of LS just passed the small bridge. You then drive it to a position in LS then type /getpackages then you get packages and a marker shows you to the docks where you take your vehicle and trailer to get dropped off.
I want to make it so you get a truck from the depot, drive it to the place where you type /getpackages, but instead of doing that. The trailers will be in that position then youl just reverse your truck up and the trailer will get attached and then the marker shows you to the docks. It doesnt seem hard i just dont know where im the code or how to check if the certain trailer is attached to the job trucks. I can try explain more if you need but ithink i pretty much covered it all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)