SA-MP Forums Archive
Help trailer - 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: Help trailer (/showthread.php?tid=653030)



Help trailer mission - KamilPolska - 24.04.2018

How can I give ID_trailer for a trailer with a mission?

For:
Код:
CreateVehicle(591, -2105.3228, -124.2982, 37.2531, 0.0, 1, 1, -1);
Code:
Код:
enum MisLocationsEnum
{
	ID_trailer,
	Status[128],
	MissionName[128],
	Float:UnloadX,
	Float:UnloadY,
	Float:UnloadZ,
	Pay
}

new MisLocations[TRAILERS][MisLocationsEnum] =
{
	{0, "Legal", "Shop SF", -2177.2544, 107.1364, 35.3203, 10000},
	{1, "Illegal", "Gun Shop  SF", -2273.9893, 1.2645, 35.3203, 5000}
};
How can I use? For a trailer with ID_trailer?
Код:
public OnPlayerUpdate(playerid)
{
	new vID = GetPlayerVehicleID(playerid);
	if(GetVehicleModel(vID)== 403 || GetVehicleModel(vID)== 515 || GetVehicleModel(vID) == 514)
	{
	    if(IsTrailerAttachedToVehicle(vID))
	    {
			ShowPlayerDialog(playerid, /*MISSION_1*/999, DIALOG_STYLE_MSGBOX, "INFO", "Point: Shop SF\nPrize: 5000$", "Yes", "No");
		}	
		else
		{
			SendClientMessage(playerid, COLOR_RED, "You need a trailer!");
		}
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "You must be in a Truck to perform this!");
	}
	return 1;
}



Re: Help trailer - KamilPolska - 24.04.2018

help please?


Re: Help trailer - ItsRobinson - 24.04.2018

Not really sure what you're trying to do but if you're trying to get the ID of the trailer you can use GetVehicleTrailer


Re: Help trailer - KamilPolska - 24.04.2018

I meant something like that: https://*********/RyMq9yP_ynM


Re: Help trailer - Phreak - 24.04.2018

Can you explain again what you're trying to achieve?
If you want to store each trailer in ID_Trailer you should do something like this:


PHP код:
new ID_trailer[10// put the number of trailers you will create inside the brackets
And thenID_trailer[0] = CreateVehicle(591 ...);
               
ID_trailer[1] = CreateVehicle(591...); 



Re: Help trailer - KamilPolska - 24.04.2018

I wanted a system like: https://*********/RyMq9yP_ynM
There are two trailers. I have a truck and I drive to the trailer. I connect the trailer and the msgbox dialogue pops up. In the dialogue he writes the unloading point: Shop SF, Status: Legal, Money: 5000 $. When I accept the mission, I have to go to the checkpoint with the trailer to earn money.


Re: Help trailer - ItsRobinson - 24.04.2018

Use Phreak's code above to create the trailers, once you've created the trailers,
under OnPlayerUpdate,
Код:
if(GetVehicleTrailer(vID) == ID_trailer[0]) //trailer 1 (ls)
{
		ShowPlayerDialog(playerid, /*MISSION_1*/997, DIALOG_STYLE_MSGBOX, "INFO", "Point: Shop LS\nPrize: 5000$", "Yes", "No");

}
else if(GetVehicleTrailer(vID) == ID_trailer[1]) //trailer 2 lv
{
		ShowPlayerDialog(playerid, /*MISSION_2*/998, DIALOG_STYLE_MSGBOX, "INFO", "Point: Shop LV\nPrize: 5000$", "Yes", "No");

}
else if(GetVehicleTrailer(vID) == ID_trailer[3]) //trailer 3 sf
{
		ShowPlayerDialog(playerid, /*MISSION_3*/999, DIALOG_STYLE_MSGBOX, "INFO", "Point: Shop SF\nPrize: 5000$", "Yes", "No");

}
If you wanna add the label to the trailers just use Attach3DTextLabelToVehicle under OnGameModeInit (or wherever you create the trailers)

Then under OnDialogResponse it will simply look something like this
Код:
if(dialogid == 999 && response)
{
        SetPlayerCheckpoint(playerid, /*x, y, z, size*/);
        SetPVarInt(playerid, "trucking", 1);
}
and then the event that happens when the player enters the destination under OnPlayerEnterCheckpoint

Код:
if(GetPVarInt(playerid, "trucking") == 1)
{
      DeletePVar(playerid, "trucking");
      SendClientMessage(playerid, 1, "Congratulations");
      //whatever else you wanna do
}
Give it ago, if you get stuck, ask for some more help.

(not tested any of this, but it will most likely work)


Re: Help trailer - KamilPolska - 24.04.2018

THANKS!! Everything works. There is only one problem. I am connecting the trailer and there is a spam dialogue. For example, if I click Yes and start to drive forward, it again shows the dialogue.
So dialogue spam. I click all the time Yes and No it shows dialogue all the time.


Re: Help trailer - ItsRobinson - 24.04.2018

just put
Код:
if(GetPVarInt(playerid, "trucking") != 1)
{
//all the code you have for the trailer
}



Re: Help trailer - Sew_Sumi - 25.04.2018

No, Don't use OnPlayerUpdate checking trailers attached to the vehicle, when there is a trailer callback at your disposal... Use as above said OnTrailerUpdate.





The reason your checkpoint keeps coming back is you aren't checking which dialog they are using and because it's simply looking for the response, it's simply showing it regardless of which dialog you hit.

Sit in that truck, and use any dialog, and it'll likely recreate the checkpoint.