https://sampwiki.blast.hk/wiki/SetVehicleToRespawn
When the trailer gets attached, set a variable for the truck equaling the trailer's vid. |
//top of script
new trailer;
//ongamemodeinit
trailer = AddStaticVehicle(blablabla
//To respawn it:
SetVehicleToRespawon(trailer);
Create the trailer with an id like
pawn Код:
|
new trailer;
trailer = ...
SetVehicleToRespawn(GetVehicleTrailer);
CMD:droppackages(playerid, params[]) { new string[128], packages, oldj, newj, price; // L1: 0 | L2: 100 | L3: 300 | L4: 700 | L5: 1200 if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 100) packages = 5; else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 300) packages = 10; else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 700) packages = 15; else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 1200) packages = 20; else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] >= 1200) packages = 25; if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(PlayerInfo[playerid][pJob] != JOB_TRUCKER && PlayerInfo[playerid][pVIPJob] != JOB_TRUCKER) return SendClientMessage(playerid, COLOR_GREY, "You are not a Trucker."); if(!IsPlayerInAnyVehicle(playerid) || !IsTruckerVehicle(GetPlayerVehicleID(playerid)) || !IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, COLOR_GREY, "You are not in a Trucker vehicle or you have no trailer attached."); if(!PlayerInfo[playerid][pTPackages]) return SendClientMessage(playerid, COLOR_GREY, "You have no packages on you."); if(PlayerInfo[playerid][pDeliverTruck] != GetPlayerVehicleID(playerid)) return SendClientMessage(playerid, COLOR_GREY, "This is not the vehicle that your packages were loaded to."); if(!IsPlayerInRangeOfPoint(playerid, 5, 2222.5107,-2682.7368,13.5409)) return SendClientMessage(playerid, COLOR_GREY, "You are not near a packages dropoff."); if(Products >= 10000) return SendClientMessage(playerid, COLOR_GREY, "The dropoff can't hold anymore products at the moment."); oldj = strval(RPJL(playerid,JOB_TRUCKER)); PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] ++; Products += packages; if(Products > 10000) Products = 10000; newj = strval(RPJL(playerid,JOB_TRUCKER)); if(PlayerInfo[playerid][pTPackages] == 1) {price = packages*200;} else if(PlayerInfo[playerid][pTPackages] == 2) {price = packages*400;} GiveZaiatMoney(playerid, price); PlayerInfo[playerid][pDeliverTruck] = -1; TruckPackages[GetPlayerVehicleID(playerid)] = -1; format(string, sizeof(string), "* %s has delivered %d products packages to the dropoff.", RPN(playerid), PlayerInfo[playerid][pTPackages]*5); // SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE); format(string, sizeof(string), "* You have delivered {FF6347}%d products{33CCFF} packages for {FF6347}$%d{33CCFF}", PlayerInfo[playerid][pTPackages]*5, price); // new currenttrailer; currenttrailer = (GetVehicleTrailer(GetPlayerVehicleID(playerid))); SetVehicleToRespawn(currenttrailer); SetVehicleToRespawn(GetPlayerVehicleID(playerid));//truckpackages respawn DisablePlayerCheckpoint(playerid); GameTextForPlayer(playerid, "~r~Packages Delivered", 3500, 3); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); if(oldj < newj) { format(string, sizeof(string), "** Your Trucker level is now %d, you can now carry %d packages. **", newj, newj*5); SendClientMessage(playerid, COLOR_YELLOW, string); } format(string, sizeof(string), "Packages Dropoff\n{FFFF00}/droppackages to deliver crates\nAvailable Products: %d/10000", Products); UpdateDynamic3DTextLabelText(ProductsText, COLOR_RED, string); PlayerInfo[playerid][pTPackages] = 0; return 1; }
new currenttrailer; currenttrailer = (GetVehicleTrailer(GetPlayerVehicleID(playerid))); SetVehicleToRespawn(currenttrailer); SetVehicleToRespawn(GetPlayerVehicleID(playerid));//truckpackages respawn