Trailers respawning. - 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: Trailers respawning. (
/showthread.php?tid=374169)
Trailers respawning. -
Why - 01.09.2012
Hello.
I am in middle of a personal project of scripting a server from scratch, I've made factions and what not and the first job I'm making is trucking. I'm well into it, however I'd like the trailer to despawn as I deliver the truck. At the moment this happens:
[ame]http://www.youtube.com/watch?v=9Yl782Ayfbk[/ame]
Is there a way to get the trailer despawned aswell?
This is my current code:
pawn Code:
if(truckloaded[playerid] == 2 && CPT[playerid] == 3)
{
SendClientMessage(playerid, COLOR_GREEN, "You've returned the truck. You got a skill point and $50 extra.");
PlayerInfo[playerid][pCash] += 50;
PlayerInfo[playerid][pTruckerSkill] += 1;
truckloaded[playerid] = 0;
DisablePlayerCheckpoint(playerid);
CPT[playerid] = 0;
new vehicleid = GetPlayerVehicleID(playerid);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(IsATruck(vehicleid)) SetVehicleToRespawn(vehicleid);
}
return 1;
}
Re: Trailers respawning. -
MarkoN - 02.09.2012
You have to make a variable for a trailer while making it and then destroy it...
pawn Code:
new Trailer;
Trailer = AddStaticVehicle(....)
DestroyVehicle(Trailer);
EDIT: if you have many trailers then make it like this :
pawn Code:
new Trailer[HOWMUCHYOUHAVEINTOTAL];
Trailer[0] = AddStaticVehicle(....)
Trailer[1] = AddStaticVehicle(....)
Re: Trailers respawning. -
Why - 02.09.2012
I thought about that, but how does the script know which trailer to destroy?
Re: Trailers respawning. -
ddnbb - 02.09.2012
Or just:
pawn Code:
new trailer = GetVehicleTrailer(GetPlayerVehicleID(playerid));
SetVehicleToRespawn(trailer);
Guess this is better option than his.
Re: Trailers respawning. -
MarkoN - 02.09.2012
Quote:
Originally Posted by ddnbb
Or just:
pawn Code:
new trailer = GetVehicleTrailer(GetPlayerVehicleID(playerid)); SetVehicleToRespawn(trailer);
Guess this is better option than his. 
|
Yep. Thanks for sharing that , i didn't remember that. reped ya for refreshing it