Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. #include <a_samp>
  2. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  3.  
  4. #define FUEL_TRAILER 584
  5. #define COAL_TRAILER 450
  6. #define BOX_TRAILER 435
  7.  
  8. enum MisLocationsEnum
  9. {
  10. ID,
  11. LoadName[128],
  12. Float:LoadX,
  13. Float:LoadY,
  14. Float:LoadZ,
  15. Float:UnloadX,
  16. Float:UnloadY,
  17. Float:UnloadZ,
  18. Pay,
  19. Trailer
  20. }
  21.  
  22. new MisLocations[][MisLocationsEnum] =
  23. {
  24. {0, "Beer from Red County Brewery to Bone County Diner",-24.4073,-281.8898,5.9985,-305.4319,1315.6797,54.6189, 5980, FUEL_TRAILER},
  25. {1, "Fuel from LV Oil Refinery to LV Dirtring",266.8981,1416.5417,10.2001,1097.5164,1741.7422,10.5474, 5700, FUEL_TRAILER},
  26. {2, "Vehicle Parts from SF Airport ATC to Wang Cars",-1268.8223,13.6925,14.8682,-1986.3477,253.9728,35.8985, 3000, BOX_TRAILER},
  27. {3, "Fuel from SF Oil Refinery to RS Haul",-1016.3634,-688.2434,32.7284,-55.3397,-1138.2479,0.8052, 18770, FUEL_TRAILER}
  28. };
  29.  
  30. #define TEAM_TRUCKER 1
  31.  
  32. new iMissionText[512][MAX_PLAYERS], Float:unx[MAX_PLAYERS], Float:uny[MAX_PLAYERS], Float:unz[MAX_PLAYERS], iPay[MAX_PLAYERS], MissionStatus[MAX_PLAYERS], trailertype = 0;
  33.  
  34. main(){}
  35.  
  36. public OnGameModeInit()
  37. {
  38. AddPlayerClass(72, -2105.3228, -124.2982, 37.2531, 0.0, 0,0,0,0,0,0);//Trucker - SF
  39. return 1;
  40. }
  41.  
  42. public OnPlayerRequestClass(playerid, classid)
  43. {
  44. switch (classid)
  45. {
  46. case 0:
  47. {
  48. GameTextForPlayer(playerid, "Trucker", 3000, 4);
  49. SetPlayerTeam(playerid, TEAM_TRUCKER);
  50. }
  51. }
  52. return 1;
  53. }
  54.  
  55. public OnPlayerCommandText(playerid, cmdtext[])
  56. {
  57. dcmd(work, 4, cmdtext);
  58. dcmd(stopwork, 8, cmdtext);
  59. return 0;
  60. }
  61.  
  62. dcmd_work(playerid, params[])
  63. {
  64. #pragma unused params
  65. if(GetPlayerTeam(playerid) == TEAM_TRUCKER) return T_NewJob(playerid);
  66. return 1;
  67. }
  68.  
  69. dcmd_stopwork(playerid, params[])
  70. {
  71. #pragma unused params
  72. if(GetPlayerTeam(playerid) == TEAM_TRUCKER) return StopWork(playerid);
  73. return 1;
  74. }
  75.  
  76. stock T_NewJob(playerid)
  77. {
  78. new MisRand = random(sizeof(MisLocations));
  79. new vID = GetPlayerVehicleID(playerid);
  80. if(GetVehicleModel(vID)== 403 || GetVehicleModel(vID)== 515 || GetVehicleModel(vID) == 514)
  81. {
  82. if (MisLocations[MisRand][Trailer] == BOX_TRAILER || MisLocations[MisRand][Trailer] == COAL_TRAILER || MisLocations[MisRand][Trailer] == FUEL_TRAILER)
  83. {
  84. if(IsTrailerAttachedToVehicle(vID))
  85. {
  86. MissionStatus[playerid] = 1;
  87. new LoadText[128], Float:x, Float:y, Float:z;
  88. x = MisLocations[MisRand][LoadX];
  89. y = MisLocations[MisRand][LoadY];
  90. z = MisLocations[MisRand][LoadZ];
  91. unx[playerid] = MisLocations[MisRand][UnloadX];
  92. uny[playerid] = MisLocations[MisRand][UnloadY];
  93. unz[playerid] = MisLocations[MisRand][UnloadZ];
  94. iPay[playerid] = MisLocations[MisRand][Pay];
  95. SetPlayerCheckpoint(playerid, x, y, z, 7);
  96. trailertype = MisLocations[MisRand][Trailer];
  97. format(LoadText, 128, "%s",MisLocations[MisRand][LoadName]);
  98. SendClientMessage(playerid, -1, "Mission:");
  99. SendClientMessage(playerid, -1, LoadText);
  100. }
  101. else
  102. {
  103. SendClientMessage(playerid, -1, "You need a trailer!");
  104. }
  105. }
  106. else
  107. {
  108. SendClientMessage(playerid, -1, "You need a trailer...!");
  109. }
  110. }
  111. else
  112. {
  113. SendClientMessage(playerid, -1, "You must be in a Truck to perform this!");
  114. }
  115. return 1;
  116. }
  117.  
  118.  
  119. stock StopWork(playerid)
  120. {
  121. DisablePlayerCheckpoint(playerid);
  122. SendClientMessage(playerid, -1, "You chose to cancel the mission and got fined $100");
  123. GivePlayerMoney(playerid, -100);
  124. MissionStatus[playerid] = 0;
  125. return 1;
  126. }
  127.  
  128. public OnPlayerEnterCheckpoint(playerid)
  129. {
  130. CheckpointEntered(playerid);
  131. return 1;
  132. }
  133.  
  134. stock CheckpointEntered(playerid)
  135. {
  136. new gString[128];
  137. new vID = GetPlayerVehicleID(playerid);
  138. if(!IsTrailerAttachedToVehicle(vID)) return SendClientMessage(playerid, -1, "You need a trailer to unload!");
  139.  
  140. if(MissionStatus[playerid] == 1)
  141. {
  142. DisablePlayerCheckpoint(playerid);
  143. SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);
  144. SendClientMessage(playerid, -1, "Loaded. Please head to the second checkpoint!");
  145. MissionStatus[playerid] = 2;
  146. }
  147. else if(MissionStatus[playerid] == 2)
  148. {
  149. DisablePlayerCheckpoint(playerid);
  150. GivePlayerMoney(playerid, iPay[playerid]);
  151. SendClientMessage(playerid, -1, "Well done! You completed the mission!");
  152. format(gString, 512, "%s has completed mission: %s", pName(playerid), iMissionText[playerid]);
  153. SendClientMessageToAll(-1, gString);
  154. SetPlayerScore(playerid, GetPlayerScore(playerid)+2);
  155. MissionStatus[playerid] = 0;
  156. }
  157. return 1;
  158. }
  159.  
  160. stock pName(PN)
  161. {
  162. new PX[MAX_PLAYER_NAME];
  163. GetPlayerName(PN, PX, sizeof(PX));
  164. return PX;
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement