drugcore.pwn 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Drug System (Revision)
  11. by Winterfield
  12. Next Generation Gaming, LLC
  13. (created by Next Generation Gaming Development Team)
  14. * Copyright (c) 2016, Next Generation Gaming, LLC
  15. *
  16. * All rights reserved.
  17. *
  18. * Redistribution and use in source and binary forms, with or without modification,
  19. * are not permitted in any case.
  20. *
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  26. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  27. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  28. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  30. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  31. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <YSI\y_hooks>
  35. new dr_iPlayerTimeStamp[MAX_PLAYERS];
  36. CMD:odrughelp(playerid, params[])
  37. {
  38. SendClientMessageEx(playerid, COLOR_WHITE,"-----------------------------------------------------------------------------------");
  39. SendClientMessageEx(playerid, COLOR_GREY, "GENERAL: /mydrugs, /usedrug, /buypot, /buyopium, /plantpot, /plantopium, /pickplant, /checkplant /makeheroin");
  40. if(IsACop(playerid)) SendClientMessageEx(playerid, COLOR_GREY, "POLICE: /destroyplant, /searchcar");
  41. if(IsAdminLevel(playerid, ADMIN_JUNIOR, 0)) SendClientMessageEx(playerid, COLOR_GREY, "ADMINISTRATOR: /adestroyplant");
  42. SendClientMessageEx(playerid, COLOR_WHITE,"-----------------------------------------------------------------------------------");
  43. return 1;
  44. }
  45. CMD:mydrugs(playerid, params[])
  46. {
  47. new string[450];
  48. SendClientMessageEx(playerid, COLOR_WHITE,"-----------------------------------------------------------------------------------");
  49. for(new i; i < sizeof(Drugs); i++) format(string, sizeof(string),"%s | %s: %dg", string, Drugs[i], PlayerInfo[playerid][pDrugs][i]);
  50. format(string, sizeof(string),"%s | Pot Seeds: %d | Opium Seeds: %d | Syringes: %d |", string, PlayerInfo[playerid][pWSeeds], PlayerInfo[playerid][pOpiumSeeds], PlayerInfo[playerid][pSyringes]);
  51. SendClientMessageEx(playerid, COLOR_GREY, string);
  52. SendClientMessageEx(playerid, COLOR_WHITE,"-----------------------------------------------------------------------------------");
  53. return 1;
  54. }
  55. CMD:checkdrugs(playerid, params[])
  56. {
  57. if (PlayerInfo[playerid][pAdmin] >= 2)
  58. {
  59. new giveplayerid;
  60. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /checkdrugs [player]");
  61. if(IsPlayerConnected(giveplayerid))
  62. {
  63. new string[450];
  64. SendClientMessageEx(playerid, COLOR_WHITE,"-----------------------------------------------------------------------------------");
  65. for(new i; i < sizeof(Drugs); i++) format(string, sizeof(string),"%s | %s: %dg", string, Drugs[i], PlayerInfo[giveplayerid][pDrugs][i]);
  66. format(string, sizeof(string),"%s | Pot Seeds: %d | Opium Seeds: %d | Syringes: %d |", string, PlayerInfo[giveplayerid][pWSeeds], PlayerInfo[giveplayerid][pOpiumSeeds], PlayerInfo[giveplayerid][pSyringes]);
  67. SendClientMessageEx(playerid, COLOR_GREY, string);
  68. SendClientMessageEx(playerid, COLOR_WHITE,"-----------------------------------------------------------------------------------");
  69. }
  70. else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
  71. }
  72. else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use this command.");
  73. return 1;
  74. }
  75. CMD:usedrug(playerid, params[])
  76. {
  77. if(GetPVarInt(playerid, "pDrugTime") > gettime()) return SendClientMessageEx(playerid, COLOR_GRAD1, "You must wait 60 seconds before using drugs again.");
  78. if(GetPVarType(playerid, "WatchingTV") || GetPVarType(playerid, "PreviewingTV")) return SendClientMessage(playerid, COLOR_GRAD1, "You cannot use drugs while watching TV.");
  79. if(HungerPlayerInfo[playerid][hgInEvent] != 0) return SendClientMessageEx(playerid, COLOR_GREY, " You cannot do this while being in the Hunger Games Event!");
  80. #if defined zombiemode
  81. if(zombieevent == 1 && GetPVarType(playerid, "pIsZombie")) return SendClientMessageEx(playerid, COLOR_GREY, "Zombies can't use this.");
  82. #endif
  83. if(GetPVarType(playerid, "PlayerCuffed") || GetPVarInt(playerid, "pBagged") >= 1 || GetPVarType(playerid, "IsFrozen") || PlayerInfo[playerid][pHospital] || (PlayerInfo[playerid][pJailTime] > 0 && strfind(PlayerInfo[playerid][pPrisonReason], "[OOC]", true) != -1))
  84. return SendClientMessage(playerid, COLOR_GRAD2, "You can't do that at this time!");
  85. if(GetPVarType(playerid, "AttemptingLockPick")) return SendClientMessageEx(playerid, COLOR_WHITE, "You are attempting to lockpick, please wait.");
  86. if(GetPVarType(playerid, "IsInArena")) return SendClientMessageEx(playerid, COLOR_WHITE, "You can't do this while being in an arena!");
  87. if(PlayerBoxing[playerid] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use drugs while you're fighting.");
  88. if(UsedCrack[playerid] == 1) return SendClientMessageEx(playerid, COLOR_WHITE, "You must wait 5 seconds before using more drugs.");
  89. if(PlayerInfo[playerid][pHospital]) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot do this at this time.");
  90. new drugstring[16], amount;
  91. if(sscanf(params, "s[16]d", drugstring, amount))
  92. {
  93. SendClientMessageEx(playerid, COLOR_GRAD1, "USAGE: /usedrug [drug name] [amount]");
  94. ListDrugs(playerid);
  95. return 1;
  96. }
  97. if(amount < 1 || amount > 20) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot take that.");
  98. new drug = GetDrugID(drugstring);
  99. if(drug == -1)
  100. {
  101. SendClientMessageEx(playerid, COLOR_GRAD1, "USAGE: /usedrug [drug name] [amount]");
  102. ListDrugs(playerid);
  103. return 1;
  104. }
  105. if(PlayerInfo[playerid][pDrugs][drug] < amount) return SendClientMessageEx(playerid, COLOR_GRAD1, "You do not have that many drugs.");
  106. if(drug == 4 && amount != 10) return SendClientMessageEx(playerid, COLOR_GRAD1, "You must take only 10 heroin at a time.");
  107. if(drug == 4 && PlayerInfo[playerid][pSyringes] <= 0) return SendClientMessageEx(playerid, COLOR_GRAD1, "You need a syringe. Craft one or buy one from a craftsman.");
  108. if(drug != 4 && dr_iPlayerTimeStamp[playerid] > gettime() - 60) return SendClientMessageEx(playerid, COLOR_GRAD1, "You have been injured in the last minute");
  109. if(drug != 4 && GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot do this right now.");
  110. if(!IsPlayerInAnyVehicle(playerid) && drug != 4) ApplyAnimation(playerid,"SMOKING","M_smkstnd_loop",2.1,0,0,0,0,0);
  111. PlayerInfo[playerid][pDrugs][drug] -= amount;
  112. SetPVarInt(playerid, "pDrugTime", gettime() + 60);
  113. GivePlayerDrugEffects(playerid, drug, amount);
  114. return 1;
  115. }
  116. CMD:buypot(playerid, params[])
  117. {
  118. new string[256];
  119. if(PlayerInfo[playerid][pJob] != 14 && PlayerInfo[playerid][pJob2] != 14 && PlayerInfo[playerid][pJob3] != 14) return SendClientMessageEx(playerid,COLOR_GREY," You are not a drug smuggler!");
  120. for (new i=0; i<MAX_POINTS; i++)
  121. {
  122. if(IsPlayerInRangeOfPoint(playerid, 3.0, DynPoints[i][poPos][0], DynPoints[i][poPos][1], DynPoints[i][poPos][2]) && DynPoints[i][poType] == 1)
  123. {
  124. if(GetPlayerMoney(playerid) < 10000) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot afford the $10,000!");
  125. GivePlayerCashEx(playerid, TYPE_ONHAND, -10000);
  126. PlayerInfo[playerid][pWSeeds] += 1;
  127. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You have purchased a bag of pot seeds from the drug house.");
  128. format(string, sizeof(string), "* %s has purchased some pot seeds.", GetPlayerNameEx(playerid));
  129. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  130. }
  131. }
  132. return 1;
  133. }
  134. CMD:buyopium(playerid, params[])
  135. {
  136. new string[256];
  137. if(PlayerInfo[playerid][pJob] != 14 && PlayerInfo[playerid][pJob2] != 14 && PlayerInfo[playerid][pJob3] != 14) return SendClientMessageEx(playerid,COLOR_GREY," You are not a drug smuggler!");
  138. if(GetPlayerMoney(playerid) < 100000) return SendClientMessageEx(playerid,COLOR_GREY," You can't afford to buy Opium");
  139. for (new i=0; i<MAX_POINTS; i++)
  140. {
  141. if(IsPlayerInRangeOfPoint(playerid, 5.0, DynPoints[i][poPos][0], DynPoints[i][poPos][1], DynPoints[i][poPos][2]) && DynPoints[i][poType] == 2)
  142. {
  143. if(GetPlayerMoney(playerid) < 100000) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot afford the $100,000!");
  144. GivePlayerCashEx(playerid, TYPE_ONHAND, -100000);
  145. PlayerInfo[playerid][pOpiumSeeds] += 1;
  146. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You have purchased a bag of opium seeds from the drug house.");
  147. format(string, sizeof(string), "* %s has purchased some opium seeds.", GetPlayerNameEx(playerid));
  148. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  149. }
  150. }
  151. return 1;
  152. }
  153. forward DrugEffectTime(playerid);
  154. public DrugEffectTime(playerid)
  155. {
  156. SyncPlayerTime(playerid);
  157. SetPlayerDrunkLevel(playerid, 0);
  158. SetPlayerWeather(playerid, gWeather);
  159. SendClientMessageEx(playerid, COLOR_GRAD1, "Your side affects have worn off.");
  160. return 1;
  161. }
  162. hook OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
  163. {
  164. dr_iPlayerTimeStamp[playerid] = gettime();
  165. }
  166. GivePlayerDrugEffects(playerid, id, amount)
  167. {
  168. new Float:health, Float:armour, string[256];
  169. GetHealth(playerid, health);
  170. GetArmour(playerid, armour);
  171. switch(id)
  172. {
  173. case 0: // Pot
  174. {
  175. new Float:increase = amount * 2;
  176. SetHealth(playerid, health + increase);
  177. if(health + increase > 100) SetHealth(playerid, 100);
  178. format(string, sizeof(string), "* %s has used some pot.", GetPlayerNameEx(playerid));
  179. ProxDetector(25.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  180. }
  181. case 1: // Crack
  182. {
  183. new Float:increase = amount * 2;
  184. SetArmour(playerid, armour + increase);
  185. if(armour + increase > 100) SetArmour(playerid, 100);
  186. format(string, sizeof(string), "* %s has used some crack.", GetPlayerNameEx(playerid));
  187. ProxDetector(25.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  188. }
  189. case 2: // Meth
  190. {
  191. new Float:increase = amount * 4;
  192. if(armour < 100 && amount == 20) SetArmour(playerid, 100);
  193. SetHealth(playerid, armour + increase);
  194. if(health + increase > 150) SetHealth(playerid, 150);
  195. format(string, sizeof(string), "* %s has used some meth.", GetPlayerNameEx(playerid));
  196. ProxDetector(25.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  197. }
  198. case 3: // Ecstasy
  199. {
  200. new Float:increase = amount * 5;
  201. SetHealth(playerid, health + increase);
  202. SetArmour(playerid, armour + increase);
  203. if(health + increase > 150) SetHealth(playerid, 150);
  204. if(armour + increase > 150) SetArmour(playerid, 150);
  205. format(string, sizeof(string), "* %s has used some ecstasy.", GetPlayerNameEx(playerid));
  206. ProxDetector(25.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  207. }
  208. case 4: // Heroin
  209. {
  210. if(GetPVarInt(playerid, "Injured") != 1)
  211. {
  212. SetPVarInt(playerid, "HeroinLastUsed", gettime());
  213. PlayerInfo[playerid][pSyringes] -= 1;
  214. SetPVarInt(playerid, "InjectHeroinStanding", SetTimerEx("InjectHeroinStanding", 5000, 0, "i", playerid));
  215. if(!IsPlayerInAnyVehicle(playerid)) ApplyAnimation(playerid,"SMOKING","M_smkstnd_loop",2.1,0,0,0,0,0);
  216. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You have injected heroin into yourself, the effects will begin in 5 seconds.");
  217. format(string, sizeof(string), "* %s injects heroin into themself.", GetPlayerNameEx(playerid));
  218. ProxDetector(25.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  219. return 1;
  220. }
  221. SetPVarInt(playerid, "HeroinLastUsed", gettime());
  222. PlayerInfo[playerid][pSyringes] -= 1;
  223. SetPVarInt(playerid, "Health", 30);
  224. SetPVarInt(playerid, "InjectHeroin", SetTimerEx("InjectHeroin", 5000, 0, "i", playerid));
  225. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You have injected heroin into yourself, the effects will begin in 5 seconds.");
  226. format(string, sizeof(string), "* %s injects heroin into themself.", GetPlayerNameEx(playerid));
  227. ProxDetector(25.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  228. }
  229. }
  230. if(id != 4) GivePlayerDrugSideEffect(playerid, id, amount);
  231. return 1;
  232. }
  233. forward InjectHeroin(playerid);
  234. public InjectHeroin(playerid)
  235. {
  236. KillEMSQueue(playerid);
  237. ClearAnimationsEx(playerid);
  238. SetHealth(playerid, 30);
  239. SetPVarInt(playerid, "HeroinEffect", SetTimerEx("HeroinEffect", 1000, 1, "i", playerid));
  240. SendClientMessageEx(playerid, COLOR_GREEN, "The effects of the heroin have started.");
  241. return 1;
  242. }
  243. forward HeroinEffectStanding(playerid);
  244. public HeroinEffectStanding(playerid)
  245. {
  246. SetPVarInt(playerid, "HeroinDamageResist", 0);
  247. SendClientMessageEx(playerid, COLOR_GREEN, "The effects of the heroin have worn off.");
  248. return 1;
  249. }
  250. forward HeroinEffect(playerid);
  251. public HeroinEffect(playerid)
  252. {
  253. if(GetPVarInt(playerid, "Health") != 0)
  254. {
  255. SetPVarInt(playerid, "Health", GetPVarInt(playerid, "Health")-1);
  256. SetHealth(playerid, GetPVarInt(playerid, "Health"));
  257. }
  258. else
  259. {
  260. KillTimer(GetPVarInt(playerid, "HeroinEffect"));
  261. DeletePVar(playerid, "HeroinEffect");
  262. }
  263. return 1;
  264. }
  265. forward InjectHeroinStanding(playerid);
  266. public InjectHeroinStanding(playerid)
  267. {
  268. SetPVarInt(playerid, "HeroinDamageResist", 1);
  269. SendClientMessageEx(playerid, COLOR_GREEN, "The effects of the heroin have started.");
  270. SetPVarInt(playerid, "HeroinEffectStanding", SetTimerEx("HeroinEffectStanding", 30000, 0, "i", playerid));
  271. return 1;
  272. }
  273. GivePlayerDrugSideEffect(playerid, id, amount)
  274. {
  275. switch(id)
  276. {
  277. case 0:
  278. {
  279. SetPlayerDrunkLevel(playerid, 50000);
  280. SetPlayerWeather(playerid, 9);
  281. SetPlayerTime(playerid, 0, 0);
  282. }
  283. case 1:
  284. {
  285. SetPlayerDrunkLevel(playerid, 50000);
  286. SetPlayerWeather(playerid, 19);
  287. SetPlayerTime(playerid, 0, 0);
  288. }
  289. case 2:
  290. {
  291. SetPlayerDrunkLevel(playerid, 50000);
  292. SetPlayerWeather(playerid, 111);
  293. SetPlayerTime(playerid, 0, 0);
  294. }
  295. case 3:
  296. {
  297. SetPlayerDrunkLevel(playerid, 50000);
  298. SetPlayerWeather(playerid, 700);
  299. SetPlayerTime(playerid, 0, 0);
  300. }
  301. default: return 1;
  302. }
  303. switch(amount)
  304. {
  305. case 1 .. 2: SetTimerEx("DrugEffectTime", 10000, false, "i", playerid);
  306. case 3 .. 7: SetTimerEx("DrugEffectTime", 15000, false, "i", playerid);
  307. case 8 .. 12: SetTimerEx("DrugEffectTime", 20000, false, "i", playerid);
  308. case 13 .. 16: SetTimerEx("DrugEffectTime", 25000, false, "i", playerid);
  309. case 17 .. 20: SetTimerEx("DrugEffectTime", 30000, false, "i", playerid);
  310. default: SetTimerEx("DrugEffectTime", 30000, false, "i", playerid);
  311. }
  312. return 1;
  313. }
  314. GetDrugName(id)
  315. {
  316. switch(id)
  317. {
  318. case 0: szMiscArray = "Pot";
  319. case 1: szMiscArray = "Crack";
  320. case 2: szMiscArray = "Meth";
  321. case 3: szMiscArray = "Ecstasy";
  322. case 4: szMiscArray = "Heroin";
  323. }
  324. return szMiscArray;
  325. }
  326. ListDrugs(playerid)
  327. {
  328. szMiscArray[0] = 0;
  329. for(new i; i < sizeof(Drugs); ++i)
  330. {
  331. format(szMiscArray, sizeof(szMiscArray),"%s | %s | %s | %s | %s", Drugs[0], Drugs[1], Drugs[2], Drugs[3], Drugs[4]);
  332. }
  333. SendClientMessageEx(playerid, COLOR_GRAD1, szMiscArray);
  334. }
  335. GetDrugID(Drug[])
  336. {
  337. for(new i; i < sizeof(Drugs); ++i) {
  338. if(strcmp(Drugs[i], Drug, true) == 0) return i;
  339. }
  340. return -1;
  341. }
  342. IncreaseSmugglerLevel(playerid)
  343. {
  344. if(PlayerInfo[playerid][pDoubleEXP] > 0)
  345. {
  346. PlayerInfo[playerid][pDrugSmuggler] += 2;
  347. // PlayerInfo[playerid][pXP] += PlayerInfo[playerid][pLevel] * XP_RATE * 2;
  348. }
  349. else
  350. {
  351. PlayerInfo[playerid][pDrugSmuggler] += 1;
  352. // PlayerInfo[playerid][pXP] += PlayerInfo[playerid][pLevel] * XP_RATE;
  353. }
  354. return 1;
  355. }
  356. Smuggle_VehicleLoad(playerid, iTargetID, iVehID)
  357. {
  358. new iTotalAmount;
  359. szMiscArray = "Ingredient\tAmount in vehicle\n";
  360. if(iTotalAmount == 0) {
  361. szMiscArray[0] = 0;
  362. szMiscArray = "Drugs\tAmount in vehicle\n";
  363. for(new i; i < sizeof(Drugs); ++i) {
  364. if(PlayerVehicleInfo[iTargetID][iVehID][pvDrugs][i] > 0) {
  365. format(szMiscArray, sizeof(szMiscArray), "%s%s\t%d\n", szMiscArray, Drugs[i], PlayerVehicleInfo[iTargetID][iVehID][pvDrugs][i]);
  366. iTotalAmount += PlayerVehicleInfo[iTargetID][iVehID][pvDrugs][i];
  367. }
  368. }
  369. if(iTotalAmount == 0) return SendClientMessageEx(playerid, COLOR_GRAD1, "There are no drugs in this vehicle.");
  370. }
  371. ShowPlayerDialogEx(playerid, DIALOG_NOTHING, DIALOG_STYLE_TABLIST_HEADERS, "Vehicle | Drug Packages", szMiscArray, "Select", "");
  372. format(szMiscArray, sizeof(szMiscArray), "_________ %s | Drugs Stored _________", GetVehicleName(iVehID));
  373. SendClientMessageEx(playerid, COLOR_GREEN, szMiscArray);
  374. format(szMiscArray, sizeof(szMiscArray), "Total amount: %d pieces.", iTotalAmount);
  375. SendClientMessageEx(playerid, COLOR_GRAD1, szMiscArray);
  376. SendClientMessageEx(playerid, COLOR_GREEN, "_______________________________________________");
  377. return 1;
  378. }
  379. Character_Actor(playerid, choice)
  380. {
  381. switch(choice) {
  382. case 0: {
  383. PlayerInfo[playerid][pModel] = GetPlayerSkin(playerid);
  384. new Float:fPos[4],
  385. iVW = GetPlayerVirtualWorld(playerid),
  386. iActorID,
  387. Float:fHealth;
  388. GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);
  389. GetPlayerFacingAngle(playerid, fPos[3]);
  390. GetHealth(playerid, fHealth);
  391. iActorID = CreateActor(PlayerInfo[playerid][pModel], fPos[0], fPos[1], fPos[2], fPos[3]);
  392. SetActorVirtualWorld(iActorID, iVW);
  393. SetActorInvulnerable(iActorID, false);
  394. SetActorHealth(iActorID, fHealth);
  395. SetPVarInt(playerid, PVAR_TEMPACTOR, iActorID);
  396. format(szMiscArray, sizeof(szMiscArray), "%s (%d)", GetPlayerNameEx(playerid), playerid);
  397. SetPVarInt(playerid, PVAR_TEMPTEXT, _:CreateDynamic3DTextLabel(szMiscArray, COLOR_WHITE, fPos[0], fPos[1], fPos[2] + 1.0, 5.0, .worldid = iVW));
  398. }
  399. case 1: {
  400. DestroyActor(GetPVarInt(playerid, PVAR_TEMPACTOR));
  401. #if defined TEXTLABEL_DEBUG
  402. Streamer_SetIntData(STREAMER_TYPE_3D_TEXT_LABEL, Text3D:GetPVarInt(playerid, PVAR_TEMPTEXT), E_STREAMER_EXTRA_ID, 6);
  403. #endif
  404. DestroyDynamic3DTextLabel(Text3D:GetPVarInt(playerid, PVAR_TEMPTEXT));
  405. DeletePVar(playerid, PVAR_TEMPACTOR);
  406. DeletePVar(playerid, PVAR_TEMPTEXT);
  407. }
  408. }
  409. }
  410. // PLANT SYSTEM //
  411. stock LoadPlants() {
  412. printf("[LoadPlants] Loading data from database...");
  413. mysql_tquery(MainPipeline, "SELECT * FROM `plants`", "PlantsLoadQuery", "");
  414. }
  415. forward PlantsLoadQuery();
  416. public PlantsLoadQuery() {
  417. new
  418. iRows,
  419. iIndex;
  420. cache_get_row_count(iRows);
  421. while((iIndex < iRows))
  422. {
  423. cache_get_value_name_int(iIndex, "Owner", Plants[iIndex][pOwner]);
  424. cache_get_value_name_int(iIndex, "Object", Plants[iIndex][pObject]);
  425. cache_get_value_name_int(iIndex, "PlantType", Plants[iIndex][pPlantType]);
  426. cache_get_value_name_float(iIndex, "PositionX", Plants[iIndex][pPos][0]);
  427. cache_get_value_name_float(iIndex, "PositionY", Plants[iIndex][pPos][1]);
  428. cache_get_value_name_float(iIndex, "PositionZ", Plants[iIndex][pPos][2]);
  429. cache_get_value_name_int(iIndex, "Virtual", Plants[iIndex][pVirtual]);
  430. cache_get_value_name_int(iIndex, "Interior", Plants[iIndex][pInterior]);
  431. cache_get_value_name_int(iIndex, "Growth", Plants[iIndex][pGrowth]);
  432. cache_get_value_name_int(iIndex, "Expires", Plants[iIndex][pExpires]);
  433. cache_get_value_name_int(iIndex, "DrugsSkill", Plants[iIndex][pDrugsSkill]);
  434. if(Plants[iIndex][pOwner] != 0)
  435. {
  436. Plants[iIndex][pObjectSpawned] = CreateDynamicObject(Plants[iIndex][pObject], Plants[iIndex][pPos][0], Plants[iIndex][pPos][1], Plants[iIndex][pPos][2], 0.0, 0.0, 0.0, Plants[iIndex][pVirtual], Plants[iIndex][pInterior]);
  437. }
  438. iIndex++;
  439. }
  440. if(iIndex > 0) printf("[LoadPlants] Successfully loaded %d plants", iIndex);
  441. else printf("[LoadPlants] Error: Failed to load any plants!");
  442. return 1;
  443. }
  444. stock SavePlant(plant)
  445. {
  446. new query[300];
  447. mysql_format(MainPipeline, query, sizeof(query), "UPDATE `plants` SET `Owner` = %d, `Object` = %d, `PlantType` = %d, `PositionX` = %f, `PositionY` = %f, `PositionZ` = %f, `Virtual` = %d, \
  448. `Interior` = %d, `Growth` = %d, `Expires` = %d, `DrugsSkill` = %d WHERE `PlantID` = %d",Plants[plant][pOwner], Plants[plant][pObject], Plants[plant][pPlantType], Plants[plant][pPos][0], Plants[plant][pPos][1], Plants[plant][pPos][2],
  449. Plants[plant][pVirtual], Plants[plant][pInterior], Plants[plant][pGrowth], Plants[plant][pExpires], Plants[plant][pDrugsSkill], plant+1);
  450. mysql_tquery(MainPipeline, query, "OnQueryFinish", "i", SENDDATA_THREAD);
  451. return 1;
  452. }
  453. stock SavePlants()
  454. {
  455. new i = 0;
  456. while(i < MAX_PLANTS)
  457. {
  458. SavePlant(i);
  459. i++;
  460. }
  461. if(i > 0) printf("[plant] %i plants saved", i);
  462. else printf("[plant] Error: No plants saved!");
  463. return 1;
  464. }
  465. CMD:makeheroin(playerid, params[])
  466. {
  467. if(!IsPlayerInRangeOfPoint(playerid, 15.0, -882.2048,1109.3385,5442.8193))
  468. return SendClientMessageEx(playerid, COLOR_GREY, "You are not at the purification lab.");
  469. if(PlayerInfo[playerid][pRawOpium] == 0)
  470. return SendClientMessageEx(playerid, COLOR_GREY, "You don't have any raw opium to purify.");
  471. if(Purification[0] == 1)
  472. return SendClientMessageEx(playerid, COLOR_GREY, "Only one player may attempt to purify their opium at a time.");
  473. new szMessage[128];
  474. SendClientMessageEx(playerid, COLOR_GREEN, "You must wait 30 seconds, for purification to be complete.");
  475. format(szMessage, sizeof(szMessage), "* %s begins the purification process.", GetPlayerNameEx(playerid));
  476. ProxDetector(25.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  477. Purification[0] = 1;
  478. SetPVarInt(playerid, "AttemptPurify", SetTimerEx("AttemptPurify", 1000, 1, "i", playerid));
  479. return 1;
  480. }
  481. CMD:plantopium(playerid, params[])
  482. {
  483. if(PlayerInfo[playerid][pOpiumSeeds] > 0)
  484. {
  485. if(PlayerInfo[playerid][pWeedObject] > 0)
  486. {
  487. SendClientMessageEx(playerid, COLOR_GRAD2, "You already have a plant growing." );
  488. return 1;
  489. }
  490. if(GetPlayerInterior(playerid) == 0) return SendClientMessageEx(playerid, COLOR_GRAD1, " You need to be inside an inteiror!");
  491. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot plant seeds while inside a vehicle!");
  492. for(new i = 0; i < MAX_PLANTS; ++i)
  493. {
  494. if(Plants[i][pObject] == 0)
  495. {
  496. new
  497. szMessage[48],
  498. Float:xyz[3];
  499. ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
  500. SendClientMessageEx(playerid, COLOR_GREEN, "You have planted some opium. It will take around 2 hours to grow.");
  501. GetPlayerPos(playerid, xyz[0], xyz[1], xyz[2]);
  502. xyz[2] -= 1.0;
  503. PlayerInfo[playerid][pOpiumSeeds]--;
  504. PlayerInfo[playerid][pWeedObject] = 1;
  505. PlacePlant(i, GetPlayerSQLId(playerid), 2, 859, PlayerInfo[playerid][pDrugSmuggler], xyz[0], xyz[1], xyz[2], GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
  506. SavePlant(i);
  507. new string[128];
  508. format(string, sizeof(string), "%s(%d) (IP:%s) has placed opium plant (%d)", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), i);
  509. Log("logs/plant.log", string);
  510. format(szMessage, sizeof(szMessage), "* %s plants some opium.", GetPlayerNameEx(playerid));
  511. ProxDetector(25.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  512. return 1;
  513. }
  514. }
  515. SendClientMessageEx(playerid, COLOR_GREY, "The server has reached the max number of plants. Try again later!");
  516. }
  517. else SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough seeds to plant opium - head to the crack house and pick up some seeds (/buyopium).");
  518. return 1;
  519. }
  520. CMD:plantpot(playerid, params[])
  521. {
  522. if(PlayerInfo[playerid][pWSeeds] > 0)
  523. {
  524. if(PlayerInfo[playerid][pWeedObject] > 0)
  525. {
  526. SendClientMessageEx(playerid, COLOR_GRAD2, "You already have a plant growing." );
  527. return 1;
  528. }
  529. if(GetPlayerInterior(playerid) == 0) return SendClientMessageEx(playerid, COLOR_GRAD1, " You need to be inside an inteiror!");
  530. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot plant seeds while inside a vehicle!");
  531. for(new i = 0; i < MAX_PLANTS; ++i)
  532. {
  533. if(Plants[i][pObject] == 0)
  534. {
  535. new
  536. szMessage[48],
  537. Float: xyz[3];
  538. ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
  539. SendClientMessageEx(playerid, COLOR_GREEN, "You have planted some weed. It will take around 20-45 minutes to grow.");
  540. GetPlayerPos(playerid, xyz[0], xyz[1], xyz[2]);
  541. xyz[2] -= 1.5;
  542. Plants[i][pDrugsSkill] = PlayerInfo[playerid][pDrugSmuggler];
  543. PlayerInfo[playerid][pWeedObject] = 1;
  544. PlayerInfo[playerid][pWSeeds]--;
  545. PlacePlant(i, GetPlayerSQLId(playerid), 1, 19473, PlayerInfo[playerid][pDrugSmuggler], xyz[0], xyz[1], xyz[2], GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
  546. SavePlant(i);
  547. new string[128];
  548. format(string, sizeof(string), "%s(%d) (IP:%s) has placed weed plant (%d)", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), i);
  549. Log("logs/plant.log", string);
  550. format(szMessage, sizeof(szMessage), "* %s plants some weed.", GetPlayerNameEx(playerid));
  551. ProxDetector(25.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  552. return 1;
  553. }
  554. }
  555. SendClientMessageEx(playerid, COLOR_GREY, "The server has reached the max number of plants.");
  556. }
  557. else SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough seeds to plant weed - head to the drug house and pick up some seeds (/buypot).");
  558. return 1;
  559. }
  560. CMD:adestroyplant(playerid, params[])
  561. {
  562. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1) {
  563. new
  564. iTargetID;
  565. if(sscanf(params, "u", iTargetID)) {
  566. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /adestroyplant [player]");
  567. }
  568. else if(IsPlayerConnected(iTargetID)) {
  569. for(new i = 0; i < MAX_PLANTS; ++i)
  570. {
  571. if(Plants[i][pOwner] == GetPlayerSQLId(iTargetID))
  572. {
  573. new
  574. szMessage[47 + MAX_PLAYER_NAME];
  575. foreach(new z : Player)
  576. {
  577. if(Plants[i][pOwner] == GetPlayerSQLId(z))
  578. {
  579. PlayerInfo[z][pWeedObject] = 0;
  580. }
  581. }
  582. format(szMessage, sizeof(szMessage), "You have destroyed %s's plant.", GetPlayerNameEx(iTargetID), Plants[i][pGrowth]);
  583. SendClientMessageEx(playerid, COLOR_GREY, szMessage);
  584. format(szMessage, sizeof(szMessage), "Administrator %s has destroyed your plant.", GetPlayerNameEx(playerid), Plants[i][pGrowth]);
  585. SendClientMessageEx(iTargetID, COLOR_GREY, szMessage);
  586. new string[128];
  587. format(string, sizeof(string), "%s (IP:%s) has destroyed %s(%d) (IP:%s) plant (%d)", GetPlayerNameEx(playerid), GetPlayerIpEx(playerid), GetPlayerNameEx(iTargetID), GetPlayerSQLId(iTargetID), GetPlayerIpEx(iTargetID), i);
  588. Log("logs/plant.log", string);
  589. PlayerInfo[iTargetID][pWeedObject] = 0;
  590. DestroyPlant(i);
  591. SavePlant(i);
  592. return 1;
  593. }
  594. }
  595. }
  596. else SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
  597. }
  598. else SendClientMessageEx(playerid, COLOR_GREY, "You're not authorized to use this command.");
  599. return 1;
  600. }
  601. CMD:destroyplant(playerid, params[])
  602. {
  603. if(IsACop(playerid) || IsAMedic(playerid))
  604. {
  605. for(new i = 0; i < MAX_PLANTS; ++i)
  606. {
  607. if(IsValidDynamicObject(Plants[i][pObjectSpawned]) && IsPlayerInRangeOfPoint(playerid, 2.5, Plants[i][pPos][0], Plants[i][pPos][1], Plants[i][pPos][2]))
  608. {
  609. if(GetPlayerVirtualWorld(playerid) == Plants[i][pVirtual] && GetPlayerInterior(playerid) == Plants[i][pInterior]) {
  610. new
  611. szMessage[128];
  612. ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_Out", 4.0, 0, 0, 0, 0, 0, 1);
  613. switch(Plants[i][pPlantType]) {
  614. case 1:
  615. {
  616. format(szMessage, sizeof(szMessage), "* You seized a marijuana plant weighing %d grams.", Plants[i][pGrowth]);
  617. SendClientMessageEx(playerid, COLOR_GREY, szMessage);
  618. format(szMessage, sizeof(szMessage), "* %s seizes the weed plant.", GetPlayerNameEx(playerid), GetPlayerNameEx(i));
  619. ProxDetector(25.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  620. foreach(new z : Player)
  621. {
  622. if(Plants[i][pOwner] == GetPlayerSQLId(z))
  623. {
  624. PlayerInfo[z][pWeedObject] = 0;
  625. }
  626. }
  627. format(szMessage, sizeof(szMessage), "%s(%d) (IP:%s) has destroyed weed plant (%d)", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), i);
  628. Log("logs/plant.log", szMessage);
  629. DestroyPlant(i);
  630. SavePlant(i);
  631. return 1;
  632. }
  633. case 2:
  634. {
  635. new Grams = Random(10, 30);
  636. format(szMessage, sizeof(szMessage), "* You seized a opium plant weighing %d milligrams.", Grams);
  637. SendClientMessageEx(playerid, COLOR_GREY, szMessage);
  638. format(szMessage, sizeof(szMessage), "* %s seizes the opium plant.", GetPlayerNameEx(playerid), GetPlayerNameEx(i));
  639. ProxDetector(25.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  640. foreach(new z : Player)
  641. {
  642. if(Plants[i][pOwner] == GetPlayerSQLId(z))
  643. {
  644. PlayerInfo[z][pWeedObject] = 0;
  645. }
  646. }
  647. format(szMessage, sizeof(szMessage), "%s(%d) (IP:%s) has destroyed opium plant (%d)", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), i);
  648. Log("logs/plant.log", szMessage);
  649. DestroyPlant(i);
  650. SavePlant(i);
  651. return 1;
  652. }
  653. }
  654. }
  655. }
  656. }
  657. SendClientMessageEx(playerid, COLOR_GREY, "You are not at a plant.");
  658. }
  659. else
  660. {
  661. SendClientMessageEx(playerid, COLOR_GREY, "You're not a law enforcement officer.");
  662. }
  663. return 1;
  664. }
  665. CMD:checkplant(playerid, params[])
  666. {
  667. for(new i = 0; i < MAX_PLANTS; ++i)
  668. {
  669. if(IsValidDynamicObject(Plants[i][pObjectSpawned]) && IsPlayerInRangeOfPoint(playerid, 2.5, Plants[i][pPos][0], Plants[i][pPos][1], Plants[i][pPos][2]))
  670. {
  671. if(GetPlayerVirtualWorld(playerid) == Plants[i][pVirtual] && GetPlayerInterior(playerid) == Plants[i][pInterior])
  672. {
  673. switch(Plants[i][pPlantType])
  674. {
  675. case 1:
  676. {
  677. if(Plants[i][pGrowth] > 10)
  678. {
  679. new
  680. szMessage[66 + MAX_PLAYER_NAME];
  681. format(szMessage, sizeof(szMessage), "Your plant currently carries %i grams - use /pickplant to claim it.", Plants[i][pGrowth]);
  682. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  683. return 1;
  684. }
  685. else SendClientMessageEx(playerid, COLOR_YELLOW, "This plant isn't ready to be picked yet.");
  686. return 1;
  687. }
  688. case 2:
  689. {
  690. if(Plants[i][pGrowth] >= 120)
  691. {
  692. SendClientMessageEx(playerid, COLOR_WHITE, "Your plant is currently ready to be harvested - use /pickplant to claim it.");
  693. return 1;
  694. }
  695. else SendClientMessageEx(playerid, COLOR_WHITE, "Your opium plant still needs more time to grow.");
  696. return 1;
  697. }
  698. }
  699. }
  700. }
  701. }
  702. return SendClientMessageEx(playerid, COLOR_GREY, "You are not at a plant.");
  703. }
  704. CMD:pickplant(playerid, params[])
  705. {
  706. for(new i = 0; i < MAX_PLANTS; ++i)
  707. {
  708. if(IsValidDynamicObject(Plants[i][pObjectSpawned]) && IsPlayerInRangeOfPoint(playerid, 2.5, Plants[i][pPos][0], Plants[i][pPos][1], Plants[i][pPos][2]))
  709. {
  710. if(GetPlayerVirtualWorld(playerid) == Plants[i][pVirtual] && GetPlayerInterior(playerid) == Plants[i][pInterior])
  711. {
  712. switch(Plants[i][pPlantType])
  713. {
  714. case 1:
  715. {
  716. if(Plants[i][pGrowth] > 10)
  717. {
  718. new szMessage[128];
  719. ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_Out", 4.0, 0, 0, 0, 0, 0, 1);
  720. format(szMessage, sizeof(szMessage), "You picked the plant and gathered %d grams of pot.", Plants[i][pGrowth]);
  721. SendClientMessageEx(playerid, COLOR_GREY, szMessage);
  722. format(szMessage, sizeof(szMessage), "* %s picks the weed plant.", GetPlayerNameEx(playerid));
  723. ProxDetector(25.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  724. foreach(new z : Player)
  725. {
  726. if(Plants[i][pOwner] == GetPlayerSQLId(z))
  727. {
  728. PlayerInfo[z][pWeedObject] = 0;
  729. }
  730. }
  731. format(szMessage, sizeof(szMessage), "%s(%d) (IP:%s) has picked weed plant (%d) and recieved %d grams", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), i, Plants[i][pGrowth]);
  732. Log("logs/plant.log", szMessage);
  733. PlayerInfo[playerid][pDrugs][0] += Plants[i][pGrowth];
  734. DestroyPlant(i);
  735. SavePlant(i);
  736. return 1;
  737. }
  738. else SendClientMessageEx(playerid, COLOR_GREY, "This plant is not ready to be picked yet.");
  739. return 1;
  740. }
  741. case 2:
  742. {
  743. if(Plants[i][pGrowth] >= 120)
  744. {
  745. new szMessage[128],
  746. Grams = Random(10, 30);
  747. ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_Out", 4.0, 0, 0, 0, 0, 0, 1);
  748. format(szMessage, sizeof(szMessage), "You picked the plant and gathered %d milligrams of opium.", Grams);
  749. SendClientMessageEx(playerid, COLOR_GREY, szMessage);
  750. format(szMessage, sizeof(szMessage), "* %s picks the opium plant.", GetPlayerNameEx(playerid));
  751. ProxDetector(25.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  752. foreach(new z : Player)
  753. {
  754. if(Plants[i][pOwner] == GetPlayerSQLId(z))
  755. {
  756. PlayerInfo[z][pWeedObject] = 0;
  757. }
  758. }
  759. format(szMessage, sizeof(szMessage), "%s(%d) (IP:%s) has picked opium plant (%d) and recieved %d milligrams", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), i, Grams);
  760. Log("logs/plant.log", szMessage);
  761. PlayerInfo[playerid][pRawOpium] += Grams;
  762. DestroyPlant(i);
  763. SavePlant(i);
  764. return 1;
  765. }
  766. else SendClientMessageEx(playerid, COLOR_GREY, "This plant is not ready to be picked yet.");
  767. return 1;
  768. }
  769. }
  770. }
  771. }
  772. }
  773. return SendClientMessageEx(playerid, COLOR_GREY, "You are not at a plant.");
  774. }
  775. forward AttemptPurify(playerid);
  776. public AttemptPurify(playerid)
  777. {
  778. if(IsPlayerInRangeOfPoint(playerid, 5.0, -882.2048,1109.3385,5442.8193))
  779. {
  780. if(playerTabbed[playerid] != 0)
  781. {
  782. SendClientMessageEx(playerid, COLOR_GREY, "You alt-tabbed during the purification process.");
  783. Purification[0] = 0;
  784. KillTimer(GetPVarInt(playerid, "AttemptPurify"));
  785. DeletePVar(playerid, "PurifyTime");
  786. DeletePVar(playerid, "AttemptPurify");
  787. return 1;
  788. }
  789. if(GetPVarInt(playerid, "PurifyTime") == 30)
  790. {
  791. new szMessage[128];
  792. if(PlayerInfo[playerid][pRawOpium] > 30)
  793. {
  794. format(szMessage, sizeof(szMessage), "You have successfully purified %d milligrams of heroin!", 30);
  795. SendClientMessageEx(playerid, COLOR_GREEN, szMessage);
  796. format(szMessage, sizeof(szMessage), "* %s has successfully purified %d milligrams of heroin.", GetPlayerNameEx(playerid), 30);
  797. ProxDetector(25.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  798. PlayerInfo[playerid][pDrugs][4] += 30;
  799. PlayerInfo[playerid][pRawOpium] -= 30;
  800. KillTimer(GetPVarInt(playerid, "AttemptPurify"));
  801. Purification[0] = 0;
  802. DeletePVar(playerid, "PurifyTime");
  803. DeletePVar(playerid, "AttemptPurify");
  804. }
  805. else
  806. {
  807. format(szMessage, sizeof(szMessage), "You have successfully purified %d milligrams of heroin!", PlayerInfo[playerid][pRawOpium]);
  808. SendClientMessageEx(playerid, COLOR_GREEN, szMessage);
  809. format(szMessage, sizeof(szMessage), "* %s has successfully purified %d milligrams of heroin.", GetPlayerNameEx(playerid), PlayerInfo[playerid][pRawOpium]);
  810. ProxDetector(25.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  811. PlayerInfo[playerid][pDrugs][4] += PlayerInfo[playerid][pRawOpium];
  812. PlayerInfo[playerid][pRawOpium] = 0;
  813. KillTimer(GetPVarInt(playerid, "AttemptPurify"));
  814. Purification[0] = 0;
  815. DeletePVar(playerid, "PurifyTime");
  816. DeletePVar(playerid, "AttemptPurify");
  817. }
  818. }
  819. else
  820. {
  821. SetPVarInt(playerid, "PurifyTime", GetPVarInt(playerid, "PurifyTime")+1);
  822. }
  823. }
  824. else
  825. {
  826. DeletePVar(playerid, "PurifyTime");
  827. Purification[0] = 0;
  828. KillTimer(GetPVarInt(playerid, "AttemptPurify"));
  829. DeletePVar(playerid, "AttemptPurify");
  830. SendClientMessageEx(playerid, COLOR_GREY, "You stopped the purification process.");
  831. }
  832. return 1;
  833. }
  834. GetMaxDrugsAllowed(iDrugID) {
  835. switch(iDrugID) {
  836. case 0: return 1000;
  837. case 1: return 1000;
  838. case 2: return 1000;
  839. case 3: return 1000;
  840. case 4: return 1000;
  841. case 5: return 1000;
  842. case 6: return 1000;
  843. case 7: return 1000;
  844. case 8: return 1000;
  845. case 9: return 1000;
  846. case 10: return 1000;
  847. case 11: return 1000;
  848. case 12: return 1000;
  849. case 13: return 1000;
  850. case 14: return 1000;
  851. }
  852. return 0;
  853. }
  854. PlacePlant(id, ownerid, planttype, objectid, drugskill, Float:x, Float:y, Float:z, virtualworld, interior)
  855. {
  856. Plants[id][pObjectSpawned] = 0;
  857. Plants[id][pOwner] = ownerid;
  858. Plants[id][pPlantType] = planttype;
  859. Plants[id][pObject] = objectid;
  860. Plants[id][pGrowth] = 0;
  861. Plants[id][pPos][0] = x;
  862. Plants[id][pPos][1] = y;
  863. Plants[id][pPos][2] = z;
  864. Plants[id][pVirtual] = virtualworld;
  865. Plants[id][pInterior] = interior;
  866. Plants[id][pExpires] = gettime()+86400;
  867. Plants[id][pDrugsSkill] = drugskill;
  868. Plants[id][pObjectSpawned] = CreateDynamicObject(objectid, x, y, z, 0.0, 0.0, 0.0, virtualworld, interior);
  869. return id;
  870. }
  871. DestroyPlant(i)
  872. {
  873. DestroyDynamicObject(Plants[i][pObjectSpawned]);
  874. Plants[i][pObjectSpawned] = 0;
  875. Plants[i][pOwner] = 0;
  876. Plants[i][pPlantType] = 0;
  877. Plants[i][pObject] = 0;
  878. Plants[i][pGrowth] = 0;
  879. Plants[i][pPos][0] = 0.0;
  880. Plants[i][pPos][1] = 0.0;
  881. Plants[i][pPos][2] = 0.0;
  882. Plants[i][pVirtual] = 0;
  883. Plants[i][pInterior] = 0;
  884. Plants[i][pExpires] = 0;
  885. Plants[i][pDrugsSkill] = 0;
  886. if(IsValidDynamicObject(Plants[i][pObjectSpawned])) DestroyDynamicObject(Plants[i][pObjectSpawned]);
  887. return i;
  888. }
  889. PlantTimer()
  890. {
  891. szMiscArray[0] = 0;
  892. for(new i = 0; i < MAX_PLANTS; i++)
  893. {
  894. if(IsValidDynamicObject(Plants[i][pObjectSpawned]))
  895. {
  896. if(Plants[i][pExpires] > gettime())
  897. {
  898. switch(Plants[i][pPlantType])
  899. {
  900. case 1:
  901. {
  902. if(Plants[i][pGrowth] < 45)
  903. {
  904. switch(Plants[i][pDrugsSkill])
  905. {
  906. case 0 .. 50: Plants[i][pGrowth] += 1;
  907. case 51 .. 100: Plants[i][pGrowth] += 2;
  908. case 101 .. 200: Plants[i][pGrowth] += 3;
  909. case 201 .. 400: Plants[i][pGrowth] += 4;
  910. default: Plants[i][pGrowth] += 5;
  911. }
  912. }
  913. }
  914. case 2:
  915. {
  916. if(Plants[i][pGrowth] < 120) Plants[i][pGrowth] += 1;
  917. if(Plants[i][pGrowth] == 120)
  918. {
  919. DestroyDynamicObject(Plants[i][pObjectSpawned]);
  920. Plants[i][pObjectSpawned] = CreateDynamicObject(862, Plants[i][pPos][0], Plants[i][pPos][1], Plants[i][pPos][2], 0.0, 0.0, 0.0, Plants[i][pVirtual], Plants[i][pInterior]);
  921. Plants[i][pGrowth] = 121;
  922. Plants[i][pObject] = 862;
  923. format(szMiscArray, sizeof(szMiscArray), "Opium plant (%d) is ready to be picked.", i);
  924. Log("logs/plant.log", szMiscArray);
  925. }
  926. }
  927. }
  928. }
  929. else if(Plants[i][pExpires] == 0) { }
  930. else
  931. {
  932. format(szMiscArray, sizeof(szMiscArray), "Plant (%d) has expired.", i);
  933. Log("logs/plant.log", szMiscArray);
  934. DestroyPlant(i);
  935. SavePlant(i);
  936. }
  937. }
  938. }
  939. }