Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.47 KB | None | 0 0
  1. /*
  2. Created by: StaLpu
  3. Credits: Stalpu
  4. */
  5.  
  6. // Colors
  7. #define COLOR_WHITE 0xFFFFFFFF
  8. #define COLOR_LIGHTGREEN 0xAFFFA1FF
  9.  
  10. // Dialogs
  11. #define DIALOG_STATUS (333)
  12. #define DIALOG_JOB (334)
  13.  
  14. // Variables
  15. new Float:HousePos[16][3] = {
  16. {2013.6630, -1656.3639, 14.0733},
  17. {2018.2024, -1629.8944, 14.0733},
  18. {1980.9697, -1719.0088, 17.0321},
  19. {2066.9150, -1731.6338, 14.0879},
  20. {2067.4844, -1643.7155, 14.0866},
  21. {1853.9839, -1914.2035, 15.2474},
  22. {1938.5319, -1911.3409, 15.1402},
  23. {1928.5387, -1916.0127, 15.2403},
  24. {2238.3540, -1906.7906, 14.9349},
  25. {2307.0564, -1679.1633, 14.2915},
  26. {2326.7124, -1716.8486, 13.8206},
  27. {2385.3164, -1711.6276, 14.1911},
  28. {2696.3904, -1990.4764, 14.1993},
  29. {2787.2646, -1926.0974, 13.5604},
  30. {1872.4790, -2132.6597, 15.5008},
  31. {1667.4546, -2106.8040, 14.0209}
  32. };
  33.  
  34.  
  35. new
  36. Timer[MAX_PLAYERS],
  37. Working[MAX_PLAYERS],
  38. Gifts[MAX_PLAYERS],
  39. TotalGifts[MAX_PLAYERS],
  40. GiftHand[MAX_PLAYERS],
  41. Vehicle[MAX_PLAYERS],
  42. Checkpoint[MAX_PLAYERS],
  43. PlayerText: InfoTD,
  44. jobVehicles[6],
  45. jobActor,
  46. jobPickup;
  47.  
  48. public OnGameModeInit() {
  49. jobActor = CreateActor(112, 2244.5381, -2193.9580, 13.5469, 78.8678);
  50. SetActorInvulnerable(jobActor, true);
  51. ApplyActorAnimation(jobActor, "COP_AMBIENT", "Coplook_loop", 4.0, 0, 1, 1, 1, -1);
  52. jobPickup = CreatePickup(1239, 23, 2243.8152,-2193.8157,13.5469);
  53. Create3DTextLabel("/startwork", 0x0062FF99, 2243.8152,-2193.8157,13.5469, 10.0, 0);
  54.  
  55. jobVehicles[0] = CreateVehicle(482, 2251.4128, -2186.0459, 13.6538, 134.9000, 3, 1, -1);
  56. jobVehicles[1] = CreateVehicle(482, 2224.4158, -2159.3484, 13.6538, 135.0000, 3, 1, -1);
  57. jobVehicles[2] = CreateVehicle(482, 2229.6980, -2164.4678, 13.6538, 135.0000, 3, 1, -1);
  58. jobVehicles[3] = CreateVehicle(482, 2235.2888, -2169.8135, 13.6538, 135.0000, 3, 1, -1);
  59. jobVehicles[4] = CreateVehicle(482, 2240.5559, -2175.1892, 13.6538, 135.0000, 3, 1, -1);
  60. jobVehicles[5] = CreateVehicle(482, 2245.7339, -2180.4153, 13.6538, 135.0000, 3, 1, -1);
  61.  
  62. CreateObject(19059, 2253.40039, -2183.45166, 17.46260, 0.00000, 90.00000, 45.00000);
  63. CreateObject(19059, 2226.90356, -2156.94824, 17.46259, 0.00000, 90.00000, 45.00000);
  64. CreateObject(19060, 2232.17334, -2162.20068, 17.46260, 0.00000, 90.00000, 45.00000);
  65. CreateObject(19061, 2237.51318, -2167.51025, 17.46260, 0.00000, 90.00000, 45.00000);
  66. CreateObject(19062, 2242.76733, -2172.80518, 17.46260, 0.00000, 90.00000, 45.00000);
  67. CreateObject(19063, 2248.10010, -2178.14355, 17.46260, 0.00000, 90.00000, 45.00000);
  68. CreateObject(2510, 2244.32959, -2186.91162, 20.80740, 0.00000, 0.00000, 90.00000);
  69. CreateObject(2510, 2225.16260, -2166.36548, 20.80740, 0.00000, 0.00000, 0.00000);
  70. CreateObject(2510, 2233.41479, -2181.15625, 20.80740, 0.00000, 0.00000, 45.00000);
  71. CreateObject(1568, 2213.29590, -2165.32520, 13.34210, 0.00000, 0.00000, 0.00000);
  72. CreateObject(1568, 2244.87207, -2196.93555, 13.34215, 0.00000, 0.00000, 0.00000);
  73. CreateObject(1568, 2243.37622, -2177.72583, 12.54010, 0.00000, 0.00000, 0.00000);
  74. CreateObject(1568, 2237.82471, -2172.34839, 12.54010, 0.00000, 0.00000, 0.00000);
  75. CreateObject(1568, 2232.51343, -2167.08398, 12.54010, 0.00000, 0.00000, 0.00000);
  76. CreateObject(1568, 2248.67065, -2182.95654, 12.54014, 0.00000, 0.00000, 0.00000);
  77. CreateObject(1568, 2226.98999, -2161.66821, 12.54010, 0.00000, 0.00000, 0.00000);
  78.  
  79. CreateObject(19057, 2786.34985, -2446.70923, 13.13820, 0.00000, 0.00000, 0.00000);
  80. CreateObject(19054, 2789.31738, -2446.70923, 13.13820, 0.00000, 0.00000, 0.00000);
  81. CreateObject(19056, 2787.84570, -2446.70923, 13.13820, 0.00000, 0.00000, 0.00000);
  82. CreateObject(19054, 2789.31738, -2449.86206, 13.13820, 0.00000, 0.00000, 0.00000);
  83. CreateObject(19057, 2789.31738, -2448.29248, 13.13820, 0.00000, 0.00000, 0.00000);
  84. CreateObject(19056, 2777.63428, -2462.71924, 13.13820, 0.00000, 0.00000, 359.89999);
  85. CreateObject(19055, 2786.34985, -2448.29248, 13.13820, 0.00000, 0.00000, 0.00000);
  86. CreateObject(19055, 2787.84570, -2449.86206, 13.13820, 0.00000, 0.00000, 0.00000);
  87. CreateObject(19058, 2787.84570, -2448.29248, 13.13820, 0.00000, 0.00000, 0.00000);
  88. CreateObject(19057, 2789.31738, -2464.06738, 13.13820, 0.00000, 0.00000, 0.00000);
  89. CreateObject(19054, 2789.31738, -2465.52002, 13.13816, 0.00000, 0.00000, 0.00000);
  90. CreateObject(19054, 2789.31738, -2462.62280, 13.13820, 0.00000, 0.00000, 0.00000);
  91. CreateObject(19056, 2787.84570, -2462.62280, 13.13820, 0.00000, 0.00000, 0.00000);
  92. CreateObject(19058, 2787.84570, -2464.06738, 13.13820, 0.00000, 0.00000, 0.00000);
  93. CreateObject(19055, 2787.84570, -2465.52002, 13.13820, 0.00000, 0.00000, 0.00000);
  94. CreateObject(19056, 2786.34985, -2465.52002, 13.13820, 0.00000, 0.00000, 0.00000);
  95. CreateObject(19055, 2786.34985, -2464.06738, 13.13820, 0.00000, 0.00000, 0.00000);
  96. CreateObject(19057, 2786.34985, -2462.62280, 13.13820, 0.00000, 0.00000, 0.00000);
  97. CreateObject(2510, 2773.17163, -2456.02759, 17.16240, 0.00000, -10.00000, -90.00000);
  98. CreateObject(1568, 2773.80566, -2461.31982, 12.63910, 0.00000, 0.00000, 0.00000);
  99. CreateObject(1568, 2773.80566, -2450.53760, 12.63907, 0.00000, 0.00000, 0.00000);
  100. CreateObject(19056, 2786.34985, -2449.86206, 13.13820, 0.00000, 0.00000, 0.00000);
  101. CreateObject(19055, 2778.33594, -2447.31152, 13.13820, 0.00000, 0.00000, 0.00000);
  102. CreateObject(19056, 2780.14063, -2446.76660, 13.13820, 0.00000, 0.00000, 0.00000);
  103. CreateObject(19057, 2779.72119, -2448.80005, 13.13820, 0.00000, 0.00000, 0.00000);
  104. CreateObject(19057, 2780.64990, -2464.70923, 13.13820, 0.00000, 0.00000, 0.00000);
  105. CreateObject(19058, 2778.50708, -2464.92896, 13.13820, 0.00000, 0.00000, 359.89999);
  106. CreateObject(19055, 2779.95483, -2462.62939, 13.13820, 0.00000, 0.00000, 359.89999);
  107. CreateObject(2469, 2791.98853, -2461.35938, 14.27980, 0.00000, 0.00000, 180.00000);
  108. CreateObject(2464, 2783.76294, -2461.34741, 14.45417, 0.00000, 0.00000, 0.00000);
  109. CreateObject(2469, 2783.71924, -2450.59106, 14.32223, 0.00000, 0.00000, 0.00000);
  110. CreateObject(2464, 2783.71167, -2450.90771, 12.84029, 0.00000, 0.00000, 0.00000);
  111. CreateObject(2480, 2783.78296, -2450.94409, 15.75139, 0.00000, 0.00000, 0.00000);
  112. CreateObject(2474, 2791.78979, -2450.48413, 12.74016, 0.00000, 0.00000, 0.00000);
  113. CreateObject(2464, 2791.92749, -2450.95142, 15.24909, 0.00000, 0.00000, 0.00000);
  114. CreateObject(2485, 2792.01172, -2451.08716, 14.32813, 0.00000, 0.00000, 0.00000);
  115. CreateObject(2466, 2783.76294, -2461.34741, 13.65120, 0.00000, 0.00000, 180.00000);
  116. CreateObject(2468, 2791.80713, -2461.36426, 13.43120, 0.00000, 0.00000, 180.00000);
  117. CreateObject(2484, 2794.80347, -2448.80249, 13.52007, 0.00000, 0.00000, 45.00000);
  118. CreateObject(2492, 2794.05786, -2466.00391, 13.73340, 0.00000, 0.00000, -135.00000);
  119. CreateObject(2493, 2793.82397, -2465.78564, 13.73340, 0.00000, 0.00000, 45.00000);
  120. CreateObject(2494, 2794.05420, -2465.77173, 13.73340, 0.00000, 0.00000, -45.00000);
  121. CreateObject(2491, 2793.93652, -2465.53589, 12.73470, 0.00000, 0.00000, 45.00000);
  122.  
  123. SetTimer("jobCheck", 1000, true);
  124. print("\nJob Christmass loaded...");
  125. print("Credits: Edison, Valentino.");
  126. return 1;
  127. }
  128.  
  129. public OnPlayerConnect(playerid) {
  130. Working[playerid] = -1;
  131. Gifts[playerid] = 0;
  132. Checkpoint[playerid] = -1;
  133. TotalGifts[playerid] = 0;
  134.  
  135. InfoTD = CreatePlayerTextDraw(playerid, 173.821395, 374.500091, "");
  136. PlayerTextDrawLetterSize(playerid, InfoTD, 0.256500, 1.279167);
  137. PlayerTextDrawAlignment(playerid, InfoTD, 1);
  138. PlayerTextDrawColor(playerid, InfoTD, -1);
  139. PlayerTextDrawSetShadow(playerid, InfoTD, 0);
  140. PlayerTextDrawSetOutline(playerid, InfoTD, 1);
  141. PlayerTextDrawBackgroundColor(playerid, InfoTD, 51);
  142. PlayerTextDrawFont(playerid, InfoTD, 1);
  143. PlayerTextDrawSetProportional(playerid, InfoTD, 1);
  144.  
  145. RemoveBuildingForPlayer(playerid, 3744, 2241.2969, -2183.9766, 15.1016, 0.25);
  146. RemoveBuildingForPlayer(playerid, 3744, 2226.3203, -2168.9922, 15.1016, 0.25);
  147. RemoveBuildingForPlayer(playerid, 1226, 2224.7813, -2185.7422, 16.3516, 0.25);
  148. RemoveBuildingForPlayer(playerid, 3574, 2226.3203, -2168.9922, 15.1016, 0.25);
  149. RemoveBuildingForPlayer(playerid, 3574, 2241.2969, -2183.9766, 15.1016, 0.25);
  150. return 1;
  151. }
  152.  
  153. public OnPlayerDeath(playerid, killerid, reason) {
  154. JobFailed(playerid);
  155. return 1;
  156. }
  157.  
  158. public OnPlayerCommandText(playerid, cmdtext[]) {
  159. if(strcmp("/stopwork", cmdtext, true, 10) == 0)
  160. {
  161. if(Working[playerid] == -1) return 1;
  162. DisablePlayerCheckpoint(playerid);
  163. Working[playerid] = -1;
  164. Gifts[playerid] = 0;
  165. Checkpoint[playerid] = -1;
  166. TotalGifts[playerid] = 0;
  167. if(Vehicle[playerid] != -1) SetVehicleToRespawn(Vehicle[playerid]);
  168. Vehicle[playerid] = -1;
  169. SendClientMessage(playerid, COLOR_WHITE, "Stop working...");
  170. if(Timer[playerid] >= 1) { Timer[playerid] = -1; PlayerTextDrawHide(playerid, InfoTD); }
  171. return 1;
  172. }
  173. return 0;
  174. }
  175.  
  176. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) {
  177. if(vehicleid == jobVehicles[0] || vehicleid == jobVehicles[1] || vehicleid == jobVehicles[2] || vehicleid == jobVehicles[3] || vehicleid == jobVehicles[4] || vehicleid == jobVehicles[5]) {
  178. if(Working[playerid] == -1) {
  179. new Float: Position[3];
  180. GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
  181. SetPlayerPos(playerid, Position[0], Position[1], Position[2]+1);
  182. SendClientMessage(playerid, COLOR_WHITE, "You do not work!");
  183. }
  184. else {
  185. if(Timer[playerid] >= 1) { Timer[playerid] = -1; PlayerTextDrawHide(playerid, InfoTD); }
  186. }
  187. }
  188. return 1;
  189. }
  190.  
  191. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  192. new string[256];
  193. if(newkeys == KEY_NO) {
  194. if(Working[playerid] == -1) return 1;
  195. if(IsPlayerInAnyVehicle(playerid)) return 1;
  196. if(Vehicle[playerid] == -1 && Working[playerid] == 1) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "* You must to climb in a vehicle and after upload gifts.");
  197. if(CheckPlayerDistanceToVehicle(5.0, playerid, Vehicle[playerid])) {
  198. RemovePlayerAttachedObject(playerid, 5);
  199. if(TotalGifts[playerid] == 0) return 1;
  200. if(GiftHand[playerid] == -1) {
  201. GiftHand[playerid] = 1;
  202. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
  203. new rand = random(4), gift;
  204. if(rand == 0) gift = 19054;
  205. else if(rand == 1) gift = 19055;
  206. else if(rand == 2) gift = 19056;
  207. else if(rand == 3) gift = 19057;
  208. else if(rand == 4) gift = 19058;
  209. SetPlayerAttachedObject( playerid, 5, gift, 1, 0.179536, 0.436568, -0.047055, 0.000000, 84.821968, 77.998138, 0.405070, 1.000000, 0.225547 );
  210. SendClientMessage(playerid, COLOR_WHITE, "* You have took one gift from your vehicle!");
  211. }
  212. else if(GiftHand[playerid] == 1) {
  213. GiftHand[playerid] = -1;
  214. RemovePlayerAttachedObject(playerid, 5);
  215. SetPlayerSpecialAction(playerid, 0);
  216. SendClientMessage(playerid, COLOR_WHITE, "* You have put the gift in your vehicle!");
  217. if(TotalGifts[playerid] < 9 && Checkpoint[playerid] == -1) {
  218. format(string, sizeof(string), "{FFBC63}Want to get gifts?\nCurrently, you have only {94FF63}%d gifts{FFFFFF}.", TotalGifts[playerid]);
  219. ShowPlayerDialog(playerid, DIALOG_STATUS, DIALOG_STYLE_MSGBOX, " ", string, "Yes", "No");
  220. }
  221. if(Gifts[playerid] == 10) {
  222. format(string, sizeof(string), "{FFBC63}Congratulations, {638DFF}%s{FFBC63}!\nYou have {94FF63}finished{FFBC63} the step one. Next step consist to distrbuite gifts on different houses. Success!", GetName(playerid));
  223. ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, " ", string, "Okay", "");
  224. new rand = random(sizeof(HousePos));
  225. SetPlayerCheckpoint(playerid, HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2], 2.0);
  226. format(string, sizeof(string), "You have still %d gifts distributed! Distance: %0.2fm", Gifts[playerid], GetPlayerDistanceFromPoint(playerid, HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2]));
  227. SendClientMessage(playerid, 0xFFFF00FF, string);
  228. Checkpoint[playerid] = 1;
  229. }
  230. }
  231. }
  232. else if(IsPlayerInRangeOfPoint(playerid, 5.0,2779.7212, -2448.8000, 13.1382) || IsPlayerInRangeOfPoint(playerid, 5.0,2787.8457, -2449.8621, 13.1382)
  233. || IsPlayerInRangeOfPoint(playerid, 5.0,2787.8457, -2462.6228, 13.1382) || IsPlayerInRangeOfPoint(playerid, 5.0,2779.9548, -2462.6294, 13.1382)) {
  234. if(Gifts[playerid] == 10) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "* You have a maximum gifts (10).");
  235. if(GiftHand[playerid] == 1) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "* You already have a gift in your hands!");
  236. Gifts[playerid] ++;
  237. TotalGifts[playerid] ++;
  238. new rand = random(4), gift;
  239. if(rand == 0) gift = 19054;
  240. else if(rand == 1) gift = 19055;
  241. else if(rand == 2) gift = 19056;
  242. else if(rand == 3) gift = 19057;
  243. else if(rand == 4) gift = 19058;
  244. SetPlayerAttachedObject( playerid, 5, gift, 1, 0.179536, 0.436568, -0.047055, 0.000000, 84.821968, 77.998138, 0.405070, 1.000000, 0.225547 );
  245. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
  246. GiftHand[playerid] = 1;
  247. }
  248. }
  249. return 1;
  250. }
  251.  
  252. public OnPlayerExitVehicle(playerid, vehicleid) {
  253. if(Working[playerid] == 1 && TotalGifts[playerid] >= 1 && vehicleid == jobVehicles[0] || vehicleid == jobVehicles[1] || vehicleid == jobVehicles[2] || vehicleid == jobVehicles[3] || vehicleid == jobVehicles[4] || vehicleid == jobVehicles[5] && Gifts[playerid] != 0) {
  254. SendClientMessage(playerid, COLOR_WHITE, "You have one minute to distribute gift on the checkpoint!");
  255. Timer[playerid] = 60;
  256. PlayerTextDrawSetString(playerid, InfoTD, "~y~Gift Distributor~w~~h~~n~You have 60 seconds until you enter in the vehicle.");
  257. PlayerTextDrawShow(playerid, InfoTD);
  258. }
  259. return 1;
  260. }
  261.  
  262. public OnPlayerStateChange(playerid, newstate, oldstate) {
  263. if(newstate == PLAYER_STATE_DRIVER) {
  264. new vehicleid = GetPlayerVehicleID(playerid);
  265. if(vehicleid == jobVehicles[0] || vehicleid == jobVehicles[1] || vehicleid == jobVehicles[2] || vehicleid == jobVehicles[3] || vehicleid == jobVehicles[4] || vehicleid == jobVehicles[5] && Gifts[playerid] == 0) {
  266. if(TotalGifts[playerid] != 0) return 1;
  267. Vehicle[playerid] = vehicleid;
  268. SendClientMessage(playerid, COLOR_WHITE, "Go to red checkpoint to load gifts!");
  269. SetPlayerCheckpoint(playerid, 2774.2368, -2455.7124, 12.6391, 8.0);
  270. Checkpoint[playerid] = 3;
  271. }
  272. }
  273. return 1;
  274. }
  275.  
  276. public OnPlayerEnterCheckpoint(playerid) {
  277. new string[256];
  278. if(Checkpoint[playerid] == 1) {
  279. if(GiftHand[playerid] == -1) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "* You do not have a gift in your hands!");
  280. DisablePlayerCheckpoint(playerid);
  281. SetPlayerSpecialAction(playerid, 0);
  282. Gifts[playerid] --;
  283. GiftHand[playerid] = -1;
  284. RemovePlayerAttachedObject(playerid, 5);
  285. new rand = random(sizeof(HousePos));
  286. SetPlayerCheckpoint(playerid, HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2], 2.0);
  287. if(Gifts[playerid] != 0) {
  288. Checkpoint[playerid] = 1;
  289. format(string, sizeof(string), "You have still %d gifts distributed! Distance: %0.2fm", Gifts[playerid], GetPlayerDistanceFromPoint(playerid, HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2]));
  290. SendClientMessage(playerid, 0xFFFF00FF, string);
  291. }
  292. // de terminat
  293. if(Gifts[playerid] == 0) {
  294. Gifts[playerid] = -1;
  295. DisablePlayerCheckpoint(playerid);
  296. SetPlayerCheckpoint(playerid, 2251.8628, -2206.0054, 13.4719, 9.0);
  297. Checkpoint[playerid] = 2;
  298. format(string, sizeof(string), "{FFBC63}Congratulations, {638DFF}%s{FFBC63}!\nYou have {94FF63}finished{FFBC63} the step two. The last step is to go to the checkpoint to take the money!", GetName(playerid));
  299. ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, " ", string, "Okay", "");
  300. }
  301. return 1;
  302. }
  303. if(Checkpoint[playerid] == 2) {
  304. if(IsPlayerInVehicle(playerid, Vehicle[playerid])) SetVehicleToRespawn(Vehicle[playerid]);
  305. DisablePlayerCheckpoint(playerid);
  306. new money = 1000 + random(500) * TotalGifts[playerid];
  307. format(string, sizeof(string), "You delivered %d gifts.", TotalGifts[playerid]);
  308. SendClientMessage(playerid, 0x25B336FF, string);
  309. format(string, sizeof(string), "Congratulations, you have earned $%d.", money);
  310. SendClientMessage(playerid, 0x25B336FF, string);
  311. GivePlayerMoney(playerid, money);
  312. TotalGifts[playerid] = 0;
  313. Checkpoint[playerid] = -1;
  314. Working[playerid] = -1;
  315. return 1;
  316. }
  317. if(Checkpoint[playerid] == 3) {
  318. DisablePlayerCheckpoint(playerid);
  319. SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Go to gifts and use key N to load a gift!");
  320. Checkpoint[playerid] = -1;
  321. return 1;
  322. }
  323. return 1;
  324. }
  325.  
  326. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  327. new string[256];
  328. switch(dialogid) {
  329. case DIALOG_STATUS: {
  330. if(response) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Continue to take gifts!");
  331. format(string, sizeof(string), "{FFBC63}Congratulations, {638DFF}%s{FFBC63}!\nYou have {94FF63}finished{FFBC63} the step one. Next step consist to distrbuite gifts on different houses. Success!", GetName(playerid));
  332. ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, " ", string, "Okay", "");
  333. new rand = random(sizeof(HousePos));
  334. SetPlayerCheckpoint(playerid, HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2], 2.0);
  335. format(string, sizeof(string), "You have still %d gifts distributed! Distance: %0.2fm", Gifts[playerid], GetPlayerDistanceFromPoint(playerid, HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2]));
  336. SendClientMessage(playerid, 0xFFFF00FF, string);
  337. Checkpoint[playerid] = 1;
  338. }
  339. case DIALOG_JOB: {
  340. if(!response) return 1;
  341. if(Working[playerid] == 1) return 1;
  342. Working[playerid] = 1;
  343. TotalGifts[playerid] = 0;
  344. Gifts[playerid] = 0;
  345. SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Congratulations! Now you can working on job.");
  346. }
  347. }
  348. return 1;
  349. }
  350.  
  351. public OnPlayerSpawn(playerid)
  352. {
  353. SetPlayerPos(playerid, 2224.7813, -2185.7422, 16.3516);
  354. return 1;
  355. }
  356.  
  357. public OnPlayerPickUpPickup(playerid, pickupid)
  358. {
  359. if(pickupid == jobPickup) {
  360. if(Working[playerid] == 1) return 1;
  361. new string[1024];
  362. strcat(string, "{FFBC63}Welcome to job {638DFF}Gift Distribuitor{FFBC63}!\n\nInformations:\n{638DFF}•{FFBC63} There are two steps to this job.\n{638DFF}•{FFBC63} The first step is that you must go to the warehouse to load");
  363. strcat(string, "gifts in the vehicle from job.\n{638DFF}•{FFBC63} The second and final step at the same time have to go to some houses (depending on how many");
  364. strcat(string, "gifts you get from the warehouse).\n{638DFF}•{FFBC63} Finally, you get a checkpoint and have to go to him. Once you get into it, get some money");
  365. strcat(string, "(depending on how many gifts you had).\n{638DFF}•{FFBC63} If you want to not work, use the command {638DFF}/stopwork{FFBC63}!\n\nDo you start work? If so, click the button {94FF63}Start!{FFBC63}");
  366. ShowPlayerDialog(playerid, DIALOG_JOB, DIALOG_STYLE_MSGBOX, " ", string, "Start", "Close");
  367. }
  368. return 1;
  369. }
  370.  
  371. forward jobCheck();
  372. public jobCheck() {
  373.  
  374. new string[256];
  375. for(new i = 0; i < MAX_PLAYERS; i++) {
  376. if(IsPlayerConnected(i)) {
  377. if(Timer[i] >= 1) {
  378. Timer[i] --;
  379. format(string, sizeof(string), "~y~Gift Distributor~w~~h~~n~You have %d seconds until you enter the vehicle.", Timer);
  380. PlayerTextDrawSetString(i, InfoTD, string);
  381. PlayerTextDrawShow(i, InfoTD);
  382. if(Timer[i] == 0) {
  383. Timer[i] = -1;
  384. JobFailed(i);
  385. PlayerTextDrawHide(i, InfoTD);
  386. }
  387. }
  388. }
  389. }
  390. return 1;
  391. }
  392.  
  393. stock JobFailed(playerid) {
  394. if(Working[playerid] == 1) {
  395. DisablePlayerCheckpoint(playerid);
  396. Working[playerid] = -1;
  397. Gifts[playerid] = 0;
  398. Checkpoint[playerid] = -1;
  399. TotalGifts[playerid] = 0;
  400. SetVehicleToRespawn(Vehicle[playerid]);
  401. Vehicle[playerid] = -1;
  402. SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Job failed!");
  403. SendClientMessage(playerid, COLOR_WHITE, "You lost the car and gifts.");
  404. }
  405. return 1;
  406. }
  407.  
  408. stock GetName(playerid) {
  409. new
  410. pName[MAX_PLAYER_NAME];
  411.  
  412. GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  413. return pName;
  414. }
  415.  
  416. stock CheckPlayerDistanceToVehicle(Float:radi, playerid, vehicleid) {
  417. if(IsPlayerConnected(playerid)) {
  418. new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z;
  419. GetPlayerPos(playerid,PX,PY,PZ);
  420. GetVehiclePos(vehicleid, X,Y,Z);
  421. new Float:Distance = (X-PX)*(X-PX)+(Y-PY)*(Y-PY)+(Z-PZ)*(Z-PZ);
  422. if(Distance <= radi*radi) return 1;
  423. }
  424. return 0;
  425. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement