1
0

points.inc 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. /*
  2. _____ _ _ ____ _____ _
  3. | __ \ (_) | | | _ \ | __ \ | |
  4. | |__) |__ _ _ __ | |_ ___ | |_) |_ _ | | | | ___ ___ _ __ ___ ___ _ __ __| |
  5. | ___/ _ \| | '_ \| __/ __| | _ <| | | | | | | |/ _ \/ __| '_ ` _ \ / _ \| '_ \ / _` |
  6. | | | (_) | | | | | |_\__ \ | |_) | |_| | | |__| | __/\__ \ | | | | | (_) | | | | (_| |
  7. |_| \___/|_|_| |_|\__|___/ |____/ \__, | |_____/ \___||___/_| |_| |_|\___/|_| |_|\__,_|
  8. __/ |
  9. |___/
  10. */
  11. // THE SYSTEM IS A MESS, TO BE IMPROVED - DESMOND
  12. #define MAX_POINTS 15
  13. #define DIALOG_EDIT_POINT 14822
  14. #define DIALOG_EDIT_POINT_NAME 14823
  15. #define DIALOG_EDIT_POINT_TIME 14824
  16. /* format(teststr, sizeof(teststr), "%s\n{FFFFFF}/capture", Points[idx][PointName]);
  17. if(idx != 0 && idx != 1) Points[idx][Point3D] = Create3DTextLabel(teststr, 0x43527DFF, Points[idx][PointPosition][0], Points[idx][PointPosition][1], Points[idx][PointPosition][2], 15, 0, 1);
  18. Keeping this here in case more points will be added and we will want to keep that style ^
  19. */
  20. // easier to know each id's point
  21. #define PMATSPICKUP1 0
  22. #define PMATSPICKUP2 1
  23. #define PAUTOEXPORT 2
  24. #define PSPRUNKFACTORY 3
  25. #define PDRUGSFACTORY 4
  26. enum pointsinfo
  27. {
  28. PointName[36],
  29. PointTime, // in seconds, time left for people to be able to /capture
  30. PointCaptureTime, // in seconds, time left for the people who last did /capture to get the point
  31. bool:PointDeployed, // a bool to check if the point exists
  32. bool:PointEnabled, // a bool to check if the point is currently available to capture
  33. Float:PointPosition[3],
  34. Text3D:Point3D, // the /capture 3D
  35. PointPickup, // the /capture pickup
  36. bool:PointDeathMessage, // false or true - whenever a message should be sent to a player who dies in range of a point or not
  37. bool:PointDrugs, // a bool to check if the point has drugs to claim (only for drugs factory)
  38. PointFamily, // family slot
  39. PointOwner[MAX_PLAYER_NAME+1],
  40. PointBorder, // the gangzone id
  41. Float:PointBorders[4] // 4 gangzone positions, X, Y, X, Y
  42. };
  43. new Points[MAX_POINTS][pointsinfo];
  44. new PointsCount = 0;
  45. new capturingpointtime[MAX_PLAYERS],
  46. Float:capturingposition[MAX_PLAYERS][3],
  47. capturingpoint[MAX_PLAYERS],
  48. editingpoint[MAX_PLAYERS],
  49. borderseditcount[MAX_PLAYERS], Float:bordersedit[MAX_PLAYERS][4],
  50. bool:viewingpointborders[MAX_PLAYERS][15];
  51. new teststr[128];
  52. forward PointsTimer();
  53. forward IsDefaultPoint(pointid);
  54. forward SetupPoint(pointid, pointname[], hours, Float:x, Float:y, Float:z); // id, name of the point, hours till the point can be captured on start, x of the point, y of the point, z of the point
  55. public SetupPoint(pointid, pointname[], hours, Float:x, Float:y, Float:z)
  56. {
  57. format(Points[pointid][PointName], 36, pointname);
  58. Points[pointid][PointDeployed] = true;
  59. Points[pointid][PointEnabled] = false;
  60. Points[pointid][PointTime] = hours*3600;
  61. Points[pointid][PointPosition][0] = x;
  62. Points[pointid][PointPosition][1] = y;
  63. Points[pointid][PointPosition][2] = z;
  64. return 1;
  65. }
  66. Hook:points_OnGameModeInit()
  67. {
  68. LoadPoints();
  69. SetupPoint(PMATSPICKUP1, "Materials Pickup 1", 9, 1423.5864, -1320.5120, 13.5547);
  70. SetupPoint(PMATSPICKUP2, "Materials Pickup 2", 10, 2390.38114, -2008.3320, 13.5537);
  71. SetupPoint(PAUTOEXPORT, "Auto Export", 7, 2610.0503, -2239.3501, 13.5392);
  72. SetupPoint(PSPRUNKFACTORY, "Sprunk Factory", 11, 1324.2122, 286.5997, 20.0452);
  73. SetupPoint(PDRUGSFACTORY, "Drugs Factory", 12, -159.9184, -287.2171, 3.9053);
  74. SetTimer("PointsTimer", 1000, true);
  75. return 1;
  76. }
  77. Hook:points_OnGameModeExit()
  78. {
  79. SavePoints();
  80. return 1;
  81. }
  82. LoadPoints()
  83. {
  84. new arrCoords[13][64];
  85. new strFromFile[3000];
  86. new File: file = fopen("pointss2.cfg", io_read);
  87. if(file)
  88. {
  89. new idx, deathmsgconvert, deployedconvert;
  90. while(idx < sizeof(Points))
  91. {
  92. fread(file, strFromFile);
  93. split(strFromFile, arrCoords, '|');
  94. format(Points[idx][PointOwner], MAX_PLAYER_NAME, arrCoords[1]);
  95. Points[idx][PointTime] = strvalEx(arrCoords[2]);
  96. deathmsgconvert = strvalEx(arrCoords[3]);
  97. if(deathmsgconvert == 1) Points[idx][PointDeathMessage] = true;
  98. else if(deathmsgconvert == 0) Points[idx][PointDeathMessage] = false;
  99. Points[idx][PointFamily] = strvalEx(arrCoords[4]);
  100. Points[idx][PointCaptureTime] = 0;
  101. if(Points[idx][PointTime] == 0) Points[idx][PointEnabled] = true;
  102. else Points[idx][PointEnabled] = false;
  103. deployedconvert = strvalEx(arrCoords[8]);
  104. if(deployedconvert == 1) Points[idx][PointDeployed] = true && PointsCount++;
  105. else if(deployedconvert == 0) Points[idx][PointDeployed] = false;
  106. Points[idx][PointBorders][0] = floatstr(arrCoords[9]);
  107. Points[idx][PointBorders][1] = floatstr(arrCoords[10]);
  108. Points[idx][PointBorders][2] = floatstr(arrCoords[11]);
  109. Points[idx][PointBorders][3] = floatstr(arrCoords[12]);
  110. Points[idx][PointBorder] = GangZoneCreate(Points[idx][PointBorders][0], Points[idx][PointBorders][1], Points[idx][PointBorders][2], Points[idx][PointBorders][3]);
  111. idx++;
  112. }
  113. fclose(file);
  114. } else {
  115. printf("[error] Failed to find pointss2.cfg");
  116. }
  117. return 1;
  118. }
  119. SavePoints()
  120. {
  121. new idx;
  122. new File:file;
  123. file = fopen("pointss2.cfg", io_write);
  124. fclose(file);
  125. file = fopen("pointss2.cfg", io_append);
  126. new coordsstring[2000];
  127. while(idx < sizeof(Points))
  128. {
  129. new deathmsgconvert, deployedconvert;
  130. if(Points[idx][PointDeathMessage] == true) deathmsgconvert = 1;
  131. else deathmsgconvert = 0;
  132. if(Points[idx][PointDeployed] == true) deployedconvert = 1;
  133. else deployedconvert = 0;
  134. format(coordsstring, sizeof(coordsstring), "%s|%s|%d|%d|%d|%f|%f|%f|%d|%f|%f|%f|%f\n",
  135. Points[idx][PointName],
  136. Points[idx][PointOwner],
  137. Points[idx][PointTime],
  138. deathmsgconvert,
  139. Points[idx][PointFamily],
  140. Points[idx][PointPosition][0],
  141. Points[idx][PointPosition][1],
  142. Points[idx][PointPosition][2],
  143. deployedconvert,
  144. Points[idx][PointBorders][0],
  145. Points[idx][PointBorders][1],
  146. Points[idx][PointBorders][2],
  147. Points[idx][PointBorders][3]);
  148. fwrite(file, coordsstring);
  149. idx++;
  150. }
  151. fclose(file);
  152. return 1;
  153. }
  154. public IsDefaultPoint(pointid)
  155. {
  156. if(pointid == PMATSPICKUP1 || pointid == PMATSPICKUP2 || pointid == PAUTOEXPORT || pointid == PSPRUNKFACTORY || pointid == PDRUGSFACTORY) return true;
  157. else return false;
  158. }
  159. Hook:points_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  160. {
  161. if(dialogid == DIALOG_EDIT_POINT)
  162. {
  163. if(response)
  164. {
  165. switch(listitem)
  166. {
  167. case 0:
  168. {
  169. if(IsDefaultPoint(editingpoint[playerid])) return SendClientMessage(playerid, COLOR_GREY, "You can not edit a default point's name.");
  170. format(teststr, sizeof(teststr), "Enter a new name for point: %s", Points[editingpoint[playerid]][PointName]);
  171. ShowPlayerDialog(playerid, DIALOG_EDIT_POINT_NAME, DIALOG_STYLE_INPUT, "Point Name", teststr, "Set", "Cancel");
  172. }
  173. case 1: ShowPlayerDialog(playerid, DIALOG_EDIT_POINT_TIME, DIALOG_STYLE_INPUT, "Point Time", "Enter a new time for the point (in hours, time till /capture for that point is available)", "Set", "Cancel");
  174. case 2:
  175. {
  176. if(IsDefaultPoint(editingpoint[playerid])) return SendClientMessage(playerid, COLOR_GREY, "You can not edit a default point's position.");
  177. new Float: temppos[3], pointid = editingpoint[playerid];
  178. GetPlayerPos(playerid, temppos[0], temppos[1], temppos[2]);
  179. Points[pointid][PointPosition][0] = temppos[0];
  180. Points[pointid][PointPosition][1] = temppos[1];
  181. Points[pointid][PointPosition][2] = temppos[2];
  182. DestroyDynamicPickup(Points[pointid][PointPickup]);
  183. Points[pointid][PointPickup] = CreateDynamicPickup(1254, 1, Points[pointid][PointPosition][0], Points[pointid][PointPosition][1], Points[pointid][PointPosition][2]);
  184. Delete3DTextLabel(Points[pointid][Point3D]);
  185. format(teststr, sizeof(teststr), "%s\n{FFFFFF}/capture", Points[pointid][PointName]);
  186. Points[pointid][Point3D] = Create3DTextLabel(teststr, 0x43527DFF, Points[pointid][PointPosition][0], Points[pointid][PointPosition][1], Points[pointid][PointPosition][2], 15, 0, 1);
  187. SendClientMessage(playerid, COLOR_GREY, "That point's position has been changed to your current position.");
  188. }
  189. case 3:
  190. {
  191. new pointid = editingpoint[playerid];
  192. if(Points[pointid][PointDeathMessage] == true)
  193. {
  194. Points[pointid][PointDeathMessage] = false;
  195. SendClientMessage(playerid, COLOR_GREY, "Players will no longer be informed if they died near a point.");
  196. }
  197. else
  198. {
  199. Points[pointid][PointDeathMessage] = true;
  200. SendClientMessage(playerid, COLOR_GREY, "Players will now be informed if they died near a point.");
  201. }
  202. }
  203. case 4:
  204. {
  205. borderseditcount[playerid] = 4;
  206. SendClientMessage(playerid, COLOR_GREY, "You are now editing the borders of the point. Type /setpborders 4 times (make a square) to complete.");
  207. }
  208. }
  209. }
  210. }
  211. if(dialogid == DIALOG_EDIT_POINT_NAME)
  212. {
  213. if(response)
  214. {
  215. if(strlen(inputtext) <= 0 || strlen(inputtext) > 35)
  216. {
  217. SendClientMessage(playerid, COLOR_GREY, "The point's name must be between 1-35 characters.");
  218. format(teststr, sizeof(teststr), "Enter a new name for point: %s", Points[editingpoint[playerid]][PointName]);
  219. ShowPlayerDialog(playerid, DIALOG_EDIT_POINT_NAME, DIALOG_STYLE_INPUT, "Point Name", teststr, "Set", "Cancel");
  220. }
  221. else
  222. {
  223. new pointid = editingpoint[playerid];
  224. format(Points[pointid][PointName], 36, "%s", inputtext);
  225. format(teststr, sizeof(teststr), "You have set that point's name to %s", Points[pointid][PointName]);
  226. SendClientMessage(playerid, COLOR_GREY, teststr);
  227. Delete3DTextLabel(Points[pointid][Point3D]);
  228. format(teststr, sizeof(teststr), "%s\n{FFFFFF}/capture", Points[pointid][PointName]);
  229. Points[pointid][Point3D] = Create3DTextLabel(teststr, 0x43527DFF, Points[pointid][PointPosition][0], Points[pointid][PointPosition][1], Points[pointid][PointPosition][2], 15, 0, 1);
  230. }
  231. }
  232. }
  233. if(dialogid == DIALOG_EDIT_POINT_TIME)
  234. {
  235. if(response)
  236. {
  237. if(!IsNumeric(inputtext) || strval(inputtext) < 0)
  238. {
  239. SendClientMessage(playerid, COLOR_GREY, "Please enter a valid number.");
  240. ShowPlayerDialog(playerid, DIALOG_EDIT_POINT_TIME, DIALOG_STYLE_INPUT, "Point Time", "Enter a new time for the point (in hours, time till /capture for that point is available)", "Set", "Cancel");
  241. }
  242. else
  243. {
  244. new pointid = editingpoint[playerid];
  245. Points[pointid][PointTime] = strval(inputtext)*3600;
  246. if(Points[pointid][PointTime] == 0)
  247. {
  248. format(teststr, sizeof(teststr), "You have set that point's time to %i hours causing it to be available to capture.", strval(inputtext));
  249. SendClientMessage(playerid, COLOR_GREY, teststr);
  250. foreach(new i: Player)
  251. {
  252. format(teststr, sizeof(teststr), "The %s is now available to capture.", Points[pointid][PointName]);
  253. SendClientMessage(i, COLOR_YELLOW, teststr);
  254. GangZoneShowForAll(Points[pointid][PointBorder], COLOR_RED);
  255. Points[pointid][PointEnabled] = true;
  256. if(PlayerInfo[i][pFMember] != 255)
  257. {
  258. SetPlayerCheckpointEx(i, Points[pointid][PointPosition][0], Points[pointid][PointPosition][1], Points[pointid][PointPosition][2], 2.0);
  259. CP[i] = 35;
  260. SendClientMessage(i, COLOR_GREY, "A checkpoint has been set for you to the available point as you're a family member.");
  261. }
  262. }
  263. }
  264. else
  265. {
  266. format(teststr, sizeof(teststr), "You have set that point's time to %i hours.", strval(inputtext));
  267. Points[pointid][PointEnabled] = false;
  268. SendClientMessage(playerid, COLOR_GREY, teststr);
  269. GangZoneHideForAll(Points[pointid][PointBorder]);
  270. }
  271. }
  272. }
  273. }
  274. return 1;
  275. }
  276. Hook:points_OnPlayerDeath(playerid, killerid, reason)
  277. {
  278. for(new p = 0; p < MAX_POINTS; p++)
  279. {
  280. if(Points[p][PointFamily] == PlayerInfo[playerid][pFMember] && Points[p][PointEnabled] == true && IsPlayerInRangeOfPoint(playerid, 30, Points[p][PointPosition][0], Points[p][PointPosition][1], Points[p][PointPosition][2]) && !strcmp(PlayerName(playerid), Points[p][PointOwner]))
  281. {
  282. Points[p][PointFamily] = 255;
  283. Points[p][PointCaptureTime] = 0;
  284. GiveMoney(killerid, 5000);
  285. foreach(new i: Player)
  286. {
  287. if(PlayerInfo[i][pFMember] != 255)
  288. {
  289. format(teststr, sizeof(teststr), "%s has died during the capturing of %s and no longer holds it.", PlayerICName(playerid), Points[p][PointName]);
  290. SendClientMessage(i, COLOR_YELLOW, teststr);
  291. format(teststr, sizeof(teststr), "%s has killed the point's conqueror %s and claimed $5000.", PlayerICName(killerid), PlayerICName(playerid));
  292. SendClientMessage(i, COLOR_YELLOW, teststr);
  293. }
  294. }
  295. break;
  296. }
  297. if(Points[p][PointEnabled] == true)
  298. {
  299. if(Points[p][PointDeathMessage] == true && IsPlayerInRangeOfPoint(playerid, 30.0, Points[p][PointPosition][0], Points[p][PointPosition][1], Points[p][PointPosition][2]))
  300. {
  301. format(teststr, sizeof(teststr), "You have died in range of point: %s", Points[p][PointName]);
  302. SendClientMessage(playerid, COLOR_RED, teststr);
  303. break;
  304. }
  305. }
  306. }
  307. return 1;
  308. }
  309. Hook:points_OnPlayerDisconnect(playerid, reason)
  310. {
  311. for(new p = 0; p < MAX_POINTS; p++)
  312. {
  313. if(Points[p][PointFamily] == PlayerInfo[playerid][pFMember] && Points[p][PointEnabled] == true && PlayerInfo[playerid][pFMember] != 255 && !strcmp(PlayerName(playerid), Points[p][PointOwner]))
  314. {
  315. Points[p][PointFamily] = 255;
  316. Points[p][PointCaptureTime] = 0;
  317. }
  318. }
  319. return 1;
  320. }
  321. Hook:ps_OnPlayerEnterCheckpoint(playerid)
  322. {
  323. if(CP[playerid] == 35)
  324. {
  325. DisablePlayerCheckpointEx(playerid);
  326. }
  327. if(CP[playerid] == CHECKPOINT_MATERIALS_1)
  328. {
  329. if(Points[PMATSPICKUP1][PointFamily] == PlayerInfo[playerid][pFMember] && PlayerInfo[playerid][pFMember] != 255)
  330. {
  331. PlayerInfo[playerid][pMats] += 100;
  332. SendClientMessage(playerid, COLOR_LIGHTBLUE, "The factory has given you a bonus of 100 materials due to your family holding Materials Pickup 1.");
  333. }
  334. }
  335. if(CP[playerid] == CHECKPOINT_MATERIALS_2)
  336. {
  337. if(Points[PMATSPICKUP2][PointFamily] == PlayerInfo[playerid][pFMember] && PlayerInfo[playerid][pFMember] != 255)
  338. {
  339. PlayerInfo[playerid][pMats] += 100;
  340. SendClientMessage(playerid, COLOR_LIGHTBLUE, "The factory has given you a bonus of 100 materials due to your family holding Materials Pickup 2.");
  341. }
  342. }
  343. return 1;
  344. }
  345. public PointsTimer()
  346. {
  347. for(new p = 0; p < MAX_POINTS; p++)
  348. {
  349. if(Points[p][PointDeployed] == true)
  350. {
  351. if(Points[p][PointTime] > 0)
  352. {
  353. Points[p][PointTime] --;
  354. if(Points[p][PointTime] == 0)
  355. {
  356. format(teststr, sizeof(teststr), "The %s is now available to capture.", Points[p][PointName]);
  357. SendClientMessageToAll(COLOR_YELLOW, teststr);
  358. Points[p][PointEnabled] = true;
  359. GangZoneShowForAll(Points[p][PointBorder], COLOR_RED);
  360. SavePoints();
  361. foreach(new i: Player)
  362. {
  363. if(PlayerInfo[i][pFMember] != 255)
  364. {
  365. SetPlayerCheckpointEx(i, Points[p][PointPosition][0], Points[p][PointPosition][1], Points[p][PointPosition][2], 2.0);
  366. CP[i] = 35;
  367. SendClientMessage(i, COLOR_GREY, "A checkpoint has been set for you to the available point as you're a family member.");
  368. }
  369. }
  370. }
  371. }
  372. }
  373. }
  374. foreach(new i: Player)
  375. {
  376. if(capturingpointtime[i] > 0)
  377. {
  378. capturingpointtime[i] --;
  379. if(capturingpointtime[i] == 0)
  380. {
  381. new Float:X, Float:Y, Float:Z;
  382. GetPlayerPos(i, X, Y, Z);
  383. if(capturingposition[i][0] == X && capturingposition[i][1] == Y && capturingposition[i][2] == Z)
  384. {
  385. format(teststr, sizeof(teststr), "%s is attempting to capture the %s, 10 minutes left.", PlayerICName(i), Points[capturingpoint[i]][PointName]);
  386. SendClientMessageToAll(COLOR_YELLOW, teststr);
  387. Points[capturingpoint[i]][PointCaptureTime] = 600;
  388. Points[capturingpoint[i]][PointFamily] = PlayerInfo[i][pFMember];
  389. GetPlayerName(i, Points[capturingpoint[i]][PointOwner], MAX_PLAYER_NAME);
  390. }
  391. else
  392. {
  393. SendClientMessage(i, COLOR_RED, "You have moved during the capturing time and failed.");
  394. }
  395. }
  396. }
  397. }
  398. for(new p = 0; p < MAX_POINTS; p++)
  399. {
  400. if(Points[p][PointEnabled] == true)
  401. {
  402. if(Points[p][PointCaptureTime] > 0)
  403. {
  404. Points[p][PointCaptureTime] --;
  405. new capturer = GetPlayerIDFromName(Points[p][PointOwner]);
  406. if(IsPlayerConnected(capturer))
  407. {
  408. new ptime = Points[p][PointCaptureTime];
  409. if(ptime%60 == 0)
  410. {
  411. if(ptime >= 60)
  412. {
  413. format(teststr, sizeof(teststr), "~r~%d minutes left", ptime/60);
  414. displayCenterHUDInfo(capturer, teststr, 5);
  415. }
  416. }
  417. else if(ptime < 60)
  418. {
  419. format(teststr, sizeof(teststr), "~r~%d seconds left", ptime);
  420. displayCenterHUDInfo(capturer, teststr, 5);
  421. }
  422. }
  423. if(Points[p][PointCaptureTime] == 0)
  424. {
  425. format(teststr, sizeof(teststr), "%s has successfully captured the %s point, it is theirs for the next 8 hours.", Points[p][PointOwner], Points[p][PointName]);
  426. SendClientMessageToAll(COLOR_YELLOW, teststr);
  427. Points[p][PointTime] = 8*3600; // convert hours to seconds. 1 hour = 3600 seconds
  428. if(p == PDRUGSFACTORY) // drugs factory point id
  429. {
  430. new capturedby = GetPlayerIDFromName(Points[p][PointOwner]);
  431. Points[PDRUGSFACTORY][PointDrugs] = true;
  432. Points[PDRUGSFACTORY][PointTime] = 12*3600; // extended time due to drugs factory point
  433. new randompdrug = random(3);
  434. switch(randompdrug)
  435. {
  436. case 0:
  437. {
  438. FamilyInfo[Points[PDRUGSFACTORY][PointFamily]][FamilyCannabis] += 50;
  439. SendClientMessage(capturedby, COLOR_LIGHTBLUE, "50 grams of Cannabis have been added to your family's safe.");
  440. Points[PDRUGSFACTORY][PointDrugs] = false;
  441. }
  442. case 1:
  443. {
  444. FamilyInfo[Points[PDRUGSFACTORY][PointFamily]][FamilyCocaine] += 50;
  445. SendClientMessage(capturedby, COLOR_LIGHTBLUE, "50 grams of Cocaine have been added to your family's safe.");
  446. Points[PDRUGSFACTORY][PointDrugs] = false;
  447. }
  448. case 2:
  449. {
  450. FamilyInfo[Points[PDRUGSFACTORY][PointFamily]][FamilyMeth] += 50;
  451. SendClientMessage(capturedby, COLOR_LIGHTBLUE, "50 grams of Meth have been added to your family's safe.");
  452. Points[PDRUGSFACTORY][PointDrugs] = false;
  453. }
  454. }
  455. }
  456. new capturedby = GetPlayerIDFromName(Points[p][PointOwner]);
  457. SendClientMessage(capturedby, COLOR_LIGHTBLUE, "Your family has received $50,000 for capturing the point.");
  458. FamilyInfo[PlayerInfo[capturedby][pFMember]][FamilyBank] += 50000;
  459. Points[p][PointEnabled] = false;
  460. GangZoneHideForAll(Points[p][PointBorder]);
  461. SavePoints();
  462. }
  463. }
  464. }
  465. }
  466. return 1;
  467. }
  468. CMD:capture(playerid, params[])
  469. {
  470. if(PlayerInfo[playerid][pFMember] == 255) return SendClientMessage(playerid, COLOR_GREY, "You are not a member of a family.");
  471. if(PlayerInfo[playerid][pRank] < 4) return SendClientMessage(playerid, COLOR_GREY, "Only R4+ can use this command.");
  472. if(pDeathState[playerid] == PLAYER_STATE_REVIVE) return SendClientMessage(playerid, COLOR_GREY, "You can not use this command while injured.");
  473. for(new p = 0; p < MAX_POINTS; p++)
  474. {
  475. if(IsPlayerInRangeOfPoint(playerid, 1, Points[p][PointPosition][0], Points[p][PointPosition][1], Points[p][PointPosition][2]))
  476. {
  477. if(Points[p][PointEnabled] == false) continue;
  478. if(Points[p][PointDeployed] == false) continue;
  479. format(teststr, sizeof(teststr), "You are attempting to capture the %s, please do not move for 10 seconds.", Points[p][PointName]);
  480. SendClientMessage(playerid, COLOR_RED, teststr);
  481. capturingpointtime[playerid] = 10;
  482. capturingpoint[playerid] = p;
  483. GetPlayerPos(playerid, capturingposition[playerid][0], capturingposition[playerid][1], capturingposition[playerid][2]);
  484. break;
  485. }
  486. }
  487. return 1;
  488. }
  489. CMD:points(playerid, params[])
  490. {
  491. new bigstr[3000], headers[] = "Point\tOwner (Family)\tTime\tStatus\n";
  492. new timemsg[60], capturedmsg[17];
  493. for(new p = 0; p < MAX_POINTS; p++)
  494. {
  495. if(Points[p][PointDeployed] == true)
  496. {
  497. new minutes, hours, family = Points[p][PointFamily];
  498. minutes = Points[p][PointTime]/60;
  499. hours = Points[p][PointTime]/3600;
  500. if(Points[p][PointTime] >= 3600) format(timemsg, sizeof(timemsg), "%d hours", hours);
  501. else format(timemsg, sizeof(timemsg), "%d minutes", minutes);
  502. if(Points[p][PointCaptureTime] != 0) format(capturedmsg, sizeof(capturedmsg), "BEING CAPTURED");
  503. else format(capturedmsg, sizeof(capturedmsg), "AVAILABLE");
  504. if(Points[p][PointTime] > 0) format(capturedmsg, sizeof(capturedmsg), "Not Ready");
  505. if(Points[p][PointFamily] == 255) format(bigstr, sizeof(bigstr), "{FFFFFF}%s%i. %s\tNone\t%s\t%s\n", bigstr, p, Points[p][PointName], timemsg, capturedmsg);
  506. else format(bigstr, sizeof(bigstr), "{FFFFFF}%s%i. %s\t%s (%s)\t%s\t%s\n", bigstr, p, Points[p][PointName], Points[p][PointOwner], FamilyInfo[family][FamilyName], timemsg, capturedmsg);
  507. }
  508. }
  509. format(bigstr, sizeof(bigstr), "%s%s", headers, bigstr);
  510. ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_TABLIST_HEADERS, "Points", bigstr, "Close", "");
  511. return 1;
  512. }
  513. CMD:editpoint(playerid, params[])
  514. {
  515. if(PlayerInfo[playerid][pAdmin] < 2 && PlayerInfo[playerid][pDev] < 2) return AdmErrorMsg;
  516. new pointid;
  517. if(sscanf(params, "i", pointid)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editpoint [pointid]");
  518. if(pointid < 0 || pointid > 14) return SendClientMessage(playerid, COLOR_GREY, "Enter a point id between 0-14.");
  519. if(Points[pointid][PointDeployed] == false) return SendClientMessage(playerid, COLOR_GREY, "That point is not created.");
  520. format(teststr, sizeof(teststr), "Editing Point %i", pointid);
  521. editingpoint[playerid] = pointid;
  522. new bigstr[1000];
  523. format(bigstr, sizeof(bigstr), "Name:\t %s\nPoint Time (hours):\t %d\nPoint Position\nDeath Message\nBorders",
  524. Points[pointid][PointName], Points[pointid][PointTime]/3600);
  525. ShowPlayerDialog(playerid, DIALOG_EDIT_POINT, DIALOG_STYLE_LIST, teststr, bigstr, "Edit", "Cancel");
  526. return 1;
  527. }
  528. CMD:gotopoint(playerid, params[])
  529. {
  530. if(PlayerInfo[playerid][pAdmin] < 2 && PlayerInfo[playerid][pDev] < 2) return AdmErrorMsg;
  531. new pointid;
  532. if(sscanf(params, "i", pointid)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /gotopoint [pointid]");
  533. if(pointid < 0 || pointid > 14) return SendClientMessage(playerid, COLOR_GREY, "Enter a point id between 0-14");
  534. if(Points[pointid][PointDeployed] == false) return SendClientMessage(playerid, COLOR_GREY, "That point is not created.");
  535. format(teststr, sizeof(teststr), "You have teleported to point ID %d", pointid);
  536. SendClientMessage(playerid, COLOR_GREY, teststr);
  537. SetPlayerPos(playerid, Points[pointid][PointPosition][0], Points[pointid][PointPosition][1], Points[pointid][PointPosition][2]);
  538. SetPlayerInterior(playerid, 0);
  539. return 1;
  540. }
  541. CMD:findpoint(playerid, params[])
  542. {
  543. new pointid;
  544. if(sscanf(params, "i", pointid)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /findpoint [pointid]");
  545. if(pointid < 0 || pointid > 14) return SendClientMessage(playerid, COLOR_GREY, "Enter a point ID between 0-14");
  546. if(Points[pointid][PointDeployed] == false) return SendClientMessage(playerid, COLOR_GREY, "That point is not created.");
  547. SetPlayerCheckpointEx(playerid, Points[pointid][PointPosition][0], Points[pointid][PointPosition][1], Points[pointid][PointPosition][2], 2.0);
  548. CP[playerid] = 35;
  549. format(teststr, sizeof(teststr), "A checkpoint to the %s point has been set on your minimap.", Points[pointid][PointName]);
  550. SendClientMessage(playerid, COLOR_GREY, teststr);
  551. return 1;
  552. }
  553. CMD:setpborders(playerid, params[])
  554. {
  555. if(PlayerInfo[playerid][pAdmin] < 2 && PlayerInfo[playerid][pDev] < 2) return AdmErrorMsg;
  556. new calc = borderseditcount[playerid] - 1;
  557. if(calc < 0) return SendClientMessage(playerid, COLOR_GREY, "You are not editing any border.");
  558. borderseditcount[playerid] --;
  559. new Float:tempposition[3];
  560. GetPlayerPos(playerid, tempposition[0], tempposition[1], tempposition[2]);
  561. if(borderseditcount[playerid] == 3)
  562. {
  563. bordersedit[playerid][0] = tempposition[0];
  564. SendClientMessage(playerid, COLOR_GREY, "Position 1/4");
  565. }
  566. else if(borderseditcount[playerid] == 2)
  567. {
  568. bordersedit[playerid][1] = tempposition[1];
  569. SendClientMessage(playerid, COLOR_GREY, "Position 2/4");
  570. }
  571. else if(borderseditcount[playerid] == 1)
  572. {
  573. bordersedit[playerid][2] = tempposition[0];
  574. SendClientMessage(playerid, COLOR_GREY, "Position 3/4");
  575. }
  576. else if(borderseditcount[playerid] == 0)
  577. {
  578. bordersedit[playerid][3] = tempposition[1];
  579. SendClientMessage(playerid, COLOR_GREY, "Position 4/4");
  580. new pointid = editingpoint[playerid];
  581. Points[pointid][PointBorders][0] = bordersedit[playerid][0];
  582. Points[pointid][PointBorders][1] = bordersedit[playerid][1];
  583. Points[pointid][PointBorders][2] = bordersedit[playerid][2];
  584. Points[pointid][PointBorders][3] = bordersedit[playerid][3];
  585. format(teststr, sizeof(teststr), "You have edited the %s point's borders (ID: %d), /pointborders to display it.", Points[pointid][PointName], pointid);
  586. SendClientMessage(playerid, COLOR_GREY, teststr);
  587. GangZoneDestroy(Points[pointid][PointBorder]);
  588. Points[pointid][PointBorder] = GangZoneCreate(bordersedit[playerid][0], bordersedit[playerid][1], bordersedit[playerid][2], bordersedit[playerid][3]);
  589. if(Points[pointid][PointEnabled])
  590. {
  591. GangZoneHideForAll(Points[pointid][PointBorder]);
  592. GangZoneShowForAll(Points[pointid][PointBorder], COLOR_RED);
  593. }
  594. }
  595. return 1;
  596. }
  597. CMD:pointborders(playerid, params[])
  598. {
  599. new pointid;
  600. if(sscanf(params, "i", pointid)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /pointborders [pointid]");
  601. if(!Points[pointid][PointDeployed]) return SendClientMessage(playerid, COLOR_GREY, "That point is not active.");
  602. if(viewingpointborders[playerid][pointid])
  603. {
  604. viewingpointborders[playerid][pointid] = false;
  605. GangZoneHideForPlayer(playerid, Points[pointid][PointBorder]);
  606. format(teststr, sizeof(teststr), "The %s point's borders no longer display for you.", Points[pointid][PointName]);
  607. SendClientMessage(playerid, COLOR_GREY, teststr);
  608. }
  609. else
  610. {
  611. viewingpointborders[playerid][pointid] = true;
  612. format(teststr, sizeof(teststr), "The %s point's borders now display for you.", Points[pointid][PointName]);
  613. SendClientMessage(playerid, COLOR_GREY, teststr);
  614. GangZoneShowForPlayer(playerid, Points[pointid][PointBorder], COLOR_RED);
  615. }
  616. return 1;
  617. }
  618. // Add/edit/delete/clear point rules in-game CREDITS TO JACOB
  619. new pointsSpam[MAX_PLAYERS];
  620. CMD:pointrules( playerid, params[] ) {
  621. if( pointsSpam[playerid] != 0 && gettime() < ( pointsSpam[playerid] + 3 ) ) {
  622. return SendClientMessage( playerid, COLOR_GREY, "Please wait 3 seconds before using this command again." );
  623. }
  624. pointsSpam[playerid] = gettime();
  625. mysql_pquery( sqlGameConnection, "SELECT * FROM pointsrules;", "fetchPointsInfo", "i", playerid );
  626. return 1;
  627. }
  628. forward fetchPointsInfo( playerid );
  629. public fetchPointsInfo( playerid ) {
  630. new verstr[4000], pointid, admin[MAX_PLAYER_NAME+1], text[128];
  631. for( new i; i < cache_get_row_count(); i++ ) {
  632. pointid = cache_get_field_content_int( i, "ID" );
  633. cache_get_field_content( i, "admin", admin, sqlGameConnection, 25 );
  634. cache_get_field_content( i, "text", text, sqlGameConnection, 128 );
  635. format( verstr, sizeof( verstr ), "%s{FFFFFF}%d.\t%s{c5c1b5} (%s)\n", verstr, pointid, text, admin );
  636. }
  637. if( strlen( verstr ) > 1 ) {
  638. ShowPlayerDialog( playerid, DIALOG_VERSION, DIALOG_STYLE_MSGBOX, "{FFC300}Current Point Rules {FFFFFF}", verstr, "Okay", "" );
  639. }
  640. return 1;
  641. }
  642. CMD:insertpointrule( playerid, params[] ) {
  643. if( PlayerInfo[playerid][pDev] < 2 && PlayerInfo[playerid][pAdmin] < 2){
  644. return 1;
  645. }
  646. new text[128];
  647. if( sscanf( params, "s[128]", text ) ) {
  648. return SendClientMessage( playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF}/insertpointrule [text]" );
  649. }
  650. insertPointRule( PlayerICName( playerid ), text, playerid );
  651. return 1;
  652. }
  653. insertPointRule( admin[], text[], playerid ) {
  654. new query[200];
  655. mysql_format( sqlGameConnection, query, sizeof( query ), "INSERT INTO pointsrules SET admin = '%e', text = '%e';", admin, text );
  656. mysql_pquery( sqlGameConnection, query );
  657. SendClientMessage( playerid, COLOR_GREY, "The point rule has been added to the rules list." );
  658. return 1;
  659. }
  660. CMD:deletepointrule( playerid, params[] ) {
  661. if( PlayerInfo[playerid][pDev] < 2 && PlayerInfo[playerid][pAdmin] < 2 ){
  662. return 1;
  663. }
  664. new pointid;
  665. if( sscanf( params, "i", pointid ) ) {
  666. return SendClientMessage( playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF}/deletepointrule [id]" );
  667. }
  668. deletePointRule( pointid, playerid );
  669. return 1;
  670. }
  671. deletePointRule( id, playerid ) {
  672. new query[200];
  673. mysql_format( sqlGameConnection, query, sizeof( query ), "DELETE FROM pointsrules WHERE ID = %d;", id );
  674. mysql_pquery( sqlGameConnection, query );
  675. SendClientMessage( playerid, COLOR_GREY, "The point rule has been deleted." );
  676. return 1;
  677. }
  678. CMD:updatepointrule( playerid, params[] ) {
  679. if( PlayerInfo[playerid][pDev] < 2 && PlayerInfo[playerid][pAdmin] < 2 ){
  680. return 1;
  681. }
  682. new pointid, text[128];
  683. if( sscanf( params, "is[128]", pointid, text ) ) {
  684. return SendClientMessage( playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF}/updatepointrule [id] [text]" );
  685. }
  686. updatePointRule( pointid, PlayerICName( playerid ), text, playerid );
  687. return 1;
  688. }
  689. updatePointRule( id, admin[], text[], playerid ) {
  690. new query[200];
  691. mysql_format( sqlGameConnection, query, sizeof( query ), "UPDATE pointsrules SET admin = '%e', text = '%e' WHERE ID = %d;", admin, text, id );
  692. mysql_pquery( sqlGameConnection, query );
  693. SendClientMessage( playerid, COLOR_GREY, "The point rule has been updated." );
  694. return 1;
  695. }
  696. CMD:clearpointrules( playerid, params[] ) {
  697. if( PlayerInfo[playerid][pDev] < 2 && PlayerInfo[playerid][pAdmin] < 2 ){
  698. return 1;
  699. }
  700. resetPointRule();
  701. SendClientMessage( playerid, COLOR_GREY, "The points rules have been cleared." );
  702. return 1;
  703. }
  704. resetPointRule() {
  705. mysql_pquery( sqlGameConnection, "TRUNCATE TABLE pointsrules;" );
  706. return 1;
  707. }