Gguiz007

Untitled

Apr 17th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.35 KB | None | 0 0
  1. // After a truckdriver entered a checkpoint, a timer is created. This function is called when the timer runs out
  2. public Trucker_LoadUnload(playerid)
  3. {
  4. if (APlayerData[playerid][InConvoy] == true)
  5. {
  6. if (APlayerData[playerid][JobStep] == 1)
  7. {
  8. PlayerTextDrawSetString(playerid, MissionText[playerid], " ");
  9. APlayerData[playerid][JobStep] = 2;
  10. PlayerTextDrawSetString(playerid, MissionText[playerid], TXT_WaitingMembersToLoadCargo);
  11. APlayerData[playerid][Carregando] = true;
  12. PlayerInfo[playerid][Carregou] = true;
  13. }
  14.  
  15. if (APlayerData[playerid][JobStep] == 3)
  16. {
  17. PlayerTextDrawSetString(playerid, MissionText[playerid], " ");
  18. APlayerData[playerid][JobStep] = 4;
  19. PlayerTextDrawSetString(playerid, MissionText[playerid], TXT_WaitingMembersToUnLoadCargo);
  20. APlayerData[playerid][Carregando] = false;
  21. PlayerInfo[playerid][Carregou] = false;
  22. }
  23.  
  24. DisablePlayerCheckpoint(playerid);
  25. TogglePlayerControllable(playerid, 1);
  26.  
  27. return 1;
  28. }
  29.  
  30. switch (APlayerData[playerid][JobStep])
  31. {
  32. case 1: // Player must load his goods
  33. {
  34. // Setup local variables
  35. new StartLoc[50], EndLoc[50], Load[50], RouteText[255], Float:x, Float:y, Float:z, UnloadMsg[100];
  36. // Set JobStep to 2 (unloading goods)
  37. APlayerData[playerid][JobStep] = 2;
  38. // Delete the loading-checkpoint
  39. DisablePlayerCheckpoint(playerid);
  40. // Get the startlocation, endlocation and the load texts
  41. format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
  42. format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
  43. format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);
  44.  
  45. APlayerData[playerid][StartTime] = GetTickCount();
  46.  
  47.  
  48. // Randomly set the load as overloaded (15% chance the load is overloaded)
  49. Trucker_SetRandomOverloaded(playerid);
  50.  
  51. PlayerTextDrawSetString(playerid, MissionText[playerid], " ");
  52. // Pre-format the missiontext (there may be some parts appended when overloaded/mafiaload
  53. format(RouteText, 255, TXT_TransportingFromToDeliver, Load, StartLoc, EndLoc);
  54. // Check if the player is overloaded
  55. if (APlayerData[playerid][Overloaded] == true)
  56. {
  57. // Add "(OL)" to the missiontext to let the player know he's been overloaded
  58. format(RouteText, 255, "%s%s", RouteText, " ~r~(SC)~w~");
  59. // Send a message to the player to let him know he's been overloaded
  60. SCM(playerid, 0xFFFFFFFF, "{FF8000}Você esta sobrecarregado. Evite a policia rodoviária!");
  61. }
  62. // Check if the player is carrying a mafia-load
  63. if (ALoads[APlayerData[playerid][LoadID]][Mafia] == true)
  64. {
  65. // Add "(ML)" to the missiontext to let the player know his load is wanted by the mafia
  66. format(RouteText, 255, "%s%s", RouteText, " ~r~(MI)~w~");
  67. // If the player is carrying a mafia-load, inform him about it
  68. GameTextForPlayer(playerid, TXT_TruckerMafiaInterested, 6000, 4);
  69. // Also set the data for the player to indicate he's carrying a mafiaload
  70. APlayerData[playerid][MafiaLoad] = true;
  71. // Also set the player's trailer ID (or the vehicle itself) as Mafia-load in the array "AVehicleMafiaLoad"
  72. if (APlayerData[playerid][TrailerID] == 0)
  73. AVehicleData[APlayerData[playerid][VehicleID]][MafiaLoad] = true; // The player has no trailer, so set his main vehicle as wanted by the mafia
  74. else
  75. AVehicleData[APlayerData[playerid][TrailerID]][MafiaLoad] = true; // The player has a trailer, so set his trailer as wanted by the mafia
  76. }
  77.  
  78. PlayerTextDrawSetString(playerid, MissionText[playerid], " ");
  79. // Set the TextDraw so the player can see it
  80. PlayerTextDrawSetString(playerid, MissionText[playerid], RouteText);
  81.  
  82. // Grab the x, y, z positions for the second location (to unload the goods)
  83. x = ALocations[APlayerData[playerid][JobLoc2]][LocX];
  84. y = ALocations[APlayerData[playerid][JobLoc2]][LocY];
  85. z = ALocations[APlayerData[playerid][JobLoc2]][LocZ];
  86. // Create a checkpoint where the player should unload the goods
  87. SetPlayerCheckpoint(playerid, x, y, z, 15);
  88. // Inform the player that he must unload his goods
  89. format(UnloadMsg, 100, TXT_DeliverCargoTo, Load, EndLoc);
  90. SCM(playerid, 0xFFFFFFFF, UnloadMsg);
  91.  
  92. //if mission bonus has started and if it isn't finished yet
  93. if(!RandomBonusMission[MissionFinished] || RandomBonusMission[RandomLoad] != 0)
  94. {
  95. if(APlayerData[playerid][JobLoc2] == RandomBonusMission[RandomEndLoc])
  96. {
  97. SCM(playerid, 0xFFFFCC, "Você agora está participando da missão bônus!");
  98. PlayerOnBonusMission[playerid] = true;
  99. }
  100. }
  101. }
  102. case 2: // Player is delivering his goods
  103. {
  104. // Setup local variables
  105. new StartLoc[50], EndLoc[50], Load[50], Msg1[128], Msg2[128], Name[24], BonusMsg[128];
  106.  
  107. // Get the player name
  108. GetPlayerName(playerid, Name, sizeof(Name));
  109. // Get the startlocation, endlocation and the load texts
  110. format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
  111. format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
  112. format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);
  113.  
  114.  
  115.  
  116. new TotalTime = (GetTickCount() - APlayerData[playerid][StartTime]) / 1000;
  117.  
  118. new Mins = TotalTime / 60;
  119. new Secs = TotalTime - (Mins * 60);
  120.  
  121. if(Secs < 24 && Mins < 1) return Kick(playerid);
  122.  
  123.  
  124.  
  125. // Construct the message sent to all players that this player completed a trucking mission
  126. if (APlayerData[playerid][Sexo] == 0 || APlayerData[playerid][Sexo] == 1) {
  127. format(Msg1, 200, "{FF8000}O Caminhoneiro {FFFFFF}%s{FF8000} transportou {FFFFFF}%s{FF8000} com sucesso.", Name, Load);
  128. format(Msg2, 128, "{FF8000}de: {FFFFFF}%s{FF8000} para: {FFFFFF}%s{FF8000} em %02i min(s) - %02i seg(s).", StartLoc, EndLoc, Mins, Secs);
  129. SCMA(0xFFFFFFFF, Msg1);
  130. SCMA(0xFFFFFFFF, Msg2); }
  131.  
  132. if (APlayerData[playerid][Sexo] == 2) {
  133. format(Msg1, 200, "{FF8000}A Caminhoneira {FFFFFF}%s{FF8000} transportou {FFFFFF}%s{FF8000} com sucesso.", Name, Load);
  134. format(Msg2, 128, "{FF8000}de: {FFFFFF}%s{FF8000} para: {FFFFFF}%s{FF8000} em %02i min(s) - %02i seg(s).", StartLoc, EndLoc, Mins, Secs);
  135. SCMA(0xFFFFFFFF, Msg1);
  136. SCMA(0xFFFFFFFF, Msg2); }
  137.  
  138. // Setup local variables
  139. new Float:x1, Float:y1, Float:x2, Float:y2, Float:Distance, Message[128], Payment, Bonus, array[200];
  140. // Grab the x, y, z positions for the first location (to load the goods)
  141. x1 = ALocations[APlayerData[playerid][JobLoc1]][LocX];
  142. y1 = ALocations[APlayerData[playerid][JobLoc1]][LocY];
  143. // Grab the x, y, z positions for the second location (to unload the goods)
  144. x2 = ALocations[APlayerData[playerid][JobLoc2]][LocX];
  145. y2 = ALocations[APlayerData[playerid][JobLoc2]][LocY];
  146. // Calculate the distance between both points
  147. Distance = floatsqroot(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
  148.  
  149. // Calculate the payment for the player
  150. Payment = floatround((Distance * ALoads[APlayerData[playerid][LoadID]][PayPerUnit]), floatround_floor);
  151. Passou[playerid] = false;
  152. // Check if the player has done the bonus mission
  153. if (RandomBonusMission[MissionFinished] == false)
  154. {
  155. // Check all paramters (load, startlocation and end-location)
  156. if (RandomBonusMission[RandomLoad] == APlayerData[playerid][LoadID])
  157. if (RandomBonusMission[RandomStartLoc] == APlayerData[playerid][JobLoc1])
  158. if (RandomBonusMission[RandomEndLoc] == APlayerData[playerid][JobLoc2])
  159. {
  160. for(new i; i < GetPlayerPoolSize(); i++)
  161. if(IsPlayerConnected(i)) PlayerOnBonusMission[i] = false;
  162.  
  163. Payment = Payment * 12; // Double the payment is the player was the first to do the bonus mission
  164. RandomBonusMission[MissionFinished] = true; // Only one player can do the bonus mission, a new one is chosen next
  165. format(BonusMsg, 128, "{1E90FF}Caminhoneiro {FFFFFF}%s{1E90FF} transportou a carga bônus com sucesso.", Name);
  166. SCMA(0xFFFFFFFF, BonusMsg);
  167. Passou[playerid] = false;
  168. }
  169. }
  170.  
  171.  
  172. new file[40];
  173. format(file, sizeof(file), BankFile, Name);
  174. if (fexist(file))
  175. {
  176. new Var[300];
  177. format(Var, sizeof Var,"{FF8C00}Você transportou {FFFFFF}%s{FF8C00} com sucesso de {FFFFFF}%s{FF8C00} para {FFFFFF}%s\n{FF8C00}Você recebeu {80FF00}R${FFFFFF}%d{FF8C00} pelo seu trabalho.\n\nDeseja depositar no banco?\n\n\nCaso você ganhe bônus, não será incluido nesta mensagem.", Load, StartLoc, EndLoc, Payment);
  178. ShowPlayerDialog(playerid, DialogTermino, DIALOG_STYLE_MSGBOX, "{FF0000}#{FFFFFF} Trabalho", Var, "Sim", "Não");
  179. Valor[playerid] = Payment;
  180.  
  181. } else Ganhos(playerid, Payment, 0);
  182. format(Message, 128, "{FF8000}Você finalizou seu trabalho e ganhou {00FF00}R${FFFFFF}%i", Payment);
  183. SCM(playerid, 0xFFFFFFFF, Message);
  184. format(Message, 128, "{FF8000}Você ganhou {FFFFFF}1 Gold!{FF8000} Troque com o NPC em {FFFFFF}Fleischberg", Payment);
  185. SCM(playerid, 0xFFFFFFFF, Message);
  186. GameTextForPlayer(playerid, "~w~Trabalho~n~~g~Finalizado", 5000, 0);
  187. Gold[playerid]++;
  188.  
  189. // Add 25% bonus if the player has been overloaded
  190. if (APlayerData[playerid][Overloaded] == true)
  191. {
  192. // Calculate the bonus
  193. Bonus = (Payment * 25) / 100;
  194. // Pay the bonus to the player
  195. Ganhos(playerid, Bonus, 0);
  196. // Send a message to let the player know he was overloaded and got paid
  197. format(Message, 128, "{FF8000}Você ganhou um bônus por estar sobrecarregado: {00FF00}R${FFFFFF}%i", Bonus);
  198. SCM(playerid, 0xFFFFFFFF, Message);
  199. }
  200.  
  201. if (APlayerData[playerid][MafiaLoad] == true)
  202. {
  203. Bonus = (Payment * 50) / 100;
  204. Ganhos(playerid, Bonus, 0);
  205. format(Message, 128, "{FF8000}Você ganhou um bônus por carregar uma carga de interesse da máfia: {00FF00}R${FFFFFF}%i", Bonus);
  206. SCM(playerid, 0xFFFFFFFF, Message);
  207. }
  208.  
  209. if (AVehicleData[APlayerData[playerid][VehicleID]][Owned] == true)
  210. {
  211. Bonus = (Payment * 10) / 100;
  212. Ganhos(playerid, Bonus, 0);
  213. format(Message, 128, "{FF8000}Você ganhou um bônus por entregar com o seu próprio caminhão: {00FF00}R${FFFFFF}%i", Bonus);
  214. SCM(playerid, 0xFFFFFFFF, Message);
  215. }
  216.  
  217. if (IsPlayerVIP(playerid))
  218. {
  219. Bonus = (Payment * 20) / 100;
  220. Ganhos(playerid, Bonus, 0);
  221. format(Message, 128, "{FF8000}Você ganhou um bônus por ser VIP: {00FF00}R${FFFFFF}%i", Bonus);
  222. SCM(playerid, 0xFFFFFFFF, Message);
  223. }
  224. if(APlayerData[playerid][StatsTruckerJobs] == 999)
  225. {
  226. if (APlayerData[playerid][Sexo] == 2)
  227. {
  228. format(array, 200, "{FF8000}A Caminhoneira {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}insana.", rNome(playerid));
  229. SendClientMessageToAll(-1, array);
  230. }
  231. else if(APlayerData[playerid][Sexo] == 0 || APlayerData[playerid][Sexo] == 1)
  232. {
  233. format(array, 200, "{FF8000}O Caminhoneiro {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}insano.", rNome(playerid));
  234. SendClientMessageToAll(-1, array);
  235. }
  236.  
  237. }
  238. if(APlayerData[playerid][StatsTruckerJobs] == 499)
  239. {
  240. if (APlayerData[playerid][Sexo] == 2)
  241. {
  242. format(array, 200, "{FF8000}A Caminhoneira {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}moderada.", rNome(playerid));
  243. SendClientMessageToAll(-1, array);
  244. }
  245. else if(APlayerData[playerid][Sexo] == 0 || APlayerData[playerid][Sexo] == 1 )
  246. {
  247.  
  248. format(array, 200, "{FF8000}O Caminhoneiro {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}moderado.", rNome(playerid));
  249. SendClientMessageToAll(-1, array);
  250. }
  251.  
  252. }
  253. if(APlayerData[playerid][StatsTruckerJobs] == 99)
  254. {
  255. if (APlayerData[playerid][Sexo] == 2)
  256. {
  257.  
  258. format(array, 200, "{FF8000}A Caminhoneira {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}intermediária.", rNome(playerid));
  259. SendClientMessageToAll(-1, array);
  260. }
  261. else if(APlayerData[playerid][Sexo] == 0 || APlayerData[playerid][Sexo] == 1)
  262. {
  263. format(array, 200, "{FF8000}O Caminhoneiro {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}intermediário.", rNome(playerid));
  264. SendClientMessageToAll(-1, array);
  265. }
  266.  
  267. }
  268.  
  269. if (Distance > 3000.0)
  270. Ganhos(playerid, 0, 3);
  271. else
  272. Ganhos(playerid, 0, 2);
  273.  
  274. APlayerData[playerid][StatsTruckerJobs]++;
  275. PlayerFile_Save(playerid);
  276.  
  277. Trucker_EndJob(playerid);
  278. }
  279. }
  280.  
  281. // Enable the player again (he can move again)
  282. TogglePlayerControllable(playerid, 1);
  283.  
  284. return 1;
  285. }
Advertisement
Add Comment
Please, Sign In to add comment