[Help] with destroying Trailer.
#1

When the player enters the checkpoint i want to destroy the truck AND the trailer at the moment only the truck gets destroyed. You will see what i mean by my code. Also when the truck and trailer gets destroyed how to i get them to respawn? Createvechile or addstaticvehcile? or something else.

Код:
public OnPlayerEnterCheckpoint(playerid) {

new vehicleid=GetPlayerVehicleID( playerid );
if (IsPlayerInVehicle(playerid,vehicleid) ) {

if ( IsTrailerAttachedToVehicle(vehicleid) )
 {
GameTextForPlayer(playerid, "~r~Congratulations! Here, have 5k", 2000, 3);
GivePlayerMoney(playerid, 5000);
DisablePlayerCheckpoint(playerid);
RemovePlayerFromVehicle(playerid);
DestroyVehicle(vehicleid);
}
else {
GameTextForPlayer(playerid, "~r~You need a trailer. Noob", 2000, 3);
}}

else { DisablePlayerCheckpoint(playerid);
}

return 1;
}
Thanks in advance,
Josh

Reply
#2

DestroyVehicle will bring back a Static Vehicle. I'm sure DestroyVehicles destroys a Created Vehicle for good.
Reply
#3

Ok thanks but do you know how to destroy the trailer?
Reply
#4

Make the Vehicles have an ID, or just the trailer.
pawn Код:
// Top
new Trailer;
// OnGameModeInit
Trailer = AddStaticVehicle(/*VEHICLEID, X, Y, Z, R, C, C*/);

//Than you can Destroy it where you want ..
DestroyVehicle(Trailer);
Reply
#5

Ok thanks heaps.
Reply
#6

Quote:
Originally Posted by Bofhead
Ok thanks heaps.
No problem buddy. You look like a hard worker, you've been posting threads for the last few hours & you're making some progress.
Reply
#7

Yes. Thanks for noticing, i am only 15 years old and looking at going into the programing industry, thought i should get some practice now in my spare time.

Thanks again,
Josh
Reply
#8

One more question. Your way of destroying the trailer works, but i have 10 different trailer spawns, how would i destroy the trailer that is being towed but not all the rest? Also new trailer; can on‌y = 1 of my 10 static vehicles.

thanks heaps,
Josh
Reply
#9

pawn Код:
new trailer[10];
trailer[0] = CreateVehicle(...
trailer[1] = CreateVehicle(...
//ect ect
Reply
#10

Thanks, this is called an array right? Sorry for my stupid questions, but i started programming only 3 days ago =)
Reply


Forum Jump:


Users browsing this thread: