lhtbally

work

Sep 22nd, 2011
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.42 KB | None | 0 0
  1. if(!strcmp("/work", command, true))
  2. {
  3. if(GetPlayerTeam(playerid) != 2) return SendClientMessage(playerid, 0xff0000ff, "ERROR: You are not a trucker!");
  4. if(GetPlayerVehicleSeat(playerid) != 0) return SendClientMessage(playerid, 0xff0000ff, "ERROR: You are not driving a vehicle!"); //Check if the player is DRIVING a vehicle, prevents missions as passenger
  5. if(GetPVarInt(playerid, "IsWorking?") != 0) return SendClientMessage(playerid, 0xff0000ff, "ERROR: You are already working!");
  6. new vid = GetPlayerVehicleID(playerid), vmod = GetVehicleModel(vid), tid = GetVehicleTrailer(vid), tmod = GetVehicleModel(tid);
  7. switch(vmod)
  8. {
  9. case 403, 514, 515: //Is the player driving a Linerunner, Tanker or roadtrain?
  10. {
  11. if(tid == 0) return SendClientMessage(playerid, red, "ERROR: You need a trailer attached to do trucker missions!");
  12. switch(tmod)
  13. {
  14. case 435, 591: //Is a BOX trailer?
  15. {
  16. #if defined USE_DIALOGS
  17. new str[1024], count, strB[111];
  18. new rand = count;
  19. for(new i; i < sizeof(TruckingMissionRandomBox); i++) //Loop init; Loop Checking; Loop Update //Loop for adding missions to dialog string
  20. {
  21. if(GetPVarInt(playerid, TruckingMissionRandomBox[rand][LoadName]) == 0)
  22. {
  23. format(strB, sizeof(strB), "Internal_%d_Value", count);
  24. SetPVarInt(playerid, strB, i);
  25. count++;
  26. format(str, sizeof(str), "{ff9000}%d) {ffffff}%s\r\n", count, TruckingMissionRandomBox[rand][LoadName]);
  27. }
  28. SetPVarInt(playerid, TruckingMissionRandomBox[rand][LoadName], GetPVarInt(playerid, TruckingMissionRandomBox[rand][LoadName])+1);
  29. }
  30. ShowPlayerDialog(playerid, 13342, DIALOG_STYLE_LIST, "{0000ff}Choose load", str, "Ok", "Cancel");
  31. #else
  32. new id = MRandom(sizeof(TruckingMissionRandomBox));
  33. new strB[128];
  34. format(strB, sizeof(strB), "%s from %s to %s", TruckingMissionRandomBox[id][LoadName], TruckingMissionRandomBox[id][LoadPointName], TruckingMissionRandomBox[id][UnloadPointName]);
  35. SetPVarString(playerid, "OnMission", strB);
  36. CreatePlayerMission(playerid, TruckingMissionRandomBox[id][UseTrailerCheck], TruckingMissionRandomBox[id][MissionPay], TruckingMissionRandomBox[id][loadx],TruckingMissionRandomBox[id][loady], TruckingMissionRandomBox[id][loadz], TruckingMissionRandomBox[id][unloadx],TruckingMissionRandomBox[id][unloady], TruckingMissionRandomBox[id][unloadz]);
  37. SetPVarInt(playerid, "IsWorking?", 1); //Better than using an array with size MAX_PLAYERS
  38. SendClientMessage(playerid, 0x00FF00FF, TruckingMissionRandomBox[id][MissionName]);
  39. #endif
  40. return 1; //Stops processing the code
  41. }
  42. case 450: //Is a DUMPER trailer?
  43. {
  44. #if defined USE_DIALOGS
  45. new str[1024], count, strB[111];
  46. new rand = count;
  47. for(new i; i < sizeof(TruckingMissionRandomDumper); i++) //Loop init; Loop Checking; Loop Update //Loop for adding missions to dialog string
  48. {
  49. if(GetPVarInt(playerid, TruckingMissionRandomDumper[rand][LoadName]) == 0)
  50. {
  51. format(strB, sizeof(strB), "Internal_%d_Value", count);
  52. SetPVarInt(playerid, strB, i);
  53. count++;
  54. format(str, sizeof(str), "{ff9000}%d) {ffffff}%s\r\n", count, TruckingMissionRandomDumper[rand][LoadName]);
  55. }
  56. SetPVarInt(playerid, TruckingMissionRandomDumper[rand][LoadName], GetPVarInt(playerid, TruckingMissionRandomDumper[rand][LoadName])+1);
  57. }
  58. ShowPlayerDialog(playerid, 13343, DIALOG_STYLE_LIST, "{0000ff}Choose load", str, "Ok", "Cancel");
  59. #else
  60. new id = MRandom(sizeof(TruckingMissionRandomDumper));
  61. new strB[128];
  62. format(strB, sizeof(strB), "%s from %s to %s", TruckingMissionRandomDumper[id][LoadName], TruckingMissionRandomDumper[id][LoadPointName], TruckingMissionRandomDumper[id][UnloadPointName]);
  63. SetPVarString(playerid, "OnMission", strB);
  64. CreatePlayerMission(playerid, TruckingMissionRandomDumper[id][UseTrailerCheck], TruckingMissionRandomDumper[id][MissionPay], TruckingMissionRandomDumper[id][loadx],TruckingMissionRandomDumper[id][loady], TruckingMissionRandomDumper[id][loadz], TruckingMissionRandomDumper[id][unloadx],TruckingMissionRandomDumper[id][unloady], TruckingMissionRandomDumper[id][unloadz]);
  65. SetPVarInt(playerid, "IsWorking?", 1); //Better than using an array with size MAX_PLAYERS
  66. SendClientMessage(playerid, 0x00FF00FF, TruckingMissionRandomDumper[id][MissionName]);
  67. #endif
  68. return 1; //Stops processing the code
  69. }
  70. case 584: //Is a PETRO trailer?
  71. {
  72. #if defined USE_DIALOGS
  73. new str[1024], count, strB[111];
  74. new rand = count;
  75. for(new i; i < sizeof(TruckingMissionRandomPetro); i++) //Loop init; Loop Checking; Loop Update //Loop for adding missions to dialog string
  76. {
  77. if(GetPVarInt(playerid, TruckingMissionRandomPetro[rand][LoadName]) == 0)
  78. {
  79. format(strB, sizeof(strB), "Internal_%d_Value", count);
  80. SetPVarInt(playerid, strB, i);
  81. count++;
  82. format(str, sizeof(str), "{ff9000}%d) {ffffff}%s\r\n", count, TruckingMissionRandomPetro[rand][LoadName]);
  83. }
  84. SetPVarInt(playerid, TruckingMissionRandomPetro[rand][LoadName], GetPVarInt(playerid, TruckingMissionRandomPetro[rand][LoadName])+1);
  85. }
  86. ShowPlayerDialog(playerid, 13344, DIALOG_STYLE_LIST, "{0000ff}Choose load", str, "Ok", "Cancel");
  87. #else
  88. new id = MRandom(sizeof(TruckingMissionRandomPetro));
  89. new strB[128];
  90. format(strB, sizeof(strB), "%s from %s to %s", TruckingMissionRandomPetro[id][LoadName], TruckingMissionRandomPetro[id][LoadPointName], TruckingMissionRandomPetro[id][UnloadPointName]);
  91. SetPVarString(playerid, "OnMission", strB);
  92. CreatePlayerMission(playerid, TruckingMissionRandomPetro[id][UseTrailerCheck], TruckingMissionRandomPetro[id][MissionPay], TruckingMissionRandomPetro[id][loadx],TruckingMissionRandomPetro[id][loady], TruckingMissionRandomPetro[id][loadz], TruckingMissionRandomPetro[id][unloadx],TruckingMissionRandomPetro[id][unloady], TruckingMissionRandomPetro[id][unloadz]);
  93. SetPVarInt(playerid, "IsWorking?", 1); //Better than using an array with size MAX_PLAYERS
  94. SendClientMessage(playerid, 0x00FF00FF, TruckingMissionRandomPetro[id][MissionName]);
  95. #endif
  96. return 1; //Stops processing the
  97. }
  98. }
  99. return SendClientMessage(playerid, red, "ERROR: Invalid trailer"); //If no match was found in the 'switch' then the trailer type is invalid
  100. }
  101. case 578, 455, 498: //Is the player driving a DTF-30, Flatbed or Boxville?
  102. {
  103. #if defined USE_DIALOGS
  104. new str[1024], count, strB[111];
  105. new rand = count;
  106. for(new i; i < sizeof(TruckingMissionRandomBox); i++) //Loop init; Loop Checking; Loop Update //Loop for adding missions to dialog string
  107. {
  108. if(GetPVarInt(playerid, TruckingMissionRandomBox[rand][LoadName]) == 0)
  109. {
  110. format(strB, sizeof(strB), "Internal_%d_Value", count);
  111. SetPVarInt(playerid, strB, i);
  112. count++;
  113. format(str, sizeof(str), "{ff9000}%d) {ffffff}%s\r\n", count, TruckingMissionRandomBox[rand][LoadName]);
  114. }
  115. SetPVarInt(playerid, TruckingMissionRandomBox[rand][LoadName], GetPVarInt(playerid, TruckingMissionRandomBox[rand][LoadName])+1);
  116. }
  117. ShowPlayerDialog(playerid, 13342, DIALOG_STYLE_LIST, "{0000ff}Choose load", str, "Ok", "Cancel");
  118. #else
  119. new id = MRandom(sizeof(TruckingMissionRandomBox));
  120. new strB[128];
  121. format(strB, sizeof(strB), "%s from %s to %s", TruckingMissionRandomBox[id][LoadName], TruckingMissionRandomBox[id][LoadPointName], TruckingMissionRandomBox[id][UnloadPointName]);
  122. SetPVarString(playerid, "OnMission", strB);
  123. CreatePlayerMission(playerid, TruckingMissionRandomBox[id][UseTrailerCheck], TruckingMissionRandomBox[id][MissionPay], TruckingMissionRandomBox[id][loadx],TruckingMissionRandomBox[id][loady], TruckingMissionRandomBox[id][loadz], TruckingMissionRandomBox[id][unloadx],TruckingMissionRandomBox[id][unloady], TruckingMissionRandomBox[id][unloadz]);
  124. SetPVarInt(playerid, "IsWorking?", 1); //Better than using an array with size MAX_PLAYERS
  125. SendClientMessage(playerid, 0x00FF00FF, TruckingMissionRandomBox[id][MissionName]);
  126. #endif
  127. return 1; //Stops processing the code
  128. }
  129. }
  130. return SendClientMessage(playerid, red, "ERROR: You can't work with this vehicle"); //If no match was found in the 'switch' then the vehicle is invalid
  131. }
Advertisement
Add Comment
Please, Sign In to add comment