zombies.pwn 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Zombies Event
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #include <YSI\y_hooks>
  34. #if defined zombiemode
  35. stock SpawnZombie(playerid)
  36. {
  37. new Float:maxdis, Float:dis, tpto;
  38. maxdis=9999.9;
  39. SetPlayerSkin(playerid, 134);
  40. SetHealth(playerid, 200);
  41. SetPlayerInterior(playerid, 0);
  42. SetPlayerVirtualWorld(playerid, 0);
  43. for(new x;x<sizeof(ZombieSpawns);x++)
  44. {
  45. dis = GetPointDistanceToPoint(ZombieSpawns[x][0], ZombieSpawns[x][1], ZombieSpawns[x][2], GetPVarFloat(playerid,"MedicX"), GetPVarFloat(playerid,"MedicY"), GetPVarFloat(playerid,"MedicZ"));
  46. if((dis < maxdis) && (dis > 50.0))
  47. {
  48. tpto=x;
  49. maxdis=dis;
  50. }
  51. }
  52. SetPlayerPos(playerid, ZombieSpawns[tpto][0], ZombieSpawns[tpto][1], ZombieSpawns[tpto][2]);
  53. SetPlayerFacingAngle(playerid, ZombieSpawns[tpto][3]);
  54. ClearAnimationsEx(playerid);
  55. return 1;
  56. }
  57. stock MakeZombie(playerid)
  58. {
  59. new Float:X, Float:Y, Float:Z, string[128];
  60. GetPlayerPos(playerid, X, Y, Z);
  61. if(IsPlayerConnected(GetPVarInt(playerid, "pZombieBiter")))
  62. {
  63. mysql_format(MainPipeline, string, sizeof(string), "INSERT INTO zombiekills (id,num) VALUES (%d,1) ON DUPLICATE KEY UPDATE num = num + 1", GetPlayerSQLId(GetPVarInt(playerid, "pZombieBiter")));
  64. mysql_tquery(MainPipeline, string, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  65. DeletePVar(playerid, "pZombieBiter");
  66. }
  67. SendClientMessageEx(playerid, COLOR_RED, "You are now a zombie - use /bite to bite people!");
  68. SetPVarInt(playerid, "pIsZombie", 1);
  69. DeletePVar(playerid, "pZombieBit");
  70. SetPlayerToTeamColor(playerid);
  71. SetHealth(playerid, 200);
  72. SetPlayerSkin(playerid, 134);
  73. ResetPlayerWeaponsEx(playerid);
  74. //SendAudioToRange(70, 100, X, Y, Z, 30); RESCRIPT NEW SOUND
  75. mysql_format(MainPipeline, string, sizeof(string), "INSERT INTO `zombie` (`id`) VALUES ('%d')", GetPlayerSQLId(playerid));
  76. mysql_tquery(MainPipeline, string, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  77. return 1;
  78. }
  79. stock UnZombie(playerid)
  80. {
  81. DeletePVar(playerid, "pIsZombie");
  82. DeletePVar(playerid, "pZombieBit");
  83. SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
  84. SetPlayerToTeamColor(playerid);
  85. SetHealth(playerid, 100);
  86. new string[64];
  87. mysql_format(MainPipeline, string, sizeof(string), "DELETE FROM `zombie` WHERE `id`='%d'", GetPlayerSQLId(playerid));
  88. mysql_tquery(MainPipeline, string, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  89. return 1;
  90. }
  91. #endif
  92. #if defined zombiemode
  93. forward OnZombieCheck(playerid);
  94. public OnZombieCheck(playerid)
  95. {
  96. if(IsPlayerConnected(playerid))
  97. {
  98. new rows;
  99. cache_get_row_count(rows);
  100. if(rows)
  101. {
  102. MakeZombie(playerid);
  103. }
  104. }
  105. return 1;
  106. }
  107. #endif
  108. forward ScrapMetal(playerid, vehicleid);
  109. public ScrapMetal(playerid, vehicleid)
  110. {
  111. PlayerInfo[playerid][mInventory][16]--;
  112. new Float:vHP;
  113. GetVehicleHealth(vehicleid, vHP);
  114. SetVehicleHealth(vehicleid, vHP+500.0);
  115. new string[128];
  116. format(string, sizeof(string), "%s has added scrap metal to their vehicle.", GetPlayerNameEx(playerid));
  117. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  118. SendClientMessage(playerid, COLOR_WHITE, "Your have applied scrap metal to your vehicle giving it +500HP!");
  119. PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
  120. ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0, 1);
  121. format(string, sizeof(string), "[ZSCRAPMETAL] %s(%d) used a Scrap Metal. Left: %d", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), PlayerInfo[playerid][mInventory][16]);
  122. Log("logs/micro.log", string);
  123. DeletePVar(playerid, "zscrapmetal");
  124. return 1;
  125. }
  126. #if defined zombiemode
  127. CMD:zh(playerid, params[])
  128. {
  129. return cmd_zombiehelp(playerid, params);
  130. }
  131. CMD:zombiehelp(playerid, params[])
  132. {
  133. SendClientMessageEx(playerid, COLOR_GREY, "*** ZOMBIE HELP *** /buycure /bite /curevirus /getvials (For Medics)");
  134. SendClientMessageEx(playerid, COLOR_GREY, "*** ZOMBIE HELP *** /buycure - 20 Credits (5x) /zinject - 40 Credits (3x) /zopenkit - 30 Credits (1x)");
  135. SendClientMessageEx(playerid, COLOR_GREY, "*** ZOMBIE HELP *** /z50cal - 20 Credits (14x bullets) /zscrapmetal - 10 Credits)");
  136. SendClientMessageEx(playerid, COLOR_GREY, "*** ZOMBIE HELP *** /bite /curevirus /getvials (For Medics)");
  137. if(PlayerInfo[playerid][pAdmin] >= 1337)
  138. {
  139. SendClientMessageEx(playerid, COLOR_GREY, "*** ZOMBIE ADMIN ***: /zombieweather /zombieevent /makezombie /setvials /zombieannounce /unzombie");
  140. }
  141. return 1;
  142. }
  143. CMD:buycure(playerid, params[])
  144. {
  145. if(IsAtDeliverPatientPoint(playerid))
  146. {
  147. if(gettime() - 900 > PlayerInfo[playerid][pBoughtCure] || PlayerInfo[playerid][pBoughtCure] == 0)
  148. {
  149. if(GetPVarInt(playerid, "PinConfirmed"))
  150. {
  151. if(PlayerInfo[playerid][pCredits] < 20)
  152. return SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough credits to purchase this item. Visit shop.ng-gaming.net to purchase credits.");
  153. new string[128];
  154. format(string, sizeof(string), "[BUYCURE] [User: %s(%i)] [IP: %s] [Credits: %s] [Zombie Cure] [Price: %s]", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), number_format(PlayerInfo[playerid][pCredits]), number_format(20));
  155. Log("logs/zombiecure.log", string), print(string);
  156. GivePlayerCredits(playerid, -20, 1);
  157. PlayerInfo[playerid][pVials] += 5;
  158. PlayerInfo[playerid][pBoughtCure] = gettime();
  159. g_mysql_SaveAccount(playerid);
  160. format(string, sizeof(string), "[BUYCURE] [User: %s(%i)] [IP: %s] [Credits: %s] [Zombie Cure] [Price: %s]", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), number_format(PlayerInfo[playerid][pCredits]), number_format(20));
  161. Log("logs/credits.log", string), print(string);
  162. format(string, sizeof(string), "You have purchased a vial of the cure for %s credits. Use it with /curevirus.", number_format(20));
  163. SendClientMessageEx(playerid, COLOR_CYAN, string);
  164. }
  165. else
  166. {
  167. PinLogin(playerid);
  168. }
  169. }
  170. else
  171. {
  172. SendClientMessageEx(playerid, COLOR_GRAD2, "You must wait 15 minutes between purchasing cures!");
  173. }
  174. }
  175. else {
  176. return SendClientMessageEx(playerid, COLOR_GRAD2, "You must be at a hospital delivery point to purchase a cure!");
  177. }
  178. return 1;
  179. }
  180. CMD:zombieweather(playerid, params[])
  181. {
  182. if(PlayerInfo[playerid][pAdmin] >= 1337)
  183. {
  184. SetWeather(9);
  185. foreach(new i: Player) SyncMinTime(i);
  186. SendRconCommand("loadfs zombie_mapping");
  187. SendClientMessageEx(playerid, COLOR_WHITE, "Zombie weather loaded.");
  188. }
  189. return 1;
  190. }
  191. //Zombie Event Commands
  192. CMD:zombieevent(playerid, params[])
  193. {
  194. if(PlayerInfo[playerid][pAdmin] >= 1337)
  195. {
  196. if(zombieevent == 0)
  197. {
  198. zombieevent=1;
  199. foreach(new i: Player)
  200. {
  201. PlayerInfo[i][pVials]++;
  202. SetPlayerWeaponsEx(playerid);
  203. }
  204. //SendAudioToRange(70, 100, 0.0, 0.0, 0.0, 10000); RESCRIPT NEW SOUND
  205. SendGroupMessage(GROUP_TYPE_MEDIC, TEAM_MED_COLOR, "Attention FDSA, the zombie event has started, you can now use /curevirus to cure the virus");
  206. SendClientMessageEx(playerid, COLOR_WHITE, "You have enabled zombie mode.");
  207. mysql_tquery(MainPipeline, "DELETE FROM zombie", "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  208. }
  209. else
  210. {
  211. zombieevent=0;
  212. SendRconCommand("unloadfs zombie_mapping");
  213. foreach(new i: Player) SyncMinTime(i);
  214. SetWeather(5);
  215. mysql_tquery(MainPipeline, "DELETE FROM zombie", "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  216. foreach(Player, i)
  217. {
  218. UnZombie(i);
  219. }
  220. SendClientMessageEx(playerid, COLOR_WHITE, "Nothing to see here, folks.");
  221. }
  222. }
  223. return 1;
  224. }
  225. CMD:zombieannounce(playerid, params[])
  226. {
  227. if(PlayerInfo[playerid][pAdmin] >= 1337)
  228. {
  229. if(zombieevent == 1)
  230. {
  231. //SendAudioToRange(65, 100, 0.0, 0.0, 0.0, 10000); RESCRIPT NEW SOUND
  232. SendClientMessageToAllEx(COLOR_WHITE, "|___________ Government News Announcement ___________|");
  233. SendClientMessageToAllEx(COLOR_DBLUE, "** Unknown Spokesman: Attention, attention. This is a government announcement.");
  234. SendClientMessageToAllEx(COLOR_DBLUE, "** Unknown Spokesman: A state of emergency has been declared by the President of San Andreas");
  235. SendClientMessageToAllEx(COLOR_DBLUE, "** Unknown Spokesman: The City of Los Santos has been quarantined under executive order 133B.");
  236. SendClientMessageToAllEx(COLOR_DBLUE, "** Unknown Spokesman: Please direct yourself to government services for assistance. May god help us all.");
  237. }
  238. }
  239. return 1;
  240. }
  241. CMD:makezombie(playerid, params[])
  242. {
  243. if(PlayerInfo[playerid][pAdmin] >= 1337)
  244. {
  245. if(zombieevent == 1)
  246. {
  247. new giveplayerid;
  248. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /makezombie [player]");
  249. MakeZombie(giveplayerid);
  250. }
  251. }
  252. return 1;
  253. }
  254. CMD:getvials(playerid, params[])
  255. {
  256. if(zombieevent == 1)
  257. {
  258. if(!IsAMedic(playerid) && PlayerInfo[playerid][pMember] != 11) return SendClientMessageEx(playerid, COLOR_GREY, "You aren't a Medic!");
  259. if(!IsAnAmbulance(GetPlayerVehicleID(playerid)) && GetVehicleModel(GetPlayerVehicleID(playerid)) != 470) return SendClientMessageEx(playerid, COLOR_GREY, "You aren't in an ambulance!");
  260. if(PlayerInfo[playerid][pVials] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You already have vials.");
  261. new string[128];
  262. PlayerInfo[playerid][pVials] += 5;
  263. SendClientMessageEx(playerid, COLOR_GREEN, "You have received 5 vials.");
  264. format(string, sizeof(string), "* %s takes 5 vials from the vehicle.", GetPlayerNameEx(playerid));
  265. ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  266. }
  267. return 1;
  268. }
  269. CMD:setvials(playerid, params[])
  270. {
  271. if(PlayerInfo[playerid][pAdmin] >= 1337)
  272. {
  273. new giveplayerid, vials;
  274. if(sscanf(params, "ui", giveplayerid, vials)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /setvials [player] [number]");
  275. if(vials < 0) return 1;
  276. new string[128];
  277. PlayerInfo[giveplayerid][pVials] += vials;
  278. format(string, sizeof(string), "You gave %s %d vials of the cure!", GetPlayerNameEx(giveplayerid), vials);
  279. SendClientMessageEx(playerid, COLOR_WHITE,string);
  280. format(string, sizeof(string), "You received %d vials of the cure - use them with /curevirus.", vials);
  281. SendClientMessageEx(giveplayerid, COLOR_WHITE,string);
  282. }
  283. return 1;
  284. }
  285. CMD:unzombie(playerid, params[])
  286. {
  287. if(PlayerInfo[playerid][pAdmin] >= 1337)
  288. {
  289. if(zombieevent == 1)
  290. {
  291. new giveplayerid;
  292. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /unzombie [player]");
  293. SendClientMessageEx(playerid, COLOR_GREY, "Done!");
  294. UnZombie(giveplayerid);
  295. }
  296. }
  297. return 1;
  298. }
  299. CMD:bite(playerid, params[])
  300. {
  301. if(zombieevent == 1)
  302. {
  303. if(GetPVarType(playerid, "pIsZombie"))
  304. {
  305. new Float:X, Float:Y, Float:Z;
  306. GetPlayerPos(playerid, X, Y, Z);
  307. foreach(Player, i)
  308. {
  309. if(!GetPVarType(i, "pIsZombie") && !IsPlayerInAnyVehicle(i) && IsPlayerInRangeOfPoint(i, 2, X, Y, Z))
  310. {
  311. /*if(GetPVarType(i, "pZombieBit")) {
  312. return SendClientMessageEx(playerid, COLOR_GREY, "This player is already infected - find somebody else!");
  313. } */
  314. new Float:hp, string[128];
  315. if(GetPVarInt(i, "LastBiteTime"))
  316. {
  317. if(gettime() < GetPVarInt(i, "LastBiteTime"))
  318. {
  319. format(string, sizeof(string), "You must wait %d seconds before you can bite that player.", (GetPVarInt(i, "LastBiteTime") - gettime()));
  320. SendClientMessageEx(playerid, COLOR_GREY, string);
  321. return 1;
  322. }
  323. }
  324. if(PlayerInfo[i][mInventory][18])
  325. {
  326. PlayerInfo[i][mInventory][18]--;
  327. SetPVarInt(i, "LastBiteTime", gettime()+15);
  328. format(string, sizeof(string), "* %s clamps down onto %s's skin, biting into it.", GetPlayerNameEx(playerid), GetPlayerNameEx(i));
  329. ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  330. SendClientMessageEx(i, COLOR_GREY, "You were not affected by the zombies bite due to the antibiotic in your bloodstream!");
  331. return SendClientMessageEx(playerid, COLOR_GREY, "They have a antibiotic in their bloodstream! Your bite had no effect on them!");
  332. }
  333. GetHealth(i, hp);
  334. SetHealth(i, hp - 30);
  335. SetPVarInt(i, "pZombieBit", 1);
  336. SetPVarInt(i, "pZombieBiter", playerid);
  337. SetPVarInt(i, "LastBiteTime", gettime()+15);
  338. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray),"INSERT INTO `zombiekills` (`id`,`name`,`num`) VALUES ('%d', '%s', 1) ON DUPLICATE KEY UPDATE `num` = `num` + 1", PlayerInfo[playerid][pId], GetPlayerNameEx(playerid));
  339. mysql_tquery(MainPipeline, szMiscArray, "","");
  340. SetPVarInt(playerid, "LastBiteID", i);
  341. SetPlayerToTeamColor(i);
  342. format(string, sizeof(string), "* %s clamps down onto %s's skin, biting into it.", GetPlayerNameEx(playerid), GetPlayerNameEx(i));
  343. ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  344. SendClientMessageEx(i, COLOR_GREY, "Use /buycure to purchase a cure to heal yourself.");
  345. //SendAudioToRange(66, 100, X, Y, Z, 5); RESCRIPT NEW SOUND
  346. return 1;
  347. }
  348. }
  349. SendClientMessageEx(playerid, COLOR_GREY, "No one is near you to bite!");
  350. }
  351. }
  352. else
  353. {
  354. if(EventKernel[EventType] == 4 && (GetPVarInt(playerid, "EventToken") == 1) && GetPVarType(playerid, "pEventZombie"))
  355. {
  356. new Float:X, Float:Y, Float:Z;
  357. GetPlayerPos(playerid, X, Y, Z);
  358. foreach(Player, i)
  359. {
  360. if((GetPVarInt(i, "EventToken") == 1) && !GetPVarType(i, "pEventZombie"))
  361. {
  362. if(IsPlayerInRangeOfPoint(i, 2, X, Y, Z))
  363. {
  364. new Float:hp, string[128];
  365. GetHealth(i, hp);
  366. SetHealth(i, hp-20);
  367. format(string, sizeof(string), "* %s clamps down onto %s's skin, biting into it.", GetPlayerNameEx(playerid), GetPlayerNameEx(i));
  368. ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  369. //SendAudioToRange(65, 100, X, Y, Z, 5);
  370. return 1;
  371. }
  372. }
  373. }
  374. SendClientMessageEx(playerid, COLOR_GREY, "No one is near you to bite!");
  375. }
  376. }
  377. return 1;
  378. }
  379. CMD:curevirus(playerid, params[])
  380. {
  381. if(zombieevent == 1 && PlayerInfo[playerid][pVials])
  382. {
  383. new giveplayerid, string[128];
  384. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /curevirus [player]");
  385. if(!GetPVarType(giveplayerid, "pZombieBit")) return SendClientMessageEx(playerid, COLOR_GREY, "That person does not have the virus, or they're already a zombie!");
  386. new Float:X, Float:Y, Float:Z;
  387. GetPlayerPos(giveplayerid, X, Y, Z);
  388. if(!IsPlayerInRangeOfPoint(playerid, 5, X, Y, Z)) return SendClientMessageEx(playerid, COLOR_GREY, "You are not near that patient.");
  389. if(GetPVarInt(playerid, "pZombieHealTime"))
  390. {
  391. if(gettime() < GetPVarInt(playerid, "pZombieHealTime"))
  392. {
  393. format(string, sizeof(string), "You must wait %d seconds before you can heal again.", (GetPVarInt(playerid, "pZombieHealTime") - gettime()));
  394. SendClientMessageEx(playerid, COLOR_GREY, string);
  395. return 1;
  396. }
  397. }
  398. format(string, sizeof(string), "* %s injects %s with an antidote.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
  399. ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  400. DeletePVar(giveplayerid, "pZombieBit");
  401. SetPVarInt(playerid, "pZombieHealTime", gettime()+15);
  402. SetPlayerToTeamColor(giveplayerid);
  403. PlayerInfo[playerid][pVials]--;
  404. if(PlayerInfo[playerid][pVials] == 0)
  405. {
  406. SendClientMessageEx(playerid, COLOR_GREY, "You've ran out of vials!");
  407. }
  408. else
  409. {
  410. format(string, sizeof(string), "You now have %d vials left.", PlayerInfo[playerid][pVials]);
  411. SendClientMessageEx(playerid, COLOR_GREY, string);
  412. }
  413. mysql_format(MainPipeline, string, sizeof(string), "INSERT INTO zombieheals (id,num) VALUES (%d,1) ON DUPLICATE KEY UPDATE num = num + 1", GetPlayerSQLId(playerid));
  414. mysql_tquery(MainPipeline, string, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  415. }
  416. return 1;
  417. }
  418. #endif
  419. /*
  420. // Changed to give an you instead of this. (15 hours playing time during this time)
  421. CMD:trickortreat(playerid, params[])
  422. {
  423. new year, month, day, string[256];
  424. getdate(year, month, day);
  425. if(month == 10 && day == 31)
  426. {
  427. if(PlayerInfo[playerid][pConnectHours] > 2)
  428. {
  429. for(new i = 0; i < sizeof(HouseInfo); i++)
  430. {
  431. if (IsPlayerInRangeOfPoint(playerid,3,HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]))
  432. {
  433. if(PlayerInfo[playerid][pTrickortreat] == 0)
  434. {
  435. GiftPlayer(MAX_PLAYERS, playerid);
  436. switch(PlayerInfo[playerid][pDonateRank])
  437. {
  438. case 0, 1: PlayerInfo[playerid][pTrickortreat] = 5;
  439. case 2: PlayerInfo[playerid][pTrickortreat] = 4;
  440. case 3: PlayerInfo[playerid][pTrickortreat] = 3;
  441. case 4: PlayerInfo[playerid][pTrickortreat] = 2;
  442. case 5: PlayerInfo[playerid][pTrickortreat] = 2;
  443. }
  444. return 1;
  445. }
  446. else
  447. {
  448. if(GetPVarInt(playerid, "PinConfirmed"))
  449. {
  450. format(string, sizeof(string),"Item: Reset Trick or Treat Timer\nYour Credits: %s\nCost: {FFD700}%s{A9C4E4}\nCredits Left: %s", number_format(PlayerInfo[playerid][pCredits]), number_format(20), number_format(PlayerInfo[playerid][pCredits]-20));
  451. ShowPlayerDialogEx( playerid, DIALOG_SHOPTOTRESET, DIALOG_STYLE_MSGBOX, "Reset Gift Timer", string, "Purchase", "Exit" );
  452. SendClientMessageEx(playerid, COLOR_GRAD2, "You have already trick or treated in the last few hours!");
  453. return 1;
  454. }
  455. else
  456. {
  457. PinLogin(playerid);
  458. SendClientMessageEx(playerid, COLOR_GRAD2, "You have already trick or treated in the last few hours!");
  459. return 1;
  460. }
  461. }
  462. }
  463. }
  464. SendClientMessageEx(playerid, COLOR_GREY, "You are not at a house. (green house icon)");
  465. }
  466. else
  467. {
  468. SendClientMessageEx(playerid, COLOR_GREY, "You have not played 2 hours.");
  469. }
  470. }
  471. else SendClientMessageEx(playerid, COLOR_GREY, "It isn't Halloween!");
  472. return 1;
  473. }*/
  474. CMD:prezombie(playerid, params[])
  475. {
  476. if(PlayerInfo[playerid][pAdmin] < 1337 && PlayerInfo[playerid][pShopTech] < 3) return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  477. if(prezombie)
  478. {
  479. prezombie = 0;
  480. SendClientMessageEx(playerid, -1, "You have successfully disabled the pre-zombie event sale.");
  481. }
  482. else
  483. {
  484. prezombie = 1;
  485. SendClientMessageEx(playerid, -1, "You have successfully enabled the pre-zombie event sale.");
  486. }
  487. return 1;
  488. }
  489. CMD:zfuelcan(playerid, params[])
  490. {
  491. new zyear, zmonth, zday;
  492. getdate(zyear, zmonth, zday);
  493. if(!zombieevent && !(zmonth == 10 && zday == 31) && !(zmonth == 11 && zday == 1)) return SendClientMessageEx(playerid, COLOR_GREY, "There is currently no active Zombie Event!");
  494. if(!PlayerInfo[playerid][zFuelCan]) return SendClientMessage(playerid, COLOR_GREY, "You do not have a Fuel Can in your inventory!");
  495. if(GetPVarInt(playerid, "fuelcan") == 2) return 1;
  496. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GRAD1, "You can not use your fuel can while inside the vehicle.");
  497. if(GetPVarInt(playerid, "EventToken")) return SendClientMessageEx(playerid, COLOR_GRAD1, "You can't use this while in an event.");
  498. if(GetPVarType(playerid, "PlayerCuffed") || GetPVarInt(playerid, "pBagged") >= 1 || GetPVarType(playerid, "Injured") || GetPVarType(playerid, "IsFrozen")) return SendClientMessageEx(playerid, COLOR_GRAD2, "You can't do that at this time!");
  499. new closestcar = GetClosestCar(playerid);
  500. if(!IsPlayerInRangeOfVehicle(playerid, closestcar, 10.0)) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not close enough to any vehicle.");
  501. new string[72];
  502. format(string, sizeof(string), "%s begins refilling their vehicle with a fuel can.", GetPlayerNameEx(playerid));
  503. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  504. ApplyAnimation(playerid, "SCRATCHING", "scdldlp", 4.0, 1, 0, 0, 0, 0, 1);
  505. SetTimerEx("FuelCan", 10000, false, "iii", playerid, closestcar, PlayerInfo[playerid][zFuelCan]);
  506. SetPVarInt(playerid, "fuelcan", 2);
  507. GameTextForPlayer(playerid, "~w~Refueling...", 10000, 3);
  508. return 1;
  509. }
  510. CMD:zscrapmetal(playerid, params[])
  511. {
  512. new zyear, zmonth, zday;
  513. getdate(zyear, zmonth, zday);
  514. if(!zombieevent && !(zmonth == 10 && zday == 31) && !(zmonth == 11 && zday == 1)) return SendClientMessageEx(playerid, COLOR_GREY, "There is currently no active Zombie Event!");
  515. if(!PlayerInfo[playerid][mInventory][16]) return SendClientMessageEx(playerid, COLOR_GREY, "You do not have any Scrap Metal in your inventory, visit /microshop to purchase.");
  516. if(GetPVarInt(playerid, "zscrapmetal") == 1) return 1;
  517. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GRAD1, "You can not use this while inside the vehicle.");
  518. if(GetPVarInt(playerid, "EventToken")) return SendClientMessageEx(playerid, COLOR_GRAD1, "You can't use this while in an event.");
  519. if(GetPVarType(playerid, "PlayerCuffed") || GetPVarInt(playerid, "pBagged") >= 1 || GetPVarType(playerid, "Injured") || GetPVarType(playerid, "IsFrozen")) return SendClientMessage(playerid, COLOR_GRAD2, "You can't do that at this time!");
  520. new closestcar = GetClosestCar(playerid);
  521. if(!IsPlayerInRangeOfVehicle(playerid, closestcar, 10.0)) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not close enough to any vehicle.");
  522. new Float:vHP;
  523. GetVehicleHealth(closestcar, vHP);
  524. if(vHP > 5000) return SendClientMessageEx(playerid, -1, "You cannot add scrapmetal when your vehicle's health is over 5000 HP!");
  525. new string[71];
  526. format(string, sizeof(string), "%s begins to apply scrap metal to their vehicle.", GetPlayerNameEx(playerid));
  527. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  528. ApplyAnimation(playerid, "COP_AMBIENT", "Copbrowse_loop", 4.1, 1, 0, 0, 0, 0, 1);
  529. SetTimerEx("ScrapMetal", 6000, false, "ii", playerid, closestcar);
  530. SetPVarInt(playerid, "zscrapmetal", 1);
  531. GameTextForPlayer(playerid, "~w~Applying...", 6000, 3);
  532. return 1;
  533. }
  534. CMD:z50cal(playerid, params[])
  535. {
  536. if(!zombieevent) return SendClientMessageEx(playerid, COLOR_GREY, "There is currently no active Zombie Event!");
  537. if(!PlayerInfo[playerid][mInventory][17]) return SendClientMessageEx(playerid, COLOR_GREY, "You do not have any .50 Caliber Ammo in your inventory, visit /microshop to purchase.");
  538. if((GetPlayerWeapon(playerid) != 33 || PlayerInfo[playerid][pGuns][6] != 33) && (GetPlayerWeapon(playerid) != 34 || PlayerInfo[playerid][pGuns][6] != 34)) return SendClientMessageEx(playerid, COLOR_GREY, "You can only load a rifle or sniper rifle with .50 cal ammo.");
  539. if(!GetPVarType(playerid, "z50Cal"))
  540. {
  541. SendClientMessageEx(playerid, -1, "You have loaded a .50 Caliber bullet into your weapon.");
  542. SetPVarInt(playerid, "z50Cal", 1);
  543. }
  544. else
  545. {
  546. SendClientMessageEx(playerid, -1, "You have unloaded a .50 Caliber bullet from your weapon.");
  547. DeletePVar(playerid, "z50Cal");
  548. }
  549. ApplyAnimation(playerid, "RIFLE", "RIFLE_load", 4.0, 0, 0, 0, 0, 0, 1);
  550. return 1;
  551. }
  552. CMD:zinject(playerid, params[])
  553. {
  554. if(!zombieevent) return SendClientMessageEx(playerid, COLOR_GREY, "There is currently no active Zombie Event!");
  555. if(!PlayerInfo[playerid][mPurchaseCount][18]) return SendClientMessageEx(playerid, COLOR_GREY, "You do not have any Antibiotic Injections in your inventory, visit /microshop to purchase.");
  556. if(PlayerInfo[playerid][mInventory][18]) return SendClientMessageEx(playerid, COLOR_GREY, "You currently have a active antibiotic in your bloodstream!");
  557. PlayerInfo[playerid][mPurchaseCount][18]--;
  558. PlayerInfo[playerid][mInventory][18] = 3;
  559. SendClientMessageEx(playerid, -1, "You have injected your self with a antibiotic! You will be immune from 3 zombie bites!");
  560. return 1;
  561. }
  562. CMD:zopenkit(playerid, params[])
  563. {
  564. new zyear, zmonth, zday;
  565. getdate(zyear, zmonth, zday);
  566. if(!zombieevent && !(zmonth == 10 && zday == 31) && !(zmonth == 11 && zday == 1)) return SendClientMessageEx(playerid, COLOR_GREY, "There is currently no active Zombie Event!");
  567. if(!PlayerInfo[playerid][mInventory][19]) return SendClientMessageEx(playerid, COLOR_GREY, "You do not have any Survivor Kits in your inventory, visit /microshop to purchase.");
  568. new string[128], rand = random(75);
  569. switch(rand)
  570. {
  571. case 0 .. 24://1 Scrap Metal & 2 Bullets
  572. {
  573. PlayerInfo[playerid][mInventory][16]++;
  574. PlayerInfo[playerid][mInventory][17] += 2;
  575. SendClientMessageEx(playerid, -1, "You found 1 Scrap Metal & 2 .50 Cal Bullets in your kit! Use /zscrapmetal and /z50cal to use your items.");
  576. format(string, sizeof(string), "[ZOPEKIT] %s found 1 Scrap Metal & 2 .50 Cal Bullets in their kit!", GetPlayerNameEx(playerid));
  577. }
  578. case 25 .. 49://5 Bullets & 2 Antibiotic Injection
  579. {
  580. PlayerInfo[playerid][mInventory][17] += 5;
  581. PlayerInfo[playerid][mPurchaseCount][18] += 2;
  582. SendClientMessageEx(playerid, -1, "You found 5 .50 Cal Bullets & 2 Antibiotic Injections in your kit! Use /z50cal and /zinject to use your items.");
  583. format(string, sizeof(string), "[ZOPEKIT] %s found 5 .50 Cal Bullets & 2 Antibiotic Injections in their kit!", GetPlayerNameEx(playerid));
  584. }
  585. case 50 .. 74://2 Engine Repair Kits & 1 Scrap Metal, 1 Antibiotic Injection
  586. {
  587. PlayerInfo[playerid][mInventory][8] += 2;
  588. PlayerInfo[playerid][mInventory][16]++;
  589. PlayerInfo[playerid][mPurchaseCount][18]++;
  590. SendClientMessageEx(playerid, -1, "You found 2 Engine Repair Kits, 1 Scrap Metal & 1 Antibiotic Injection in your kit! Use /jumpstart /zscrapmetal and /zinject to use your items.");
  591. format(string, sizeof(string), "[ZOPEKIT] %s found 2 Engine Repair Kits, 1 Scrap Metal & 1 Antibiotic Injection in their kit!", GetPlayerNameEx(playerid));
  592. }
  593. }
  594. Log("logs/micro.log", string);
  595. PlayerInfo[playerid][mInventory][19]--;
  596. return 1;
  597. }
  598. CMD:givez(playerid, params[])
  599. {
  600. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use this command!");
  601. new target, option[11], amount;
  602. if(sscanf(params, "us[11]d", target, option, amount) || amount <= 0) return SendClientMessageEx(playerid, -1, "USAGE: /givez [player] [option] [amount]"), SendClientMessageEx(playerid, -1, "Available Options: jumpstart, fuelcan, scrapmetal, 50cal, inject, kit");
  603. if(!IsPlayerConnected(target)) return SendClientMessageEx(playerid, COLOR_GREY, "That player is not connected.");
  604. new string[128];
  605. if(!strcmp(option, "jumpstart", true))
  606. {
  607. PlayerInfo[playerid][mInventory][8] += amount;
  608. format(string, sizeof(string), "You have given %s %d Jump Start(s).", GetPlayerNameEx(target), amount);
  609. SendClientMessageEx(playerid, -1, string);
  610. format(string, sizeof(string), "%s has given you %d Jump Start(s). /jumpstart to use this item.", GetPlayerNameEx(playerid), amount);
  611. SendClientMessageEx(target, -1, string);
  612. format(string, sizeof(string), "[GIVEZ] %s has given %s(%d) %d Jump Start(s).", GetPlayerNameEx(playerid), GetPlayerNameEx(target), GetPlayerSQLId(target), amount);
  613. }
  614. if(!strcmp(option, "fuelcan", true))
  615. {
  616. if(amount != 25 && amount != 50 && amount != 75) return SendClientMessageEx(playerid, -1, "Valid Amounts for fuel cans are 25, 50 and 75.");
  617. PlayerInfo[target][zFuelCan] = amount;
  618. format(string, sizeof(string), "You have given %s a fuelcan with %d fuel.", GetPlayerNameEx(target), amount);
  619. SendClientMessageEx(playerid, -1, string);
  620. format(string, sizeof(string), "%s has given you a fuelcan with %d fuel. /zfuelcan to use this item.", GetPlayerNameEx(playerid), amount);
  621. SendClientMessageEx(target, -1, string);
  622. format(string, sizeof(string), "[GIVEZ] %s has given %s(%d) a fuelcan with %d fuel.", GetPlayerNameEx(playerid), GetPlayerNameEx(target), GetPlayerSQLId(target), amount);
  623. }
  624. if(!strcmp(option, "scrapmetal", true))
  625. {
  626. PlayerInfo[target][mInventory][16] += amount;
  627. format(string, sizeof(string), "You have given %s %d Scrap Metal(s).", GetPlayerNameEx(target), amount);
  628. SendClientMessageEx(playerid, -1, string);
  629. format(string, sizeof(string), "%s has given you %d Scrap Metal(s). /zscrapmetal to use this item.", GetPlayerNameEx(playerid), amount);
  630. SendClientMessageEx(target, -1, string);
  631. format(string, sizeof(string), "[GIVEZ] %s has given %s(%d) %d Scrap Metal(s).", GetPlayerNameEx(playerid), GetPlayerNameEx(target), GetPlayerSQLId(target), amount);
  632. }
  633. if(!strcmp(option, "50cal", true))
  634. {
  635. PlayerInfo[target][mInventory][17] += amount;
  636. format(string, sizeof(string), "You have given %s %d .50 Caliber Bullet(s).", GetPlayerNameEx(target), amount);
  637. SendClientMessageEx(playerid, -1, string);
  638. format(string, sizeof(string), "%s has given you %d .50 Caliber Bullet(s). /z50cal to use this item.", GetPlayerNameEx(playerid), amount);
  639. SendClientMessageEx(target, -1, string);
  640. format(string, sizeof(string), "[GIVEZ] %s has given %s(%d) %d .50 Caliber Bullet(s).", GetPlayerNameEx(playerid), GetPlayerNameEx(target), GetPlayerSQLId(target), amount);
  641. }
  642. if(!strcmp(option, "inject", true))
  643. {
  644. PlayerInfo[target][mPurchaseCount][18] += amount;
  645. format(string, sizeof(string), "You have given %s %d Antibiotic Injection(s).", GetPlayerNameEx(target), amount);
  646. SendClientMessageEx(playerid, -1, string);
  647. format(string, sizeof(string), "%s has given you %d Antibiotic Injection(s). /zinject to use this item.", GetPlayerNameEx(playerid), amount);
  648. SendClientMessageEx(target, -1, string);
  649. format(string, sizeof(string), "[GIVEZ] %s has given %s(%d) %d Antibiotic Injection(s).", GetPlayerNameEx(playerid), GetPlayerNameEx(target), GetPlayerSQLId(target), amount);
  650. }
  651. if(!strcmp(option, "kit", true))
  652. {
  653. PlayerInfo[target][mInventory][19] += amount;
  654. format(string, sizeof(string), "You have given %s %d Survivor Kit(s).", GetPlayerNameEx(target), amount);
  655. SendClientMessageEx(playerid, -1, string);
  656. format(string, sizeof(string), "%s has given you %d Survivor Kit(s). /zopenkit to use this item.", GetPlayerNameEx(playerid), amount);
  657. SendClientMessageEx(target, -1, string);
  658. format(string, sizeof(string), "[GIVEZ] %s has given %s(%d) %d Survivor Kit(s).", GetPlayerNameEx(playerid), GetPlayerNameEx(target), GetPlayerSQLId(target), amount);
  659. }
  660. Log("logs/micro.log", string);
  661. return 1;
  662. }
  663. CMD:zscores(playerid, params[]) {
  664. if(!zombieevent) return SendClientMessageEx(playerid, COLOR_GREY, "The zombie event is not active!");
  665. ShowPlayerDialogEx(playerid, DIALOG_ZSCORES, DIALOG_STYLE_LIST, "Zombie Scores", "Human Kills\nZombie Infections\nLongest Surviving\nLongest Zombies", "Select", "Cancel");
  666. return 1;
  667. }
  668. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  669. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  670. switch(dialogid) {
  671. case DIALOG_ZSCORES: {
  672. if(!response) return 1;
  673. ShowZombieScoreBoard(playerid, listitem);
  674. }
  675. }
  676. return 0;
  677. }
  678. ShowZombieScoreBoard(iPlayerID, iScoreType) {
  679. switch(iScoreType) {
  680. case 0: {
  681. mysql_tquery(MainPipeline, "SELECT * FROM `humankills` ORDER BY `num` DESC LIMIT 5", "OnShowZombieScoreBoard", "ii", iPlayerID, iScoreType);
  682. }
  683. case 1: {
  684. mysql_tquery(MainPipeline, "SELECT * FROM `zombiekills` ORDER BY `num` DESC LIMIT 5", "OnShowZombieScoreBoard", "ii", iPlayerID, iScoreType);
  685. }
  686. case 2: {
  687. mysql_tquery(MainPipeline, "SELECT * FROM `humansurvivor` ORDER BY `num` DESC LIMIT 5", "OnShowZombieScoreBoard", "ii", iPlayerID, iScoreType);
  688. }
  689. case 3: {
  690. mysql_tquery(MainPipeline, "SELECT * FROM `zombiesurvivor` ORDER BY `num` DESC LIMIT 5", "OnShowZombieScoreBoard", "ii", iPlayerID, iScoreType);
  691. }
  692. }
  693. return 1;
  694. }
  695. forward OnShowZombieScoreBoard(iPlayerID, iScoreType);
  696. public OnShowZombieScoreBoard(iPlayerID, iScoreType) {
  697. new
  698. iRows,
  699. iCount,
  700. iNumb,
  701. szTempName[MAX_PLAYER_NAME];
  702. szMiscArray[0] = 0;
  703. cache_get_row_count(iRows);
  704. switch(iScoreType) {
  705. case 0: szMiscArray = "Name\tKills";
  706. case 1: szMiscArray = "Name\tKills";
  707. case 2: szMiscArray = "Name\tTime";
  708. case 3: szMiscArray = "Name\tTime";
  709. }
  710. while(iCount < iRows) {
  711. cache_get_value_name(iCount, "name", szTempName);
  712. cache_get_value_name_int(iCount, "num", iNumb);
  713. switch(iScoreType) {
  714. case 0, 1: format(szMiscArray, sizeof(szMiscArray), "%s\n%s\t%d", szMiscArray, szTempName, iNumb);
  715. case 2, 3: format(szMiscArray, sizeof(szMiscArray), "%s\n%s\t%s", szMiscArray, szTempName, ConvertTimeS(iNumb));
  716. }
  717. iCount++;
  718. }
  719. switch(iScoreType) {
  720. case 0, 2: ShowPlayerDialogEx(iPlayerID, DIALOG_NOTHING, DIALOG_STYLE_TABLIST_HEADERS, "Survivor Scoreboard", szMiscArray, "Close", "");
  721. case 1, 3: ShowPlayerDialogEx(iPlayerID, DIALOG_NOTHING, DIALOG_STYLE_TABLIST_HEADERS, "Zombie Scoreboard", szMiscArray, "Close", "");
  722. }
  723. return 1;
  724. }
  725. SaveZombieStats(i) {
  726. new iSSurvive = GetPVarInt(i, "iSAliveTick");
  727. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "INSERT INTO `humansurvivor` (`id`,`name`,`num`) VALUES ('%d', '%s', '%d') ON DUPLICATE KEY UPDATE `num` = `num` + '%d'", PlayerInfo[i][pId], GetPlayerNameEx(i), iSSurvive, iSSurvive);
  728. mysql_tquery(MainPipeline, szMiscArray, "OnSaveZombieStats", "ii", i, 0);
  729. }
  730. forward OnSaveZombieStats(iPlayerID, iStage);
  731. public OnSaveZombieStats(iPlayerID, iStage) {
  732. switch(iStage) {
  733. case 0: {
  734. new iZSurvive = GetPVarInt(iPlayerID, "iZAliveTick");
  735. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "INSERT INTO `zombiesurvivor` (`id`,`name`,`num`) VALUES ('%d', '%s', '%d') ON DUPLICATE KEY UPDATE `num` = `num` + '%d'", PlayerInfo[iPlayerID][pId], GetPlayerNameEx(iPlayerID), iZSurvive, iZSurvive);
  736. mysql_tquery(MainPipeline, szMiscArray, "OnSaveZombieStats", "ii", iPlayerID, 1);
  737. }
  738. case 1: {
  739. SetPVarInt(iPlayerID, "iSAliveTick", 0);
  740. SetPVarInt(iPlayerID, "iZAliveTick", 0);
  741. format(szMiscArray, sizeof(szMiscArray), "Saved zombie stats for %s (%d)", GetPlayerNameEx(iPlayerID), iPlayerID);
  742. print(szMiscArray);
  743. }
  744. }
  745. return 1;
  746. }
  747. hook OnPlayerConnect(playerid) {
  748. if(zombieevent) {
  749. DeletePVar(playerid, "iZAliveTick");
  750. DeletePVar(playerid, "iSAliveTick");
  751. }
  752. return 1;
  753. }
  754. hook OnPlayerDisconnect(playerid, reason) {
  755. if(zombieevent) SaveZombieStats(playerid);
  756. return 1;
  757. }
  758. ptask ZombieTick[1000](i) {
  759. if(zombieevent) {
  760. //if(PlayerInfo[i][pAdmin] >= 2) return 1;
  761. if(GetPVarType(i, "pIsZombie")) {
  762. new iZSurvive = GetPVarInt(i, "iZAliveTick");
  763. SetPVarInt(i, "iZAliveTick", iZSurvive+1);
  764. }
  765. if(!GetPVarType(i, "pIsZombie")) {
  766. new iSSurvive = GetPVarInt(i, "iSAliveTick");
  767. SetPVarInt(i, "iSAliveTick", iSSurvive+1);
  768. }
  769. }
  770. }