1
0

pizza_job.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. _____ _ _ _ ____ _____ _
  3. | __ (_) | | | | | _ \ | __ \ | |
  4. | |__) | __________ _ | | ___ | |__ | |_) |_ _ | | | | ___ ___ _ __ ___ ___ _ __ __| |
  5. | ___/ |_ /_ / _` | _ | |/ _ \| '_ \ | _ <| | | | | | | |/ _ \/ __| '_ ` _ \ / _ \| '_ \ / _` |
  6. | | | |/ / / / (_| | | |__| | (_) | |_) | | |_) | |_| | | |__| | __/\__ \ | | | | | (_) | | | | (_| |
  7. |_| |_/___/___\__,_| \____/ \___/|_.__/ |____/ \__, | |_____/ \___||___/_| |_| |_|\___/|_| |_|\__,_|
  8. __/ |
  9. |___/
  10. */
  11. #define DIALOG_GETPIZZAJOB 16738
  12. new cancelpizzajobtimer[MAX_PLAYERS];
  13. static housedeliveryid[MAX_PLAYERS];
  14. static haspizza[MAX_PLAYERS];
  15. new Float:RandomHouse[][3] =
  16. {
  17. {2441.6282,-1356.9805,24.0000},
  18. {2441.7490,-1339.3866,24.0000},
  19. {2782.9695,-1925.3589,13.5469},
  20. {2753.0330,-1962.4550,13.5469},
  21. {2136.6016,-1229.8315,23.9766},
  22. {2192.3796,-1237.8867,23.9766},
  23. {2209.7964,-1237.3121,23.9263},
  24. {2144.9907,-1085.6957,24.7004},
  25. {2140.3267,-1083.1752,24.4701},
  26. {2109.4468,-1081.5615,24.8858},
  27. {2102.5120,-1074.7393,25.8022},
  28. {2104.7888,-1056.4807,27.1996},
  29. {1906.1940,-1116.4855,25.6641},
  30. {2230.0771,-1159.1823,25.8170},
  31. {2230.3896,-1395.5856,24.0000}
  32. };
  33. forward cancelpizzadelivery(playerid);
  34. forward startpizzadelivery(playerid);
  35. forward GetPlayerPizzaPay(playerid);
  36. forward GetPlayerPizzaLevel(playerid);
  37. forward IncreasePlayerPizzaSkill(playerid);
  38. forward GetPlayerPizzaSkillLevel(playerid);
  39. public cancelpizzadelivery(playerid)
  40. {
  41. DisablePlayerCheckpointEx(playerid);
  42. CP[playerid] = CHECKPOINT_NONE;
  43. onpizzadelivery[playerid] = 0;
  44. HidePlayerProgressBar(playerid, pizzajobdeliveryid[playerid]);
  45. haspizza[playerid] = 0;
  46. return 1;
  47. }
  48. public startpizzadelivery(playerid)
  49. {
  50. onpizzadelivery[playerid] = 1;
  51. housedeliveryid[playerid] = random(sizeof(RandomHouse));
  52. haspizza[playerid] = 0; // no longer need to check if the player has a pizza tray to place using /placepizza.
  53. SetPlayerProgressBarValue(playerid, pizzajobdeliveryid[playerid], 100.0);
  54. ShowPlayerProgressBar(playerid, pizzajobdeliveryid[playerid]);
  55. DisablePlayerCheckpointEx(playerid);
  56. SetPlayerCheckpointEx(playerid, RandomHouse[housedeliveryid[playerid]][0], RandomHouse[housedeliveryid[playerid]][1], RandomHouse[housedeliveryid[playerid]][2], 4.0);
  57. CP[playerid] = CHECKPOINT_PIZZAJOB;
  58. return 1;
  59. }
  60. public GetPlayerPizzaLevel(playerid)
  61. {
  62. new skill = PlayerInfo[playerid][pPizzaSkill];
  63. if(skill >= 0 && skill <= 49) return 1;
  64. else if(skill >= 50 && skill <= 119) return 2;
  65. else if(skill >= 120 && skill <= 199) return 3;
  66. else if(skill >= 200 && skill <= 269) return 4;
  67. else if(skill >= 270) return 5;
  68. return 1;
  69. }
  70. public GetPlayerPizzaPay(playerid)
  71. {
  72. new level = GetPlayerPizzaLevel(playerid);
  73. switch(level)
  74. {
  75. case 1: return 0;
  76. case 2: return 300;
  77. case 3: return 500;
  78. case 4: return 700;
  79. case 5: return 1000;
  80. }
  81. return 1;
  82. }
  83. public IncreasePlayerPizzaSkill(playerid)
  84. {
  85. new skill = PlayerInfo[playerid][pPizzaSkill];
  86. if(skill+1 == 50)
  87. {
  88. SendClientMessage(playerid, COLOR_YELLOW, "* Your Pizza Skill is now Level 2, you will earn more money per delivery.");
  89. }
  90. else if(skill+1 == 120)
  91. {
  92. SendClientMessage(playerid, COLOR_YELLOW, "* Your Pizza Skill is now Level 3, you will earn more money per delivery.");
  93. }
  94. else if(skill+1 == 200)
  95. {
  96. SendClientMessage(playerid, COLOR_YELLOW, "* Your Pizza Skill is now Level 4, you will earn more money per delivery.");
  97. }
  98. else if(skill+1 == 270)
  99. {
  100. SendClientMessage(playerid, COLOR_YELLOW, "* Your Pizza Skill is now Level 5, you will earn more money per delivery.");
  101. }
  102. PlayerInfo[playerid][pPizzaSkill]++;
  103. return 1;
  104. }
  105. public GetPlayerPizzaSkillLevel(playerid)
  106. {
  107. new skill = PlayerInfo[playerid][pPizzaSkill];
  108. new reqleft;
  109. if(skill >= 0 && skill <= 49) reqleft = 50 -skill;
  110. else if(skill >= 50 && skill <= 119) reqleft = 120 -skill;
  111. else if(skill >= 120 && skill <= 199) reqleft = 200 -skill;
  112. else if(skill >= 200 && skill <= 269) reqleft = 270 -skill;
  113. return reqleft;
  114. }
  115. Hook:PJob_OnGameModeInit()
  116. {
  117. // test pizza faggio //
  118. CreateVehicle(448, 2097.4907, -1792.2670, 12.9876, 87.4951, 3, 6, 60*30); // pizza 1
  119. CreateVehicle(448, 2097.4900, -1794.2600, 12.9707, 86.4419, 3, 6, 60*30); // pizza 2
  120. CreateVehicle(448, 2097.4900, -1796.2600, 12.9616, 86.4419, 3, 6, 60*30); // pizza 3
  121. CreateVehicle(448, 2097.4900, -1798.2600, 12.9616, 86.4419, 3, 6, 60*30); // pizza 4
  122. CreateVehicle(448, 2097.4900, -1800.2600, 12.9639, 86.4417, 3, 6, 60*30); // pizza 5
  123. //CreateActor(155, 2104.9565, -1803.1753, 13.5547, 83.6858);
  124. //Create3DTextLabel("Pizza Delivery Job\n{FFFFFF}Press Y to become a pizza boy.", 0x43527DFF, 2104.9565, -1803.1753, 14.5247, 20.0, 0, 1);
  125. CreatePickup(1582, 1, 2104.7837,-1804.7845,13.5547, 0); // /getpizza pickup
  126. iPizza = CreateDynamicPickup(1239, 23, 2104.51, -1803.17, 13.55);
  127. SetTimer("CancelPizzaJob", 1000, 1);
  128. new Text3D:textPizza = CreateDynamic3DTextLabel("Pizza Delivery Job\n{FFFFFF}/getjob", 0xFFFF91FF, 2104.51, -1803.17, 13.55 +0.88, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100);
  129. Create3DTextLabel("Pizza Delivery Job\n{FFFFFF}/getpizza", 0xFFFF91FF, 2104.7837,-1804.7845,13.5547 + 0.60, 20.0, 0, 1);
  130. #pragma unused textPizza
  131. return 1;
  132. }
  133. Hook:PJob_OnPlayerConnect(playerid)
  134. {
  135. pizzajobdeliveryid[playerid] = CreatePlayerProgressBar(playerid, 290.0, 340.00, 65.0, 5.0, 0xFFFF00AA, 100.0, BAR_DIRECTION_RIGHT);
  136. return 1;
  137. }
  138. CMD:getpizza(playerid, params[])
  139. {
  140. if(PlayerInfo[playerid][pCash] < 300) return SendClientMessage(playerid, COLOR_GREY, "You must have 300$ to get pizza.");
  141. if(PlayerInfo[playerid][pJob] != 21) return SendClientMessage(playerid, COLOR_GREY, "You must have the pizza job to use this command.");
  142. if(haspizza[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "You already have a pizza! Place it in your pizza faggio using /placepizza.");
  143. if(!IsPlayerInRangeOfPoint(playerid, 4.0, 2104.7837,-1804.7845,13.5547)) return SendClientMessage(playerid, COLOR_GREY, "You must be by the pizza stack's entrance to do this.");
  144. haspizza[playerid] = 1;
  145. SendClientMessage(playerid, COLOR_YELLOW, "You were given a pizza tray ($300), place it in a pizza faggio (/placepizza) to continue the delivery.");
  146. GiveMoney(playerid, -300);
  147. return 1;
  148. }
  149. CMD:placepizza(playerid, params[])
  150. {
  151. if(PlayerInfo[playerid][pJob] != 21) return SendClientMessage(playerid, COLOR_GREY, "You must have the pizza job to use this command.");
  152. if(onpizzadelivery[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are already on a delivery.");
  153. new currentvehicleid = GetPlayerVehicleID(playerid);
  154. if(GetVehicleModel(currentvehicleid) != 448) return SendClientMessage(playerid, COLOR_GREY, "You must be in a pizza faggio to do this.");
  155. if(CP[playerid] != 0 && CP[playerid] != CHECKPOINT_PIZZAJOB) return SendClientMessage(playerid, COLOR_GREY, "You already have an active checkpoint, /killcp.");
  156. if(haspizza[playerid] != 1) return SendClientMessage(playerid, COLOR_GREY, "You must have a pizza tray to do this.");
  157. startpizzadelivery(playerid);
  158. SendClientMessage(playerid, COLOR_YELLOW, "You are now on a delivery. If you exit your faggio the delivery will be cancelled (/cpizzadelivery to cancel it manually).");
  159. SendClientMessage(playerid, COLOR_YELLOW, "A checkpoint has been set for you to find the location of the house you're going to deliver the pizza to.");
  160. return 1;
  161. }
  162. CMD:cpizzadelivery(playerid, params[])
  163. {
  164. if(CP[playerid] == CHECKPOINT_PIZZAJOB && onpizzadelivery[playerid] == 1 && PlayerInfo[playerid][pJob] == 21)
  165. {
  166. cancelpizzadelivery(playerid);
  167. SendClientMessage(playerid, -1, "Your delivery has been cancelled.");
  168. }
  169. return 1;
  170. }
  171. Hook:PJB_OnPlayerEnterCheckpoint(playerid)
  172. {
  173. if(CP[playerid] == CHECKPOINT_PIZZAJOB && onpizzadelivery[playerid] != 0)
  174. {
  175. // note - progress bar value is set to 100 when the delivery sets. every second it's minus 0.5, which means 2 seconds = 1 value, so if currentprogbarvalue is 90, it means 20 seconds passed and not 10.
  176. new Float:currentprogbarvalue = GetPlayerProgressBarValue(playerid, pizzajobdeliveryid[playerid]);
  177. new msg[80], randomdeliverymoney = GetPlayerPizzaPay(playerid); // bonus per level
  178. if(currentprogbarvalue < 70) // more than 60 seconds
  179. {
  180. randomdeliverymoney += random(600-300) + 300;
  181. format(msg, sizeof(msg), "You have delivered the pizza very late ($%i received).", randomdeliverymoney);
  182. SendClientMessage(playerid, COLOR_GREY, msg);
  183. GiveMoney(playerid, randomdeliverymoney);
  184. }
  185. else if(currentprogbarvalue >= 70 && currentprogbarvalue < 85) // done within 31-60 seconds
  186. {
  187. randomdeliverymoney += random(800-600) + 600;
  188. format(msg, sizeof(msg), "You have delivered the pizza in a respected time ($%i received).", randomdeliverymoney);
  189. SendClientMessage(playerid, COLOR_GREY, msg);
  190. GiveMoney(playerid, randomdeliverymoney);
  191. }
  192. else if(currentprogbarvalue >= 85 && currentprogbarvalue <= 100) // done within 1-30 seconds
  193. {
  194. randomdeliverymoney += random(1200-1000) + 1000;
  195. format(msg, sizeof(msg), "You have delivered the pizza in a very respected time (received: $%i).", randomdeliverymoney);
  196. SendClientMessage(playerid, COLOR_GREY, msg);
  197. GiveMoney(playerid, randomdeliverymoney);
  198. }
  199. else // somehow managed to get a number which is not defined within the if's above
  200. {
  201. randomdeliverymoney += random(500-300) + 300;
  202. format(msg, sizeof(msg), "You have delivered the pizza in an unknown time (received: $%i).", randomdeliverymoney);
  203. SendClientMessage(playerid, COLOR_GREY, msg);
  204. GiveMoney(playerid, randomdeliverymoney);
  205. }
  206. cancelpizzadelivery(playerid);
  207. IncreasePlayerPizzaSkill(playerid);
  208. }
  209. return 1;
  210. }
  211. Hook:PJob_OnPlayerExitVehicle(playerid, vehicleid)
  212. {
  213. if(CP[playerid] == CHECKPOINT_PIZZAJOB && onpizzadelivery[playerid] == 1 && GetVehicleModel(vehicleid) == 448)
  214. {
  215. SendClientMessage(playerid, COLOR_GREY, "You have left your pizza faggio during the delivery, you have 15 seconds to get in your pizza faggio otherwise the delivery will fail.");
  216. cancelpizzajobtimer[playerid] = 15;
  217. }
  218. return 1;
  219. }
  220. Hook:PJob_OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  221. {
  222. if(onpizzadelivery[playerid] == 1 && GetVehicleModel(vehicleid) == 448){
  223. cancelpizzajobtimer[playerid] = -1;
  224. }
  225. if(GetVehicleModel(vehicleid) == 448 && PlayerInfo[playerid][pJob] != 21)
  226. {
  227. ClearAnimations(playerid);
  228. displayCenterHUDInfo(playerid, "You must be in pizza delivery job in order to drive the pizza faggio.", 8);
  229. PlayerPlaySound(playerid, 24600, 0.0, 0.0, 0.0);
  230. }
  231. return 1;
  232. }
  233. /* Pizza Job Timer */
  234. forward CancelPizzaJob(playerid);
  235. public CancelPizzaJob(playerid){
  236. foreach(new i: Player)
  237. {
  238. if(cancelpizzajobtimer[i] != 0)
  239. {
  240. cancelpizzajobtimer[i] --;
  241. if(cancelpizzajobtimer[i] == 0)
  242. {
  243. TimePizzaJobCancel(i);
  244. }
  245. }
  246. }
  247. return 1;
  248. }
  249. forward TimePizzaJobCancel(playerid);
  250. public TimePizzaJobCancel(playerid){
  251. cancelpizzadelivery(playerid);
  252. SendClientMessage(playerid, COLOR_RED, "You failed to get back on the Pizza fagio bike within time limit!");
  253. return 1;
  254. }