Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <izcmd>
- #include <streamer>
- main(){}
- #define COLOR_BLACK 0x000000FF
- #define COLOR_WHITE 0xFFFFFFAA
- #define MAX_TRAILERS 2
- #define DIALOG_MISSIONS1 100
- #define DIALOG_MISSIONS2 101
- enum MissionLocationData
- {
- ID_Mission,
- NamePoint[128],
- Float:UnloadX,
- Float:UnloadY,
- Float:UnloadZ,
- Pay,
- PayScore
- }
- new MissionLocation[][MissionLocationData] =
- {
- {0, "Shop SF", 1799.3297, -1928.4818, 13.3884, 2500, 1},
- {1, "Shop LV", -68.6766, -1588.9198, 2.6172, 2500, 1}
- };
- enum TrailersData
- {
- bool:active,
- ID_Trailer,
- Float:TrailerX,
- Float:TrailerY,
- Float:TrailerZ,
- Float:TrailerA
- };
- new Trailers[MAX_TRAILERS][TrailersData];
- new i_Pay[MAX_PLAYERS], i_PayScore[MAX_PLAYERS], MissionStatus[MAX_PLAYERS];
- new TrailerStatus[MAX_PLAYERS];
- public OnGameModeInit()
- {
- AddPlayerClass(29, 2780.8523, 2596.5154, 10.8203, 0.0, 0, 0, 0, 0, 0, 0);
- AddTrailer(591, 2746.2683, 2635.5381, 11.4273, 206.3398); // Trailer_1
- AddTrailer(591, 2752.8616, 2635.5381, 11.4273, 205.3398); // Trailer_2
- return 1;
- }
- stock AddTrailer(vehicletype, Float:x, Float:y, Float:z, Float:rotation)
- {
- for(new i; i < MAX_TRAILERS; i++)
- {
- if(Trailers[i][active] == false)
- {
- Trailers[i][active] = true;
- Trailers[i][ID_Trailer] = CreateVehicle(vehicletype, x, y, z, rotation, -1, -1, -1);
- Trailers[i][TrailerX] = x;
- Trailers[i][TrailerY] = y;
- Trailers[i][TrailerZ] = z;
- Trailers[i][TrailerA] = rotation;
- return 1;
- }
- }
- return 1;
- }
- forward FinishMissionTrucking(playerid);
- forward TuckerCheckTrail(playerid);
- TimersT(playerid)
- {
- new vehicleid = GetPlayerVehicleID(playerid);
- TrailerStatus[playerid] = GetVehicleTrailer(vehicleid);
- SetTimerEx("TuckerCheckTrail", 1000, false, "i", playerid);
- }
- public TuckerCheckTrail(playerid)
- {
- if(!IsTrailerAttachedToVehicle(TrailerStatus[playerid]))
- {
- GameTextForPlayer(playerid, "Test!", 5000, 2);
- SetTimerEx("FinishMissionTrucking", 30000, false, "i", playerid);
- }
- return 1;
- }
- public FinishMissionTrucking(playerid)
- {
- new vID = GetPlayerVehicleID(playerid);
- new TrailerID = GetVehicleTrailer(vID);
- SetVehicleToRespawn(TrailerID);
- DisablePlayerCheckpoint(playerid);
- MissionStatus[playerid] = 0;
- TrailerStatus[playerid] = 0;
- return 1;
- }
- public OnTrailerUpdate(playerid, vehicleid)
- {
- new vID = GetPlayerVehicleID(playerid);
- if(TrailerStatus[playerid] != 1)
- {
- if(GetVehicleTrailer(vID) == Trailers[0][ID_Trailer])
- {
- new string_mission_i[300];
- format(string_mission_i, sizeof string_mission_i, "Point: %s\nPrize: %d$.", MissionLocation[0][NamePoint], MissionLocation[0][Pay]);
- ShowPlayerDialog(playerid, DIALOG_MISSIONS1, DIALOG_STYLE_MSGBOX, "Info", string_mission_i, "Yes", "Cancel");
- }
- else if(GetVehicleTrailer(vID) == Trailers[1][ID_Trailer])
- {
- new string_mission_i[300];
- format(string_mission_i, sizeof string_mission_i, "Point: %s\nPrize: %d$.", MissionLocation[1][NamePoint], MissionLocation[1][Pay]);
- ShowPlayerDialog(playerid, DIALOG_MISSIONS2, DIALOG_STYLE_MSGBOX, "Info", string_mission_i, "Yes", "Cancel");
- }
- }
- TrailerStatus[playerid] = 1;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_MISSIONS1)
- {
- if(response)
- {
- return Mission_1(playerid);
- }
- else
- {
- return Mission_Cancel(playerid);
- }
- }
- if(dialogid == DIALOG_MISSIONS2)
- {
- if(response)
- {
- return Mission_2(playerid);
- }
- else
- {
- return Mission_Cancel(playerid);
- }
- }
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- CheckpointEntered(playerid);
- return 1;
- }
- stock Mission_1(playerid)
- {
- MissionStatus[playerid] = 1;
- new Float:x, Float:y, Float:z;
- x = MissionLocation[0][UnloadX];
- y = MissionLocation[0][UnloadY];
- z = MissionLocation[0][UnloadZ];
- i_Pay[playerid] = MissionLocation[0][Pay];
- i_PayScore[playerid] = MissionLocation[0][PayScore];
- TimersT(playerid);
- SetPlayerCheckpoint(playerid, x, y, z, 5);
- SendClientMessage(playerid, -1, "Go to the designated destination.");
- return 1;
- }
- stock Mission_2(playerid)
- {
- MissionStatus[playerid] = 1;
- new Float:x, Float:y, Float:z;
- x = MissionLocation[1][UnloadX];
- y = MissionLocation[1][UnloadY];
- z = MissionLocation[1][UnloadZ];
- i_Pay[playerid] = MissionLocation[1][Pay];
- i_PayScore[playerid] = MissionLocation[1][PayScore];
- TimersT(playerid);
- SetPlayerCheckpoint(playerid, x, y, z, 5);
- SendClientMessage(playerid, -1, "Go to the designated destination.");
- return 1;
- }
- stock Mission_Cancel(playerid)
- {
- new Float:x, Float:y, Float:z, Float:a;
- new vid = GetPlayerVehicleID(playerid);
- new vehicleid = GetPlayerVehicleID(playerid);
- GetVehiclePos(vehicleid, x, y, z);
- GetVehicleZAngle(vehicleid, a);
- GetXYInFrontOfPoint(x, y, a, 14);
- DetachTrailerFromVehicle(vid);
- SetVehiclePos(vid, x, y, z);
- TrailerStatus[playerid] = -1;
- return 1;
- }
- stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance)
- {
- x += (distance * floatsin(-angle, degrees));
- y += (distance * floatcos(-angle, degrees));
- }
- stock CheckpointEntered(playerid)
- {
- new vID = GetPlayerVehicleID(playerid);
- if(GetVehicleModel(vID) == 403 || GetVehicleModel(vID) == 515 || GetVehicleModel(vID) == 514)
- {
- if(IsTrailerAttachedToVehicle(vID))
- {
- if(MissionStatus[playerid] == 1)
- {
- DisablePlayerCheckpoint(playerid);
- TogglePlayerControllable(playerid, 0);
- SendClientMessage(playerid, -1, "Unloading...");
- SetTimerEx("unload", 10000, 0, "i", playerid);
- }
- }
- else
- {
- SendClientMessage(playerid, -1, "You do not have a trailer!");
- }
- }
- else
- {
- SendClientMessage(playerid, -1, "You do not have a truck!");
- }
- return 1;
- }
- forward unload(playerid);
- public unload(playerid)
- {
- new vID = GetPlayerVehicleID(playerid);
- new TrailerID = GetVehicleTrailer(vID);
- new string_misja[300];
- TogglePlayerControllable(playerid, true);
- SendClientMessage(playerid, -1, "Unloaded trailer.");
- SetVehicleToRespawn(TrailerID);
- MissionStatus[playerid] = 0;
- TrailerStatus[playerid] = 0;
- GivePlayerMoney(playerid, i_Pay[playerid]);
- SetPlayerScore(playerid, GetPlayerScore(playerid) + i_PayScore[playerid]);
- return 1;
- }
- stock PlayerName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment