mechanic.pwn 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Mechanic System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. timer Fix_PlayerInVehicleCheck[3000](playerid) {
  34. if(IsPlayerInAnyVehicle(playerid) && PlayerInfo[playerid][pMechSkill] < 400) {
  35. TogglePlayerControllable(playerid, true);
  36. RemovePlayerFromVehicle(playerid);
  37. SendClientMessageEx(playerid, COLOR_LIGHTRED, "[SERVER]: Please do not exploit this again.");
  38. TogglePlayerControllable(playerid, false);
  39. }
  40. }
  41. CMD:fix(playerid, params[])
  42. {
  43. if(PlayerInfo[playerid][pJob] == 7 || PlayerInfo[playerid][pJob2] == 7 || PlayerInfo[playerid][pJob3] == 7 ||
  44. (PlayerInfo[playerid][pBusiness] != INVALID_BUSINESS_ID && Businesses[PlayerInfo[playerid][pBusiness]][bType] == BUSINESS_TYPE_MECHANIC && InBusiness(playerid) == PlayerInfo[playerid][pBusiness]))
  45. {
  46. new string[32 + MAX_PLAYER_NAME];
  47. if(IsPlayerInAnyVehicle(playerid))
  48. {
  49. SendClientMessageEx(playerid, COLOR_GRAD1, "You can not repair while inside the vehicle.");
  50. return 1;
  51. }
  52. if(gettime() < PlayerInfo[playerid][pMechTime])
  53. {
  54. format(string, sizeof(string), "You must wait %d seconds!", PlayerInfo[playerid][pMechTime]-gettime());
  55. SendClientMessageEx(playerid, COLOR_GRAD1,string);
  56. return 1;
  57. }
  58. else if(GetPVarType(playerid, "IsInArena"))
  59. {
  60. SendClientMessageEx(playerid, COLOR_WHITE, "You can't do this right now, you are in an arena!");
  61. return 1;
  62. }
  63. else if(GetPVarInt(playerid, "EventToken"))
  64. {
  65. SendClientMessageEx(playerid, COLOR_GRAD1, "You can't use this while in an event.");
  66. return 1;
  67. }
  68. else if(GetPVarType(playerid, "PlayerCuffed") || GetPVarInt(playerid, "pBagged") >= 1 || GetPVarType(playerid, "Injured") || GetPVarType(playerid, "IsFrozen"))
  69. {
  70. return SendClientMessage(playerid, COLOR_GRAD2, "You can't do that at this time!");
  71. }
  72. else if(GetPVarType(playerid, "FixVehicleTimer"))
  73. {
  74. return SendClientMessageEx(playerid, COLOR_GRAD2, "You are already fixing a vehicle!");
  75. }
  76. else
  77. {
  78. new closestcar = GetClosestCar(playerid);
  79. if(IsPlayerInRangeOfVehicle(playerid, closestcar, 10.0))
  80. {
  81. new engine,lights,alarm,doors,bonnet,boot,objective;
  82. new level = PlayerInfo[playerid][pMechSkill];
  83. GetVehicleParamsEx(closestcar,engine,lights,alarm,doors,bonnet,boot,objective);
  84. if(!IsABike(closestcar) && !IsAPlane(closestcar)) {
  85. if(bonnet == VEHICLE_PARAMS_OFF || bonnet == VEHICLE_PARAMS_UNSET)
  86. {
  87. SendClientMessageEx(playerid, COLOR_GRAD1, "The vehicle hood must be opened in order to repair it.");
  88. return 1;
  89. }
  90. }
  91. if(level >= 400)
  92. {
  93. SetTimerEx("FixVehicle", 2000, false, "ii", playerid, closestcar); // Fixes the crash bug.
  94. }
  95. else
  96. {
  97. format(string, sizeof(string), "* %s has began repairing the vehicle.", GetPlayerNameEx(playerid));
  98. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  99. SetPVarInt(playerid, "FixVehicleTimer", SetTimerEx("FixVehicle", 15000, false, "ii", playerid, closestcar));
  100. TogglePlayerControllable(playerid, 0);
  101. ApplyAnimation(playerid, "MISC", "Plunger_01", 4.1, 1, 1, 1, 1, 1, 1);
  102. }
  103. defer Fix_PlayerInVehicleCheck(playerid);
  104. }
  105. else return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not close enough to any vehicle.");
  106. }
  107. }
  108. else return SendClientMessageEx(playerid, COLOR_WHITE, "You are not a Mechanic!" );
  109. return 1;
  110. }
  111. forward FixVehicle(playerid, vehicleid);
  112. public FixVehicle(playerid, vehicleid)
  113. {
  114. TogglePlayerControllable(playerid, 1);
  115. ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0, 1);
  116. ClearAnimationsEx(playerid);
  117. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  118. PlayerInfo[playerid][pMechTime] = gettime()+60;
  119. SetVehicleHealth(vehicleid, 1000.0);
  120. Vehicle_Armor(vehicleid);
  121. new engine,lights,alarm,doors,bonnet,boot,objective;
  122. GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  123. if(GetVehicleModel(vehicleid) == 481 && GetVehicleModel(vehicleid) == 509 && GetVehicleModel(vehicleid) == 510)
  124. {
  125. SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
  126. arr_Engine{vehicleid} = 1;
  127. }
  128. format(szMiscArray, sizeof(szMiscArray), "* %s has repaired the vehicle.", GetPlayerNameEx(playerid));
  129. ProxDetector(30.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  130. DeletePVar(playerid, "FixVehicleTimer");
  131. }
  132. CMD:mechduty(playerid, params[])
  133. {
  134. if(PlayerInfo[playerid][pJob] == 7 || PlayerInfo[playerid][pJob2] == 7 || PlayerInfo[playerid][pJob3] == 7)
  135. {
  136. if(GetPVarInt(playerid, "MechanicDuty") == 1)
  137. {
  138. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* You are now off duty from your Car Mechanic job and will not receive calls anymore.");
  139. SetPVarInt(playerid, "MechanicDuty", 0);
  140. Mechanics -= 1;
  141. }
  142. else if(GetPVarInt(playerid, "MechanicDuty") == 0)
  143. {
  144. if (TransportDuty[playerid] != 0) return SendClientMessageEx(playerid,COLOR_GREY,"You need to get off duty as a transport driver first.");
  145. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* You are now on duty with your Car Mechanic job and will receive calls from people in need.");
  146. SetPVarInt(playerid, "MechanicDuty", 1);
  147. ++Mechanics;
  148. }
  149. }
  150. else
  151. {
  152. SendClientMessageEx(playerid, COLOR_GRAD1, " You are not a mechanic!");
  153. }
  154. return 1;
  155. }
  156. CMD:nos(playerid, params[])
  157. {
  158. if(PlayerInfo[playerid][pJob] == 7 || PlayerInfo[playerid][pJob2] == 7 || PlayerInfo[playerid][pJob3] == 7) {
  159. if(IsPlayerInAnyVehicle(playerid)) {
  160. if(GetPVarInt(playerid, "EventToken")) {
  161. return SendClientMessageEx(playerid, COLOR_GRAD1, "You can't use this while in an event.");
  162. }
  163. if(GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(1010)) != 1010 && GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(1009)) != 1009 && GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(1008)) != 1008)
  164. {
  165. if(!IsPlayerInInvalidNosVehicle(playerid))
  166. {
  167. new string[128];
  168. new nostogive;
  169. new level = PlayerInfo[playerid][pMechSkill];
  170. if(level >= 0 && level < 50) { nostogive = 1009; }
  171. else if(level >= 50 && level < 100) { nostogive = 1009; }
  172. else if(level >= 100 && level < 200) { nostogive = 1008; }
  173. else if(level >= 200 && level < 400) { nostogive = 1008; }
  174. else if(level >= 400) { nostogive = 1010; }
  175. AddVehicleComponent(GetPlayerVehicleID(playerid),nostogive);
  176. PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
  177. format(string, sizeof(string), "* %s added nitrous injection to the vehicle.", GetPlayerNameEx(playerid));
  178. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  179. }
  180. else {
  181. SendClientMessageEx(playerid, COLOR_GREY, "Nitrous injection cannot be installed on this vehicle.");
  182. }
  183. }
  184. else {
  185. SendClientMessageEx(playerid, COLOR_GREY, "This vehicle already has nitrous.");
  186. }
  187. }
  188. else {
  189. SendClientMessageEx(playerid, COLOR_GREY, "You're not in a vehicle.");
  190. }
  191. }
  192. else {
  193. SendClientMessageEx(playerid, COLOR_GREY, "You are not a Mechanic!" );
  194. }
  195. return 1;
  196. }
  197. CMD:hyd(playerid, params[])
  198. {
  199. if(PlayerInfo[playerid][pJob] == 7 || PlayerInfo[playerid][pJob2] == 7 || PlayerInfo[playerid][pJob3] == 7) {
  200. if(IsPlayerInAnyVehicle(playerid)) {
  201. if(IsPlayerInInvalidNosVehicle(playerid) || (DynVeh[GetPlayerVehicleID(playerid)] != -1 && DynVehicleInfo[DynVeh[GetPlayerVehicleID(playerid)]][gv_igID] != INVALID_GROUP_ID && arrGroupData[DynVehicleInfo[DynVeh[GetPlayerVehicleID(playerid)]][gv_igID]][g_iGroupType] != GROUP_TYPE_CRIMINAL)) return SendClientMessageEx(playerid, COLOR_WHITE, "Hydraulics cannot be installed in this vehicle.");
  202. if(gettime() < PlayerInfo[playerid][pServiceTime]) return SendClientMessage(playerid, COLOR_GREY, "You must wait 20 seconds before using this command again.");
  203. new string[128];
  204. PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
  205. AddVehicleComponent(GetPlayerVehicleID(playerid), 1087);
  206. format(string, sizeof(string), "* %s added hydraulics to the vehicle.", GetPlayerNameEx(playerid));
  207. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  208. PlayerInfo[playerid][pServiceTime] = gettime()+20;
  209. }
  210. else return SendClientMessageEx(playerid, COLOR_WHITE, "You're not in a vehicle.");
  211. }
  212. else return SendClientMessageEx(playerid, COLOR_WHITE, "You are not a Mechanic!");
  213. return 1;
  214. }