Guest User

Untitled

a guest
May 19th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.41 KB | None | 0 0
  1. #include <a_samp>
  2. #include <izcmd>
  3. #include <streamer>
  4.  
  5. main(){}
  6.  
  7. #define COLOR_BLACK 0x000000FF
  8. #define COLOR_WHITE 0xFFFFFFAA
  9.  
  10. #define MAX_TRAILERS 2
  11.  
  12. #define DIALOG_MISSIONS1 100
  13. #define DIALOG_MISSIONS2 101
  14.  
  15. enum MissionLocationData
  16. {
  17. ID_Mission,
  18. NamePoint[128],
  19. Float:UnloadX,
  20. Float:UnloadY,
  21. Float:UnloadZ,
  22. Pay,
  23. PayScore
  24. }
  25. new MissionLocation[][MissionLocationData] =
  26. {
  27. {0, "Shop SF", 1799.3297, -1928.4818, 13.3884, 2500, 1},
  28. {1, "Shop LV", -68.6766, -1588.9198, 2.6172, 2500, 1}
  29. };
  30.  
  31. enum TrailersData
  32. {
  33. bool:active,
  34. ID_Trailer,
  35. Float:TrailerX,
  36. Float:TrailerY,
  37. Float:TrailerZ,
  38. Float:TrailerA
  39. };
  40. new Trailers[MAX_TRAILERS][TrailersData];
  41.  
  42. new i_Pay[MAX_PLAYERS], i_PayScore[MAX_PLAYERS], MissionStatus[MAX_PLAYERS];
  43. new TrailerStatus[MAX_PLAYERS];
  44.  
  45. public OnGameModeInit()
  46. {
  47. AddPlayerClass(29, 2780.8523, 2596.5154, 10.8203, 0.0, 0, 0, 0, 0, 0, 0);
  48.  
  49. AddTrailer(591, 2746.2683, 2635.5381, 11.4273, 206.3398); // Trailer_1
  50. AddTrailer(591, 2752.8616, 2635.5381, 11.4273, 205.3398); // Trailer_2
  51.  
  52. return 1;
  53. }
  54.  
  55. stock AddTrailer(vehicletype, Float:x, Float:y, Float:z, Float:rotation)
  56. {
  57. for(new i; i < MAX_TRAILERS; i++)
  58. {
  59. if(Trailers[i][active] == false)
  60. {
  61. Trailers[i][active] = true;
  62. Trailers[i][ID_Trailer] = CreateVehicle(vehicletype, x, y, z, rotation, -1, -1, -1);
  63. Trailers[i][TrailerX] = x;
  64. Trailers[i][TrailerY] = y;
  65. Trailers[i][TrailerZ] = z;
  66. Trailers[i][TrailerA] = rotation;
  67. return 1;
  68. }
  69. }
  70. return 1;
  71. }
  72.  
  73. forward FinishMissionTrucking(playerid);
  74. forward TuckerCheckTrail(playerid);
  75.  
  76. TimersT(playerid)
  77. {
  78. new vehicleid = GetPlayerVehicleID(playerid);
  79. TrailerStatus[playerid] = GetVehicleTrailer(vehicleid);
  80. SetTimerEx("TuckerCheckTrail", 1000, false, "i", playerid);
  81. }
  82.  
  83. public TuckerCheckTrail(playerid)
  84. {
  85. if(!IsTrailerAttachedToVehicle(TrailerStatus[playerid]))
  86. {
  87. GameTextForPlayer(playerid, "Test!", 5000, 2);
  88. SetTimerEx("FinishMissionTrucking", 30000, false, "i", playerid);
  89. }
  90. return 1;
  91. }
  92.  
  93. public FinishMissionTrucking(playerid)
  94. {
  95. new vID = GetPlayerVehicleID(playerid);
  96. new TrailerID = GetVehicleTrailer(vID);
  97.  
  98. SetVehicleToRespawn(TrailerID);
  99. DisablePlayerCheckpoint(playerid);
  100. MissionStatus[playerid] = 0;
  101. TrailerStatus[playerid] = 0;
  102. return 1;
  103. }
  104.  
  105. public OnTrailerUpdate(playerid, vehicleid)
  106. {
  107. new vID = GetPlayerVehicleID(playerid);
  108.  
  109. if(TrailerStatus[playerid] != 1)
  110. {
  111. if(GetVehicleTrailer(vID) == Trailers[0][ID_Trailer])
  112. {
  113. new string_mission_i[300];
  114. format(string_mission_i, sizeof string_mission_i, "Point: %s\nPrize: %d$.", MissionLocation[0][NamePoint], MissionLocation[0][Pay]);
  115. ShowPlayerDialog(playerid, DIALOG_MISSIONS1, DIALOG_STYLE_MSGBOX, "Info", string_mission_i, "Yes", "Cancel");
  116. }
  117. else if(GetVehicleTrailer(vID) == Trailers[1][ID_Trailer])
  118. {
  119. new string_mission_i[300];
  120. format(string_mission_i, sizeof string_mission_i, "Point: %s\nPrize: %d$.", MissionLocation[1][NamePoint], MissionLocation[1][Pay]);
  121. ShowPlayerDialog(playerid, DIALOG_MISSIONS2, DIALOG_STYLE_MSGBOX, "Info", string_mission_i, "Yes", "Cancel");
  122. }
  123. }
  124. TrailerStatus[playerid] = 1;
  125. return 1;
  126. }
  127.  
  128. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  129. {
  130. if(dialogid == DIALOG_MISSIONS1)
  131. {
  132. if(response)
  133. {
  134. return Mission_1(playerid);
  135. }
  136. else
  137. {
  138. return Mission_Cancel(playerid);
  139. }
  140. }
  141. if(dialogid == DIALOG_MISSIONS2)
  142. {
  143. if(response)
  144. {
  145. return Mission_2(playerid);
  146. }
  147. else
  148. {
  149. return Mission_Cancel(playerid);
  150. }
  151. }
  152. return 1;
  153. }
  154.  
  155. public OnPlayerEnterCheckpoint(playerid)
  156. {
  157. CheckpointEntered(playerid);
  158. return 1;
  159. }
  160.  
  161. stock Mission_1(playerid)
  162. {
  163. MissionStatus[playerid] = 1;
  164. new Float:x, Float:y, Float:z;
  165. x = MissionLocation[0][UnloadX];
  166. y = MissionLocation[0][UnloadY];
  167. z = MissionLocation[0][UnloadZ];
  168. i_Pay[playerid] = MissionLocation[0][Pay];
  169. i_PayScore[playerid] = MissionLocation[0][PayScore];
  170.  
  171. TimersT(playerid);
  172.  
  173. SetPlayerCheckpoint(playerid, x, y, z, 5);
  174. SendClientMessage(playerid, -1, "Go to the designated destination.");
  175. return 1;
  176. }
  177.  
  178. stock Mission_2(playerid)
  179. {
  180. MissionStatus[playerid] = 1;
  181. new Float:x, Float:y, Float:z;
  182. x = MissionLocation[1][UnloadX];
  183. y = MissionLocation[1][UnloadY];
  184. z = MissionLocation[1][UnloadZ];
  185. i_Pay[playerid] = MissionLocation[1][Pay];
  186. i_PayScore[playerid] = MissionLocation[1][PayScore];
  187.  
  188. TimersT(playerid);
  189.  
  190. SetPlayerCheckpoint(playerid, x, y, z, 5);
  191. SendClientMessage(playerid, -1, "Go to the designated destination.");
  192. return 1;
  193. }
  194.  
  195. stock Mission_Cancel(playerid)
  196. {
  197. new Float:x, Float:y, Float:z, Float:a;
  198. new vid = GetPlayerVehicleID(playerid);
  199. new vehicleid = GetPlayerVehicleID(playerid);
  200.  
  201. GetVehiclePos(vehicleid, x, y, z);
  202. GetVehicleZAngle(vehicleid, a);
  203. GetXYInFrontOfPoint(x, y, a, 14);
  204. DetachTrailerFromVehicle(vid);
  205. SetVehiclePos(vid, x, y, z);
  206. TrailerStatus[playerid] = -1;
  207. return 1;
  208. }
  209.  
  210. stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance)
  211. {
  212. x += (distance * floatsin(-angle, degrees));
  213. y += (distance * floatcos(-angle, degrees));
  214. }
  215.  
  216. stock CheckpointEntered(playerid)
  217. {
  218. new vID = GetPlayerVehicleID(playerid);
  219.  
  220. if(GetVehicleModel(vID) == 403 || GetVehicleModel(vID) == 515 || GetVehicleModel(vID) == 514)
  221. {
  222. if(IsTrailerAttachedToVehicle(vID))
  223. {
  224. if(MissionStatus[playerid] == 1)
  225. {
  226. DisablePlayerCheckpoint(playerid);
  227. TogglePlayerControllable(playerid, 0);
  228. SendClientMessage(playerid, -1, "Unloading...");
  229. SetTimerEx("unload", 10000, 0, "i", playerid);
  230. }
  231. }
  232. else
  233. {
  234. SendClientMessage(playerid, -1, "You do not have a trailer!");
  235. }
  236. }
  237. else
  238. {
  239. SendClientMessage(playerid, -1, "You do not have a truck!");
  240. }
  241. return 1;
  242. }
  243.  
  244. forward unload(playerid);
  245. public unload(playerid)
  246. {
  247. new vID = GetPlayerVehicleID(playerid);
  248. new TrailerID = GetVehicleTrailer(vID);
  249. new string_misja[300];
  250.  
  251. TogglePlayerControllable(playerid, true);
  252. SendClientMessage(playerid, -1, "Unloaded trailer.");
  253.  
  254. SetVehicleToRespawn(TrailerID);
  255.  
  256. MissionStatus[playerid] = 0;
  257. TrailerStatus[playerid] = 0;
  258. GivePlayerMoney(playerid, i_Pay[playerid]);
  259. SetPlayerScore(playerid, GetPlayerScore(playerid) + i_PayScore[playerid]);
  260.  
  261. return 1;
  262. }
  263. stock PlayerName(playerid)
  264. {
  265. new name[MAX_PLAYER_NAME];
  266. GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  267. return name;
  268. }
Advertisement
Add Comment
Please, Sign In to add comment