Respawn a trailer.. ? Is it possible ?
#1

So im trying to create a trucker job and im nearly done i just have a problem is it possible to be able to despawn a trailer

I have been trying i just cant do it..

If you need any code just ask

Please help

Thanks
Reply
#2

https://sampwiki.blast.hk/wiki/SetVehicleToRespawn

When the trailer gets attached, set a variable for the truck equaling the trailer's vid.
Reply
#3

Quote:
Originally Posted by Snipa
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/SetVehicleToRespawn

When the trailer gets attached, set a variable for the truck equaling the trailer's vid.
Still confused can you help a little bit please

When your in a truck it automatically picks it up

If you need any more code just ask

Please help

Thanks
Reply
#4

https://sampwiki.blast.hk/wiki/GetVehicleTrailer
Reply
#5

Create the trailer with an id like

pawn Код:
//top of script
new trailer;

//ongamemodeinit


trailer = AddStaticVehicle(blablabla

//To respawn it:

SetVehicleToRespawon(trailer);
Reply
#6

Quote:
Originally Posted by milanosie
Посмотреть сообщение
Create the trailer with an id like

pawn Код:
//top of script
new trailer;

//ongamemodeinit


trailer = AddStaticVehicle(blablabla

//To respawn it:

SetVehicleToRespawon(trailer);
I have at the top of my script

pawn Код:
new trailer;
And on game mode in it

pawn Код:
trailer = ...
But the thing is there are five trailers and the person can choose any on of them and i wont know which one to respawn

Could i do something like this

pawn Код:
SetVehicleToRespawn(GetVehicleTrailer);
If you need any more code just ask

Please help

Thanks
Reply
#7

Please help

Thanks
Reply
#8

Wow someone please help me

Please
Reply
#9

What do you want to do? Respawn the trailer that is attached to the player's vehicle or what? You're not explaining it clear enough. Programming is a LOGICAL process, it doesn't guess when you want a trailer to respawn, it needs to be instructed to do so at a certain event - what is that event?

And don't bump your topics - you aren't more important than everyone else that posts in this section. Read the rules.
Reply
#10

okay dude this is what iv done, im not sure if it helps but here goes,
im a noob so im not sure if its the best way but here:
Iv got a command /droppackages - heres the whole code section.

Код:
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;
}
Im editing the zgamingroleplay GM. What i did is when you type droppackages the truck your in and trailer attached disapears. The part your looking at is:

Код:
new currenttrailer;
    currenttrailer = (GetVehicleTrailer(GetPlayerVehicleID(playerid)));
    SetVehicleToRespawn(currenttrailer);
	SetVehicleToRespawn(GetPlayerVehicleID(playerid));//truckpackages respawn
This respawns the current trailer or and truck the players in. Im sorry if it doesnt work for you but it works great for me. All im trying to figure out now is how to make the trailer respawn if the trailers arent attatched to anything anymore. If anyone knows how i can go about setting the trailer to respawn after about a min of it being apart from the truck thatd be great, also i want it so if the player reconnects the trailer it wont despawn. Thanks alot and i hope i help you guy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)