damage.pwn 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Damage System
  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. /*
  35. static Float:WeaponRange[] = {
  36. 10.0, // 0 - Fist
  37. 10.0, // 1 - Brass knuckles
  38. 10.0, // 2 - Golf club
  39. 10.0, // 3 - Nitestick
  40. 10.0, // 4 - Knife
  41. 10.0, // 5 - Bat
  42. 10.0, // 6 - Shovel
  43. 10.0, // 7 - Pool cue
  44. 10.0, // 8 - Katana
  45. 10.0, // 9 - Chainsaw
  46. 10.0, // 10 - Dildo
  47. 10.0, // 11 - Dildo 2
  48. 10.0, // 12 - Vibrator
  49. 10.0, // 13 - Vibrator 2
  50. 10.0, // 14 - Flowers
  51. 10.0, // 15 - Cane
  52. 40.0, // 16 - Grenade
  53. 40.0, // 17 - Teargas
  54. 40.0, // 18 - Molotov
  55. 90.0, // 19 - Vehicle M4 (custom)
  56. 75.0, // 20 - Vehicle minigun (custom)
  57. 0.0, // 21
  58. 35.0, // 22 - Colt 45
  59. 35.0, // 23 - Silenced
  60. 35.0, // 24 - Deagle
  61. 40.0, // 25 - Shotgun
  62. 35.0, // 26 - Sawed-off
  63. 40.0, // 27 - Spas
  64. 35.0, // 28 - UZI
  65. 45.0, // 29 - MP5
  66. 70.0, // 30 - AK47
  67. 90.0, // 31 - M4
  68. 35.0, // 32 - Tec9
  69. 100.0, // 33 - Cuntgun
  70. 320.0, // 34 - Sniper
  71. 55.0, // 35 - Rocket launcher
  72. 55.0, // 36 - Heatseeker
  73. 5.1, // 37 - Flamethrower
  74. 75.0 // 38 - Minigun
  75. };*/
  76. new HitStatus[MAX_PLAYERS];
  77. hook OnPlayerConnect(playerid) {
  78. HitStatus[playerid] = 0;
  79. return 1;
  80. }
  81. hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  82. if((newkeys & KEY_SPRINT) || (newkeys & KEY_SECONDARY_ATTACK)) {
  83. if(IsDoingAnim[playerid]) ClearAnimationsEx(playerid);
  84. }
  85. return 1;
  86. }
  87. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) {
  88. new string[128];
  89. //SendClientMessageEx(playerid, COLOR_WHITE, "Weapon %i fired. hittype: %i hitid: %i pos: %f, %f, %f", weaponid, hittype, hitid, fX, fY, fZ);
  90. if(GhostHacker[playerid][5] < gettime()) {
  91. GhostHacker[playerid][3] = 0;
  92. GhostHacker[playerid][5] = gettime()+9;
  93. }
  94. if(playerid != INVALID_PLAYER_ID) {
  95. if(GetPVarInt(playerid, "EventToken") == 0 && !GetPVarType(playerid, "IsInArena")) {
  96. if(weaponid > 0 && GetPlayerWeapon(playerid) == weaponid) {
  97. if(PlayerInfo[playerid][pGuns][GetWeaponSlot(weaponid)] != weaponid) {
  98. ExecuteHackerAction(playerid, weaponid);
  99. RemovePlayerWeapon(playerid, weaponid);
  100. return 0;
  101. }
  102. }
  103. }
  104. if(hittype == BULLET_HIT_TYPE_PLAYER) {
  105. if(hitid != INVALID_PLAYER_ID) {
  106. if(weaponid != 9 || weaponid != 37 || weaponid != 38 || weaponid != 41 || weaponid != 42) {
  107. //if(GetPVarInt(playerid, "EventToken") == 0 && !GetPVarType(playerid, "IsInArena")) {
  108. GhostHacker[playerid][2]++;
  109. if(!GhostHacker[playerid][4]) {
  110. GhostHacker[playerid][4] = 1;
  111. SetTimerEx("CheckBulletAmount", 1000, 0, "ii", playerid);
  112. }
  113. //}
  114. }
  115. }
  116. }
  117. if(weaponid == WEAPON_SILENCED && pTazer{playerid} == 1) {
  118. new iShots = GetPVarInt(playerid, "TazerShots");
  119. if(iShots > 0) {
  120. SetPVarInt(playerid, "TazerShots", iShots - 1);
  121. }
  122. if(iShots < 1) {
  123. TazerTimeout[playerid] = 12;
  124. SetTimerEx("TazerTimer",1000,false,"d",playerid);
  125. SendClientMessageEx(playerid, COLOR_WHITE, "Your tazer is recharging!");
  126. RemovePlayerWeapon(playerid, 23);
  127. GivePlayerValidWeapon(playerid, pTazerReplace{playerid});
  128. format(szMiscArray, sizeof(szMiscArray), "* %s holsters their tazer.", GetPlayerNameEx(playerid));
  129. ProxDetector(4.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  130. pTazer{playerid} = 0;
  131. }
  132. }
  133. }
  134. /*
  135. if(GetPVarInt(playerid, "FireStart") == 1) {
  136. if(fX != 0 && fY != 0 && hittype != BULLET_HIT_TYPE_PLAYER && hittype != BULLET_HIT_TYPE_VEHICLE) {
  137. if(gettime() > GetPVarInt(playerid, "fCooldown")) CreateStructureFire(fX, fY, fZ, GetPlayerVirtualWorld(playerid));
  138. }
  139. }
  140. */
  141. if(hittype != BULLET_HIT_TYPE_NONE ) // Bullet Crashing uses just this hittype
  142. {
  143. if(!(-1000.0 <= fX <= 1000.0) || !(-1000.0 <= fY <= 1000.0) || !(-1000.0 <= fZ <= 1000.0)) // a valid offset, it's impossible that a offset bigger than 1000 is legit (also less than -1000.0 is impossible, not used by this hack, but still, let's check for it, just for the future, who knows what hacks will appear). The object with biggest offset is having ~700-800 radius.
  144. {
  145. format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s was kicked for a possiable invalid hit type!", GetPlayerNameEx(playerid));
  146. ABroadCast(COLOR_YELLOW, string, 2);
  147. Kick(playerid);
  148. Log("logs/bulletcrasher.log", string);
  149. return 0; // let's desynchronize that bullet, so players won't crash
  150. }
  151. }
  152. return 1;
  153. }
  154. forward CheckBulletAmount(playerid);
  155. public CheckBulletAmount(playerid) {
  156. new szMessage[128];
  157. if(GhostHacker[playerid][2] > 8) {
  158. if(++GhostHacker[playerid][3] > 2) {
  159. format(szMessage, sizeof(szMessage), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) may possibly be using aim assist.", GetPlayerNameEx(playerid), playerid);
  160. ABroadCast(COLOR_YELLOW, szMessage, 2);
  161. }
  162. }
  163. GhostHacker[playerid][2] = 0;
  164. GhostHacker[playerid][4] = 0;
  165. return 1;
  166. }
  167. // Required as aiming with a single weapon wont update the anim index so we need to force clear.
  168. stock IsAimingColt(playerid) {
  169. if(GetPlayerCameraMode(playerid) == 53) {
  170. if(GetPlayerWeapon(playerid) == 22 || GetPlayerWeapon(playerid) == 26 || GetPlayerWeapon(playerid) == 28 || GetPlayerWeapon(playerid) == 32) {
  171. return 1;
  172. }
  173. }
  174. return 0;
  175. }
  176. stock IsInvalidGunAnim(playerid)
  177. {
  178. switch(GetPlayerAnimationIndex(playerid))
  179. {
  180. case
  181. 320,
  182. 471,
  183. 1164,
  184. 1183,
  185. 1188,
  186. 1189, // PED: IDLE_STANCE
  187. 1196, // PED: JUMP_LAND
  188. 1198, // PED: JUMP_LAUNCH_R
  189. 1223, // PED: RUN_ARMED
  190. 1231, // PED: RUN_PLAYER
  191. 1197, // PED: JUMP_LAUNCH
  192. 1195, // PED: JUMP_GLIDE
  193. 1266, // PED: WALK_PLAYER
  194. 1246, // PED: SPRINT_CIVI
  195. 1066, // PED: PED CLIMB_STAND
  196. 1067, // PED: CLIMB_STAND_FINISH
  197. 224, // BUDDY: BUDDY_RELOAD
  198. 1234, // PED: RUN_STOP
  199. 1132, // PED: FALL_GLIDE
  200. 1133, // PED: FALL_LAND
  201. 1130, // PED: FALL_FALL
  202. 1129, // PED: PED FALL_COLLAPSE
  203. 1207, // PED: KO_SHOT_STOM
  204. 1274, // PED: WEAPON_CROUCH
  205. 1235, // PED: RUN_STOPR
  206. 1233, // PED: RUN_ROCKET
  207. 1225, // PED: RUN_CSAW
  208. 1062, // PED: CLIMB_JUMP
  209. 1065, // PED: CLIMB_PULL
  210. 1159, // PED: GUNCROUCHFWD
  211. 1269, // PED: WALK_START
  212. 1180, // PED: HIT_WALL
  213. 1069, // PED: CROUCH_ROLL_L
  214. 1070: // PED: CROUCH_ROLL_R
  215. return 1;
  216. }
  217. return 0;
  218. }
  219. public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
  220. {
  221. szMiscArray[0] = 0;
  222. if(gPlayerLogged{playerid} == 0) {
  223. format(szMiscArray, sizeof(szMiscArray), "%s(%d) [%s] has moved from the login screen position.", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid));
  224. Log("logs/security.log", szMiscArray);
  225. SendClientMessage(playerid, COLOR_WHITE, "SERVER: You attempted to deal damage to someone when not logged in.");
  226. SetTimerEx("KickEx", 1000, 0, "i", playerid);
  227. return 1;
  228. }
  229. if((0 <= bodypart < 2)) return 1;
  230. if(IsAimingColt(playerid) && IsInvalidGunAnim(playerid)) {
  231. ClearAnimations(playerid, 1);
  232. return 1;
  233. }
  234. /*
  235. new animlib[32];
  236. new animname[32];
  237. GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
  238. if(!IsInvalidGunAnim(playerid)) SendClientMessageEx(playerid, COLOR_WHITE, "Anim: %d | Name: %s %s", GetPlayerAnimationIndex(playerid), animlib, animname);*/
  239. if(PlayerIsDead[damagedid]) return 1;
  240. //if(!HitStatus[damagedid]) return 1;
  241. new Float:realdam = amount;
  242. if(damagedid != INVALID_PLAYER_ID && playerid != INVALID_PLAYER_ID) {
  243. if(GhostHacker[playerid][0] > 0 && GhostHacker[playerid][6] < gettime()) GhostHacker[playerid][6] = gettime()+6, GhostHacker[playerid][0] = 0;
  244. if(IsPlayerPaused(playerid) || IsDoingAnim[playerid] || IsInvalidGunAnim(playerid)) {
  245. if(GhostHacker[playerid][1] < gettime()) {
  246. if(++GhostHacker[playerid][0] > 1) {
  247. format(szMiscArray, sizeof(szMiscArray), "{AA3333}AdmWarning{FFFF00}: %s may possibly be Ghost Hacking, damage was denied.", GetPlayerNameEx(playerid));
  248. ABroadCast(COLOR_YELLOW, szMiscArray, 2);
  249. GhostHacker[playerid][1] = gettime()+3;
  250. format(szMiscArray, sizeof(szMiscArray), "%s may possibly be Ghost Hacking.", GetPlayerNameEx(playerid));
  251. Log("logs/hack.log", szMiscArray);
  252. }
  253. }
  254. foreach(Player, i)
  255. {
  256. if(IsPlayerConnected(i))
  257. {
  258. if(PlayerInfo[i][pAdmin] >= 2 && GetPVarType(i, "_dCheck") && GetPVarInt(i, "_dCheck") == playerid) {
  259. format(szMiscArray, sizeof(szMiscArray), "[Dmgcheck] %s: Dmgd: %s (%d) | Wp: %s | CSDmg: %.2f | SSDmg: Denied | %s (GIVE)", GetPlayerNameEx(playerid), GetPlayerNameEx(damagedid), damagedid, GetWeaponNameEx(weaponid), amount, ReturnBoneName(bodypart));
  260. SendClientMessageEx(i, COLOR_WHITE, szMiscArray);
  261. }
  262. }
  263. }
  264. return 1;
  265. }
  266. if(amount < 0.0) amount = 0.0;
  267. if(amount > 150.0) amount = 150.0;
  268. // First define our base damage.
  269. switch(weaponid)
  270. {
  271. case 0 .. 3, 5 .. 8, 10 .. 15, 28, 32: if(amount > 20.0) amount = 20.0;
  272. case 4: if(amount > 150.0) amount = 150.0;
  273. case 9: if(amount > 30.0) amount = 30.0;
  274. case 23: if(amount > 14.0) amount = 14.0;
  275. case 24, 38: if(amount > 47.0) amount = 47.0;
  276. case 25, 26: if(amount > 50.0) amount = 50.0;
  277. case 27: if(amount > 40.0) amount = 40.0;
  278. case 22, 29: if(amount > 9.0) amount = 9.0;
  279. case 30, 31: if(amount > 10.0) amount = 10.0;
  280. case 33: if(amount > 25.0) amount = 25.0;
  281. case 34: if(amount > 42.0) amount = 42.0;
  282. case 37, 42: if(amount > 3.0) amount = 3.0;
  283. case 41: amount = 0.0;
  284. default: if(amount > 20.0) amount = 20.0; // If there is no gun defined fall onto this (Should stop hacks going out of the 32-bit range)
  285. }
  286. if(GetPlayerCameraMode(playerid) == 55 && amount > 9.0) amount = 9.0;
  287. if(weaponid == WEAPON_COLT45 || weaponid == WEAPON_SILENCED || weaponid == WEAPON_AK47)
  288. {
  289. amount *= 1.65;
  290. }
  291. /*if(weaponid == WEAPON_SNIPER)
  292. {
  293. amount *= 1.30;
  294. }*/
  295. //heroin damage reduction
  296. if (GetPVarInt(damagedid, "HeroinDamageResist") == 1) {
  297. amount *= 0.45;
  298. }
  299. new Float:difference,
  300. Float:health,
  301. Float:armour;
  302. GetHealth(damagedid, health);
  303. GetArmour(damagedid, armour);
  304. // Ignore godmode. - Admins / Advisors (for health only)
  305. if(!GetPVarInt(damagedid, "pGodMode") && !GetPVarInt(damagedid, "eventStaff")) {
  306. if(health < 0.1) SetHealth(damagedid, 0.1), GetHealth(damagedid, health); // just set to this as they'll be killed either way.
  307. if(health > 150.0) SetHealth(damagedid, 150.0), GetHealth(damagedid, health);
  308. if(armour < 0.0) SetArmour(damagedid, 0.0), GetArmour(damagedid, armour);
  309. if(armour > 150.0) SetArmour(damagedid, 150.0), GetArmour(damagedid, armour);
  310. }
  311. if(!IsPlayerStreamedIn(playerid, damagedid) || !IsPlayerStreamedIn(damagedid, playerid)) return 1;
  312. /*
  313. new Float:fOriginX, Float:fOriginY, Float:fOriginZ, Float:fHitPosX, Float:fHitPosY, Float:fHitPosZ,
  314. Float:x, Float:y, Float:z;
  315. GetPlayerPos(playerid, x, y, z);
  316. GetPlayerLastShotVectors(playerid, fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
  317. new Float:fDistance = VectorSize(fOriginX - fHitPosX, fOriginY - fHitPosY, fOriginZ - fHitPosZ),
  318. Float:origin_dist = VectorSize(fOriginX - x, fOriginY - y, fOriginZ - z);
  319. if(origin_dist > 15.0) {
  320. new iVehCheck = IsPlayerInAnyVehicle(damagedid) || GetPlayerSurfingVehicleID(playerid);
  321. if((!iVehCheck && GetPlayerSurfingVehicleID(playerid) == INVALID_VEHICLE_ID) || origin_dist > 50.0) {
  322. return 1;
  323. }
  324. }
  325. if(fDistance > WeaponRange[weaponid]) return 1;
  326. new Float:fHitDist = GetPlayerDistanceFromPoint(damagedid, fHitPosX, fHitPosY, fHitPosZ),
  327. iVehCheck = IsPlayerInAnyVehicle(damagedid);
  328. if ((!iVehCheck && fHitDist > 20.0) || fHitDist > 50.0) return 1;*/
  329. new vehmodel = GetVehicleModel(GetPlayerVehicleID(playerid));
  330. if(GetPVarInt(playerid, "EventToken") == 0 && !GetPVarType(playerid, "IsInArena") && (vehmodel != 425 && vehmodel != 432 && vehmodel != 447 && vehmodel != 464 && vehmodel != 476 && vehmodel != 520) && GetWeaponSlot(weaponid) != -1)
  331. {
  332. if(PlayerInfo[playerid][pGuns][GetWeaponSlot(weaponid)] != weaponid)
  333. {
  334. if(gettime() > GetPVarInt(playerid, "NopeWepWarn"))
  335. {
  336. format(szMiscArray, sizeof(szMiscArray), "{AA3333}AdmWarning{FFFF00}: %s (ID: %d) has been denied issuing damage. Possible weapon hack: Server Weapon: %d | Used Weapon: %d", GetPlayerNameEx(playerid), playerid, PlayerInfo[playerid][pGuns][GetWeaponSlot(weaponid)], weaponid);
  337. ABroadCast(COLOR_YELLOW, szMiscArray, 2);
  338. format(szMiscArray, sizeof(szMiscArray), "%s (%d) has been denied issuing damage. Possible weapon hack: Server Weapon: %d | Used Weapon: %d", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), PlayerInfo[playerid][pGuns][GetWeaponSlot(weaponid)], weaponid);
  339. Log("logs/hack.log", szMiscArray);
  340. SetPVarInt(playerid, "NopeWepWarn", gettime()+60);
  341. }
  342. return 1;
  343. }
  344. if((PlayerInfo[playerid][pWRestricted] > 0 || PlayerInfo[playerid][pConnectHours] < 2) && (weaponid != 0 && weaponid != 46))
  345. {
  346. if(gettime() > GetPVarInt(playerid, "WepResWarn"))
  347. {
  348. format(szMiscArray, sizeof(szMiscArray), "{AA3333}AdmWarning{FFFF00}: %s (ID: %d) has been denied issuing damage while being weapon restricted. WeaponID: %d", GetPlayerNameEx(playerid), playerid, weaponid);
  349. ABroadCast(COLOR_YELLOW, szMiscArray, 2);
  350. format(szMiscArray, sizeof(szMiscArray), "%s (%d) has been denied issuing damage while being weapon restricted. WeaponID: %d", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), weaponid);
  351. Log("logs/hack.log", szMiscArray);
  352. SetPVarInt(playerid, "WepResWarn", gettime()+60);
  353. }
  354. return 1;
  355. }
  356. }
  357. if(PlayerInfo[playerid][pAccountRestricted] == 1 || PlayerInfo[damagedid][pAccountRestricted] == 1) return 1;
  358. if(PlayerInfo[playerid][pHospital] == 1 || PlayerInfo[damagedid][pHospital] == 1) return 1;
  359. if(GetPVarInt(damagedid, "PlayerCuffed") == 1) return 1;
  360. ShotPlayer[playerid][damagedid] = gettime();
  361. LastShot[damagedid] = gettime();
  362. aLastShot[damagedid] = playerid;
  363. aLastShotBone[damagedid] = bodypart;
  364. aLastShotWeapon[damagedid] = weaponid;
  365. if(zombieevent && GetPVarInt(playerid, "z50Cal") == 1 && PlayerInfo[playerid][mInventory][17] && (weaponid == WEAPON_SNIPER || weaponid == WEAPON_RIFLE))
  366. {
  367. if(bodypart == BODY_PART_HEAD && GetPVarInt(damagedid, "pIsZombie")) SetHealth(damagedid, 0);
  368. if(PlayerInfo[playerid][mInventory][17]) PlayerInfo[playerid][mInventory][17]--;
  369. DeletePVar(playerid, "z50Cal");
  370. }
  371. if(IsAHitman(playerid) && GetPVarInt(playerid, "ExecutionMode") == 1 && (weaponid == WEAPON_DEAGLE || weaponid == WEAPON_SNIPER || weaponid == WEAPON_COLT45 || weaponid == WEAPON_RIFLE || weaponid == WEAPON_SILENCED))
  372. {
  373. if(damagedid == GoChase[playerid] && bodypart == BODY_PART_HEAD)
  374. {
  375. SetPVarInt(playerid, "ExecutionMode", 0);
  376. SetPVarInt(playerid, "KillShotCooldown", gettime());
  377. SetHealth(damagedid, 0);
  378. OnPlayerDeath(damagedid, playerid, weaponid);
  379. return 1;
  380. }
  381. else
  382. {
  383. SetPVarInt(playerid, "ExecutionMode", 0);
  384. SendClientMessage(playerid, COLOR_RED, "You missed the target, wait 5 minutes before re-loading a HP Round.");
  385. SetPVarInt(playerid, "KillShotCooldown", gettime());
  386. }
  387. }
  388. if(pTazer{playerid} == 1)
  389. {
  390. if(weaponid != 23) {
  391. RemovePlayerWeapon(playerid, 23);
  392. GivePlayerValidWeapon(playerid, pTazerReplace{playerid});
  393. format(szMiscArray, sizeof(szMiscArray), "* %s holsters their tazer.", GetPlayerNameEx(playerid));
  394. ProxDetector(30.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  395. pTazer{playerid} = 0;
  396. return 1;
  397. }
  398. if(!ProxDetectorS(20.0, playerid, damagedid)) {
  399. format(szMiscArray, sizeof(szMiscArray), "* %s fires their tazer at %s, missing them.", GetPlayerNameEx(playerid), GetPlayerNameEx(damagedid));
  400. ProxDetector(30.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  401. return 1;
  402. }
  403. if(TazerTimeout[playerid] > 0 && !GetPVarType(damagedid, "IsFrozen")) return 1;
  404. if(GetPlayerState(damagedid) == PLAYER_STATE_ONFOOT && PlayerCuffed[damagedid] == 0 && PlayerInfo[playerid][pHasTazer] == 1)
  405. {
  406. if((PlayerInfo[damagedid][pAdmin] >= 2 || PlayerInfo[damagedid][pWatchdog] >= 2) && PlayerInfo[damagedid][pTogReports] != 1) return SendClientMessageEx(playerid, COLOR_GRAD2, "Admins can not be tazed!");
  407. if(HelpingNewbie[damagedid] != INVALID_PLAYER_ID) return SendClientMessageEx(playerid, COLOR_GRAD2, "You cannot taze an advisor while they are helping someone.");
  408. if(PlayerInfo[damagedid][pHospital] == 1) return SendClientMessageEx(playerid, COLOR_GRAD2, "Players in hospital cannot be tazed!");
  409. new newkeys, dir1, dir2;
  410. GetPlayerKeys(damagedid, newkeys, dir1, dir2);
  411. if(GetPlayerCameraMode(damagedid) == 53 || GetPlayerCameraMode(damagedid) == 7 || GetPlayerCameraMode(damagedid) == 8 || GetPlayerCameraMode(damagedid) == 51) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot taze players that are actively aiming.");
  412. //if(ActiveKey(KEY_HANDBRAKE) && (!IsNotAGun(GetPlayerWeapon(damagedid)))) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot taze players that are actively aiming.");
  413. //if(ActiveKey(KEY_FIRE) && (!IsNotAGun(GetPlayerWeapon(damagedid)))) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot taze players that are actively shooting.");
  414. #if defined zombiemode
  415. if(GetPVarInt(damagedid, "pIsZombie")) return SendClientMessageEx(playerid, COLOR_GRAD2, "Zombies can not be tazed!");
  416. #endif
  417. new Float:X, Float:Y, Float:Z;
  418. GetPlayerPos(playerid, X, Y, Z);
  419. format(szMiscArray, sizeof(szMiscArray), "* %s fires their tazer at %s, stunning them.", GetPlayerNameEx(playerid), GetPlayerNameEx(damagedid));
  420. ProxDetector(30.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  421. //GameTextForPlayer(damagedid, "~r~Tazed", 3500, 3);
  422. ClearAnimationsEx(damagedid);
  423. TogglePlayerControllable(damagedid, 0);
  424. ApplyAnimation(damagedid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
  425. PlayerPlaySound(damagedid, 1085, X, Y, Z);
  426. PlayerPlaySound(playerid, 1085, X, Y, Z);
  427. PlayerCuffed[damagedid] = 1;
  428. SetPVarInt(damagedid, "PlayerCuffed", 1);
  429. PlayerCuffedTime[damagedid] = 16;
  430. SetPVarInt(damagedid, "IsFrozen", 1);
  431. TazerTimeout[playerid] = 12;
  432. SetTimerEx("TazerTimer",1000,false,"d",playerid);
  433. PlayerTextDrawShow(damagedid, _vhudFlash[damagedid]);
  434. SetTimerEx("TurnOffFlash", 800, 0, "i", damagedid);
  435. if(GetPVarType(damagedid, "FixVehicleTimer")) KillTimer(GetPVarInt(damagedid, "FixVehicleTimer")), DeletePVar(damagedid, "FixVehicleTimer");
  436. GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~r~Tazer reloading... ~w~12", 1500,3);
  437. return 1;
  438. }
  439. }
  440. if(GetPlayerWeapon(playerid) == 25 && GetPVarType(playerid, "pBeanBag"))
  441. {
  442. if(GetPVarInt(damagedid, "pBagged") >= 1) return 0;
  443. else if(GetPlayerState(damagedid) == PLAYER_STATE_ONFOOT)
  444. {
  445. if(GetPlayerCameraMode(damagedid) == 53 || GetPlayerCameraMode(damagedid) == 7 || GetPlayerCameraMode(damagedid) == 8 || GetPlayerCameraMode(damagedid) == 51) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot bag players that are actively aiming.");
  446. if((PlayerInfo[damagedid][pAdmin] >= 2 || PlayerInfo[damagedid][pWatchdog] >= 2) && PlayerInfo[damagedid][pTogReports] != 1) return SendClientMessageEx(playerid, COLOR_GRAD2, "Admins can not be bagged!");
  447. if(HelpingNewbie[damagedid] != INVALID_PLAYER_ID) return SendClientMessageEx(playerid, COLOR_GRAD2, "You cannot bag an advisor while they are helping someone.");
  448. if(PlayerInfo[damagedid][pHospital] == 1) return SendClientMessageEx(playerid, COLOR_GRAD2, "Players in hospital cannot be bagged!");
  449. new Float:fHealth, Float:fArmour;
  450. GetHealth(damagedid, fHealth);
  451. GetArmour(damagedid, fArmour);
  452. SetHealth(damagedid, fHealth);
  453. SetArmour(damagedid, fArmour);
  454. ClearAnimationsEx(damagedid);
  455. TogglePlayerControllable(damagedid, FALSE);
  456. ApplyAnimation(damagedid,"PED","KO_shot_stom",4.1,0,1,1,1,1,1);
  457. SetTimerEx("_UnbeanbagTimer", 20000, false, "d", damagedid);
  458. SetPlayerDrunkLevel(damagedid, 10000);
  459. PlayerTextDrawShow(damagedid, _vhudFlash[damagedid]);
  460. SetPVarInt(damagedid, "IsFrozen", 1);
  461. SetTimerEx("TurnOffFlash", 5000, 0, "i", damagedid);
  462. SetPVarInt(damagedid, "pBagged", 1);
  463. GameTextForPlayer(damagedid, "~r~Bagged!", 7000, 3);
  464. format(szMiscArray, sizeof(szMiscArray), "* %s fires their beanbag shotgun at %s, stunning them.", GetPlayerNameEx(playerid), GetPlayerNameEx(damagedid));
  465. ProxDetector(30.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  466. if(GetPVarType(damagedid, "FixVehicleTimer")) KillTimer(GetPVarInt(damagedid, "FixVehicleTimer")), DeletePVar(damagedid, "FixVehicleTimer");
  467. return 1;
  468. }
  469. }
  470. if(pTazer{damagedid} == 1 && (!IsNotAGun(weaponid)))
  471. {
  472. RemovePlayerWeapon(damagedid, 23);
  473. GivePlayerValidWeapon(damagedid, pTazerReplace{damagedid});
  474. format(szMiscArray, sizeof(szMiscArray), "* %s holsters their tazer.", GetPlayerNameEx(damagedid));
  475. ProxDetector(4.0, damagedid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  476. pTazer{damagedid} = 0;
  477. SendClientMessageEx(damagedid, COLOR_WHITE, "Your tazer has been holstered as you have taken damage from bullets.");
  478. }
  479. // Apply Ending Result
  480. if(armour < 0.1)
  481. {
  482. difference = health - amount;
  483. if(difference < 0.1)
  484. {
  485. SetHealth(damagedid, 0.0);
  486. OnPlayerDeath(damagedid, playerid, weaponid);
  487. }
  488. else SetHealth(damagedid, difference);
  489. }
  490. else
  491. {
  492. difference = armour - amount;
  493. if(difference < 0.1)
  494. {
  495. SetArmour(damagedid, 0.0);
  496. health += difference;
  497. if(health < 0.1) {
  498. SetHealth(damagedid, 0.0);
  499. OnPlayerDeath(damagedid, playerid, weaponid);
  500. }
  501. else SetHealth(damagedid, health);
  502. }
  503. else SetArmour(damagedid, difference);
  504. }
  505. foreach(Player, i)
  506. {
  507. if(IsPlayerConnected(i))
  508. {
  509. if(PlayerInfo[i][pAdmin] >= 2 && GetPVarType(i, "_dCheck") && GetPVarInt(i, "_dCheck") == playerid) {
  510. format(szMiscArray, sizeof(szMiscArray), "[Dmgcheck] %s: Dmgd: %s (%d) | Wp: %s | CSDmg: %.2f | SSDmg: %.2f | %s (GIVE)", GetPlayerNameEx(playerid), GetPlayerNameEx(damagedid), damagedid, GetWeaponNameEx(weaponid), realdam, amount, ReturnBoneName(bodypart));
  511. SendClientMessageEx(i, COLOR_WHITE, szMiscArray);
  512. }
  513. }
  514. }
  515. }
  516. return 1;
  517. }
  518. timer DeathScreen[4000](playerid) {
  519. if(!GetPVarType(playerid, "InjuredTL")) return 1;
  520. new Float:fPos[3],
  521. iObjectID;
  522. GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);
  523. iObjectID = CreateObject(19300, fPos[0], fPos[1], fPos[2], 0.0, 0.0, 0.0);
  524. SetPVarInt(playerid, "DS_OBJ", iObjectID);
  525. MoveObject(iObjectID, fPos[0], fPos[1], fPos[2] + 3.0, 1.0, 1.0, 0.0, 0.0);
  526. AttachCameraToObject(playerid, iObjectID);
  527. // ApplyAnimation(playerid, "WUZI", "CS_Dead_Guy", 4.1, 1, 1, 1, 1, 0, 1);
  528. return 1;
  529. }
  530. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
  531. {
  532. szMiscArray[0] = 0;
  533. if((0 <= bodypart < 2)) return 1;
  534. if(PlayerIsDead[playerid]) return 1;
  535. new Float:realdam = amount;
  536. if(playerid != 65535)
  537. {
  538. if(amount < 0.0) amount = 0.0;
  539. if(amount > 150.0) amount = 150.0;
  540. switch(weaponid)
  541. {
  542. // Take into account drug effects (needs to be 150 for fall damage etc..)
  543. case 50: { ClearAnimationsEx(playerid); if(amount > 150.0) amount = 150.0; }
  544. case 41: amount = 0.0;
  545. default: if(amount > 150.0) amount = 150.0;
  546. }
  547. //heroin damage reduction
  548. if (GetPVarInt(playerid, "HeroinDamageResist") == 1) {
  549. amount *= 0.45;
  550. }
  551. new Float:difference,
  552. Float:health,
  553. Float:armour;
  554. GetHealth(playerid, health);
  555. GetArmour(playerid, armour);
  556. // Ignore godmode. - Admins / Advisors (for health only)
  557. if(!GetPVarInt(playerid, "pGodMode") && !GetPVarInt(playerid, "eventStaff")) {
  558. if(health < 0.1) SetHealth(playerid, 0.1), GetHealth(playerid, health);
  559. if(health > 150.0) SetHealth(playerid, 150.0), GetHealth(playerid, health);
  560. if(armour < 0.0) SetArmour(playerid, 0.0), GetArmour(playerid, armour);
  561. if(armour > 150.0) SetArmour(playerid, 150.0), GetArmour(playerid, armour);
  562. }
  563. if(PlayerInfo[playerid][pHospital] == 1) return 1;
  564. if(GetPVarInt(playerid, "PlayerCuffed") == 1) return 1;
  565. if(weaponid == WEAPON_COLLISION && (1061 <= GetPlayerAnimationIndex(playerid) <= 1067)) // Climb Bug
  566. {
  567. new Float:hp;
  568. ClearAnimationsEx(playerid);
  569. GetHealth(playerid, hp);
  570. SetHealth(playerid, hp);
  571. return 1;
  572. }
  573. if(issuerid != 65535) {
  574. if(IsPlayerPaused(issuerid)) return 1;
  575. /*
  576. if(GhostHacker[issuerid][0] > 0 && GhostHacker[issuerid][6] < gettime()) GhostHacker[issuerid][6] = gettime()+6, GhostHacker[issuerid][0] = 0;
  577. if(IsPlayerPaused(issuerid) || IsDoingAnim[issuerid] || IsInvalidGunAnim(issuerid)) {
  578. if(GhostHacker[issuerid][1] < gettime()) {
  579. if(++GhostHacker[issuerid][0] > 1) {
  580. format(szMiscArray, sizeof(szMiscArray), "{AA3333}AdmWarning{FFFF00}: %s may possibly be Ghost Hacking, damage was denied.", GetPlayerNameEx(issuerid));
  581. ABroadCast(COLOR_YELLOW, szMiscArray, 2);
  582. GhostHacker[issuerid][1] = gettime()+3;
  583. format(szMiscArray, sizeof(szMiscArray), "%s may possibly be Ghost Hacking.", GetPlayerNameEx(issuerid));
  584. Log("logs/hack.log", szMiscArray);
  585. }
  586. }
  587. foreach(Player, i)
  588. {
  589. if(IsPlayerConnected(i))
  590. {
  591. if(PlayerInfo[i][pAdmin] >= 2 && GetPVarType(i, "_dCheck") && GetPVarInt(i, "_dCheck") == playerid) {
  592. format(szMiscArray, sizeof(szMiscArray), "[Dmgcheck] %s: Issuer: %s (%d) | Wp: %s (%d) | CSDmg: %.2f | SSDmg: Denied | %s (TAKE)", GetPlayerNameEx(playerid), GetPlayerNameEx(issuerid), issuerid, GetWeaponNameEx(weaponid), weaponid, amount, ReturnBoneName(bodypart));
  593. SendClientMessageEx(i, COLOR_WHITE, szMiscArray);
  594. }
  595. }
  596. }
  597. return 1;
  598. }*/
  599. if(GetPVarInt(playerid, "AttemptingLockPick") == 1) {
  600. DeletePVar(playerid, "AttemptingLockPick");
  601. DeletePVar(playerid, "LockPickCountdown");
  602. DeletePVar(playerid, "LockPickTotalTime");
  603. DeletePVar(playerid, "LockPickPosX");
  604. DeletePVar(playerid, "LockPickPosY");
  605. DeletePVar(playerid, "LockPickPosZ");
  606. DeletePVar(playerid, "LockPickPosZ");
  607. DestroyVLPTextDraws(playerid);
  608. if(GetPVarType(playerid, "LockPickVehicleSQLId")) {
  609. DeletePVar(playerid, "LockPickVehicleSQLId");
  610. DeletePVar(playerid, "LockPickPlayerSQLId");
  611. DeletePVar(playerid, "LockPickPlayerName");
  612. DestroyVehicle(GetPVarInt(playerid, "LockPickVehicle"));
  613. }
  614. else {
  615. new slot = GetPlayerVehicle(GetPVarInt(playerid, "LockPickPlayer"), GetPVarInt(playerid, "LockPickVehicle"));
  616. PlayerVehicleInfo[GetPVarInt(playerid, "LockPickPlayer")][slot][pvBeingPickLocked] = 0;
  617. PlayerVehicleInfo[GetPVarInt(playerid, "LockPickPlayer")][slot][pvBeingPickLockedBy] = INVALID_PLAYER_ID;
  618. }
  619. DeletePVar(playerid, "LockPickVehicle");
  620. DeletePVar(playerid, "LockPickPlayer");
  621. format(szMiscArray, sizeof(szMiscArray), "(( You took damage from %s(%d) using %s.))", GetPlayerNameEx(issuerid), issuerid, GetWeaponNameEx(weaponid));
  622. SendClientMessageEx(playerid, COLOR_RED, "(( You failed to pick lock this vehicle because you took damage. ))");
  623. SendClientMessageEx(playerid, COLOR_RED, szMiscArray);
  624. SendClientMessageEx(playerid, COLOR_RED, "(( If this was DM, visit ng-gaming.net and make a Player Complaint. ))");
  625. ClearAnimationsEx(playerid, 1);
  626. }
  627. if(GetPVarType(playerid, "AttemptingCrackTrunk")) {
  628. DeletePVar(playerid, "AttemptingCrackTrunk");
  629. DeletePVar(playerid, "CrackTrunkCountdown");
  630. DestroyVLPTextDraws(playerid);
  631. ClearAnimationsEx(playerid, 1);
  632. format(szMiscArray, sizeof(szMiscArray), "(( You took damage from %s(%d) using %s.))", GetPlayerNameEx(issuerid), issuerid, GetWeaponNameEx(weaponid));
  633. SendClientMessageEx(playerid, COLOR_RED, "(( You failed to crack this vehicle's trunk because you took damage. ))");
  634. SendClientMessageEx(playerid, COLOR_RED, szMiscArray);
  635. SendClientMessageEx(playerid, COLOR_RED, "(( If this was DM, visit ng-gaming.net and make a Player Complaint. ))");
  636. }
  637. if(GetPVarInt(playerid, "commitSuicide") == 1) SetPVarInt(playerid, "commitSuicide", 0);
  638. if(GetPVarInt(playerid, "BackpackProt") == 1)
  639. {
  640. DeletePVar(playerid, "BackpackProt");
  641. if(GetPVarInt(playerid, "BackpackOpen") == 1)
  642. {
  643. SendClientMessageEx(playerid, COLOR_RED, "You have taken damage during the backpack menu, your backpack is disabled for 3 minutes.");
  644. ShowPlayerDialogEx(playerid, -1, 0, "", "", "", "");
  645. SetPVarInt(playerid, "BackpackDisabled", 180);
  646. DeletePVar(playerid, "BackpackOpen");
  647. }
  648. }
  649. if(GetPVarInt(playerid, "BackpackMedKit") == 1) DeletePVar(playerid, "BackpackMedKit");
  650. if(GetPVarInt(playerid, "BackpackMeal") == 1) DeletePVar(playerid, "BackpackMeal");
  651. }
  652. /*
  653. 51 - Explosion
  654. 38 - Hunter Minigun
  655. 47 - Fake Pistol
  656. 37 - Flamethrower
  657. 49 - Car Ramming
  658. 50 - Heliblade
  659. 31 - Seasparrow minigun (M4)
  660. 54 - Splat
  661. */
  662. if(issuerid == 65535) {
  663. difference = health - amount;
  664. if(difference < 0.1)
  665. {
  666. SetHealth(playerid, 0.0);
  667. OnPlayerDeath(playerid, issuerid, weaponid);
  668. }
  669. else SetHealth(playerid, difference);
  670. }
  671. if(issuerid != 65535 && (weaponid == 51 || weaponid == 38 || weaponid == 47 || weaponid == 37 || weaponid == 49 || GetVehicleModel(GetPlayerVehicleID(issuerid)) == 447 && weaponid == 31)) {
  672. if(armour < 0.1)
  673. {
  674. difference = health - amount;
  675. if(difference < 0.1)
  676. {
  677. SetHealth(playerid, 0.0);
  678. OnPlayerDeath(playerid, issuerid, weaponid);
  679. }
  680. else SetHealth(playerid, difference);
  681. }
  682. else
  683. {
  684. difference = armour - amount;
  685. if(difference < 0.1)
  686. {
  687. SetArmour(playerid, 0.0);
  688. health += difference;
  689. if(health < 0.1) {
  690. SetHealth(playerid, 0.0);
  691. OnPlayerDeath(playerid, issuerid, weaponid);
  692. }
  693. else SetHealth(playerid, health);
  694. }
  695. else SetArmour(playerid, difference);
  696. }
  697. }
  698. foreach(Player, i)
  699. {
  700. if(IsPlayerConnected(i))
  701. {
  702. if(PlayerInfo[i][pAdmin] >= 2 && GetPVarType(i, "_dCheck") && GetPVarInt(i, "_dCheck") == playerid) {
  703. format(szMiscArray, sizeof(szMiscArray), "[Dmgcheck] %s: Issuer: %s (%d) | Wp: %s (%d) | CSDmg: %.2f | SSDmg: %.2f | %s (TAKE)", GetPlayerNameEx(playerid), GetPlayerNameEx(issuerid), issuerid, GetWeaponNameEx(weaponid), weaponid, realdam, amount, ReturnBoneName(bodypart));
  704. SendClientMessageEx(i, COLOR_WHITE, szMiscArray);
  705. }
  706. }
  707. }
  708. }
  709. return 1;
  710. }
  711. /*
  712. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  713. {
  714. return 1;
  715. }
  716. */
  717. public OnPlayerDeath(playerid, killerid, reason)
  718. {
  719. if(IsPlayerNPC(playerid)) return 1;
  720. // if(GetPVarType(playerid, "pTut")) return 1;
  721. if(PlayerIsDead[playerid]) return 1;
  722. PlayerIsDead[playerid] = true;
  723. IsSpawned[playerid] = 0;
  724. SpawnKick[playerid] = 0;
  725. for(new x; x < MAX_PLAYERTOYS; x++)
  726. {
  727. if(IsPlayerAttachedObjectSlotUsed(playerid, x))
  728. {
  729. if(x == 9 && PlayerInfo[playerid][pBEquipped])
  730. break;
  731. RemovePlayerAttachedObject(playerid, x);
  732. }
  733. }
  734. for(new i; i < 10; i++) PlayerHoldingObject[playerid][i] = 0;
  735. SetPVarInt(playerid, "Health", 0);
  736. if(GetPVarInt(playerid, "HeroinDamageResist") == 1) HeroinEffectStanding(playerid), KillTimer(GetPVarInt(playerid, "HeroinEffectStanding"));
  737. if(IsPlayerConnected(playerid) && IsPlayerConnected(killerid))
  738. {
  739. if(gPlayerUsingLoopingAnim[playerid])
  740. {
  741. gPlayerUsingLoopingAnim[playerid] = 0;
  742. TextDrawHideForPlayer(playerid,txtAnimHelper);
  743. }
  744. SetPVarInt(playerid, "PlayerOwnASurf", 0);
  745. #if defined zombiemode
  746. if(zombieevent == 1 && GetPVarType(playerid, "pIsZombie"))
  747. {
  748. new string[128];
  749. mysql_format(MainPipeline, string, sizeof(string), "INSERT INTO humankills (id, num, name) VALUES (%d,1, '%s') ON DUPLICATE KEY UPDATE num = num + 1", PlayerInfo[killerid][pId], GetPlayerNameEx(killerid));
  750. mysql_tquery(MainPipeline, string, "OnQueryFinish", "ii", SENDDATA_THREAD, killerid);
  751. }
  752. if(zombieevent == 1 && GetPVarType(playerid, "pIsZombie"))
  753. {
  754. new Float:mX, Float:mY, Float:mZ;
  755. GetPlayerPos(playerid, mX, mY, mZ);
  756. SetPVarFloat(playerid, "MedicX", mX);
  757. SetPVarFloat(playerid, "MedicY", mY);
  758. SetPVarFloat(playerid, "MedicZ", mZ);
  759. }
  760. #endif
  761. if(SpoofKill[playerid] == 0)
  762. KillTime[playerid] = gettime();
  763. SpoofKill[playerid]++;
  764. if(SpoofKill[playerid] >= 4)
  765. {
  766. if((gettime() - KillTime[playerid]) <= 2)
  767. {
  768. CreateBan(INVALID_PLAYER_ID, PlayerInfo[playerid][pId], playerid, PlayerInfo[playerid][pIP], "Kill-spoofing", 180);
  769. TotalAutoBan++;
  770. Kick(playerid);
  771. }
  772. else
  773. {
  774. SpoofKill[playerid] = 0;
  775. }
  776. }
  777. RemoveArmor(playerid);
  778. PlayerInfo[playerid][pHolsteredWeapon] = 0;
  779. if (GetPVarInt(playerid, "_SwimmingActivity") >= 1)
  780. {
  781. DisablePlayerCheckpoint(playerid);
  782. DeletePVar(playerid, "_SwimmingActivity");
  783. }
  784. if (GetPVarInt(playerid, "_BoxingQueue") == 1)
  785. {
  786. DeletePVar(playerid, "_BoxingQueue");
  787. }
  788. if (GetPVarInt(playerid, "_BoxingFight") != 0)
  789. {
  790. new winner = GetPVarInt(playerid, "_BoxingFight") - 1;
  791. SendClientMessageEx(winner, COLOR_GREEN, "You have won the fight!");
  792. SendClientMessageEx(playerid, COLOR_RED, "You have lost the fight!");
  793. DeletePVar(winner, "_BoxingFight");
  794. DeletePVar(playerid, "_BoxingFight");
  795. new time = gettime();
  796. SetPVarInt(playerid, "_BoxingFightOver", time + 8);
  797. SetPVarInt(winner, "_BoxingFightOver", time + 1);
  798. }
  799. if(GetPVarInt(playerid, "_InJailBoxing") > 0)
  800. {
  801. new string[60 + MAX_PLAYER_NAME];
  802. if(killerid == GetPVarInt(playerid, "_JailBoxingChallenger"))
  803. {
  804. SendClientMessageEx(playerid, COLOR_WHITE, "You have lost the boxing fight. You may now leave the arena.");
  805. SendClientMessageEx(killerid, COLOR_WHITE, "You have won the boxing fight. You may now leave the arena.");
  806. format(string, sizeof(string), "** [Boxing News (Arena:%d)] %s has won! **", (GetPVarInt(playerid, "_InJailBoxing") - 1), GetPlayerNameEx(killerid));
  807. ProxDetector(10.0, playerid, string, 0xEB41000, 0xEB41000, 0xEB41000, 0xEB41000, 0xEB41000);
  808. arrJailBoxingData[GetPVarInt(playerid, "_InJailBoxing") - 1][bInProgress] = false;
  809. RemoveFromJailBoxing(playerid);
  810. RemoveFromJailBoxing(killerid);
  811. }
  812. else
  813. {
  814. arrJailBoxingData[GetPVarInt(playerid, "_InJailBoxing") - 1][bInProgress] = false;
  815. RemoveFromJailBoxing(playerid);
  816. RemoveFromJailBoxing(killerid);
  817. }
  818. }
  819. if(GetPVarInt(playerid, "_InJailBrawl") != 0)
  820. {
  821. if(killerid == GetPVarInt(playerid, "_InJailBrawl") - 1)
  822. {
  823. SendClientMessageEx(playerid, COLOR_WHITE, "You have lost the brawl.");
  824. SendClientMessageEx(killerid, COLOR_WHITE, "You have won the brawl.");
  825. }
  826. DeletePVar(playerid, "_InJailBrawl");
  827. DeletePVar(killerid, "_InJailBrawl");
  828. DeletePVar(GetPVarInt(playerid, "_InJailBrawl") - 1, "_InJailBrawl");
  829. }
  830. if (_vhudVisible[playerid] == 1)
  831. {
  832. HideVehicleHUDForPlayer(playerid); // incase vehicle despawns
  833. }
  834. if (CarRadars[playerid] > 0)
  835. {
  836. CarRadars[playerid] = 0;
  837. PlayerTextDrawHide(playerid, _crTextTarget[playerid]);
  838. PlayerTextDrawHide(playerid, _crTextSpeed[playerid]);
  839. PlayerTextDrawHide(playerid, _crTickets[playerid]);
  840. DeletePVar(playerid, "_lastTicketWarning");
  841. }
  842. if(GetPVarInt(playerid, "AttemptPurify"))
  843. {
  844. Purification[0] = 0;
  845. KillTimer(GetPVarInt(playerid, "AttemptPurify"));
  846. }
  847. if(GetPVarInt(playerid, "HeroinEffect"))
  848. {
  849. DeletePVar(playerid, "HeroinEffect");
  850. KillTimer(GetPVarInt(playerid, "HeroinEffect"));
  851. }
  852. if(GetPVarInt(playerid, "InjectHeroin"))
  853. {
  854. KillTimer(GetPVarInt(playerid, "InjectHeroin"));
  855. }
  856. new weaponname[32];
  857. GetWeaponName(reason, weaponname, sizeof(weaponname));
  858. new query[256];
  859. mysql_format(MainPipeline, query, sizeof(query), "INSERT INTO `kills` (`id`, `killerid`, `killedid`, `date`, `weapon`) VALUES (NULL, %d, %d, NOW(), '%e')", GetPlayerSQLId(killerid), GetPlayerSQLId(playerid), weaponname);
  860. PlayerKills[killerid]++;
  861. mysql_tquery(MainPipeline, query, "OnQueryFinish", "i", SENDDATA_THREAD);
  862. if(GetPVarType(killerid, "IsInArena")) PlayerInfo[killerid][pDMKills]++;
  863. if(GetPVarType(playerid, "FixVehicleTimer")) KillTimer(GetPVarInt(playerid, "FixVehicleTimer")), DeletePVar(playerid, "FixVehicleTimer");
  864. }
  865. TextDrawHideForPlayer(playerid, BFText);
  866. DeletePVar(playerid, "BlindFolded");
  867. pTazer{playerid} = 0;
  868. InsidePlane[playerid] = INVALID_VEHICLE_ID;
  869. DeletePVar(playerid, "SpeedRadar");
  870. DeletePVar(playerid, "UsingSprunk");
  871. KillTimer(GetPVarInt(playerid, "firstaid5"));
  872. DeletePVar(playerid, "usingfirstaid");
  873. if(GetPVarType(playerid, "MovingStretcher"))
  874. {
  875. KillTimer(GetPVarInt(playerid, "TickEMSMove"));
  876. DeletePVar(GetPVarInt(playerid, "MovingStretcher"), "OnStretcher");
  877. DeletePVar(playerid, "MovingStretcher");
  878. }
  879. if(GetPVarType(playerid, "DraggingPlayer"))
  880. {
  881. DeletePVar(GetPVarInt(playerid, "DraggingPlayer"), "BeingDragged");
  882. DeletePVar(playerid, "DraggingPlayer");
  883. }
  884. if(IsPlayerConnected(Mobile[playerid]))
  885. {
  886. new
  887. iCaller = Mobile[playerid],
  888. szMessage[64];
  889. SendClientMessageEx(iCaller, COLOR_GRAD2, "The line went dead.");
  890. format(szMessage, sizeof(szMessage), "* %s puts away their cellphone.", GetPlayerNameEx(iCaller));
  891. ProxDetector(30.0, iCaller, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  892. CellTime[iCaller] = 0;
  893. Mobile[iCaller] = INVALID_PLAYER_ID;
  894. RemovePlayerAttachedObject(Mobile[playerid], 8);
  895. }
  896. Mobile[playerid] = INVALID_PLAYER_ID;
  897. CellTime[playerid] = 0;
  898. RingTone[playerid] = 0;
  899. RemovePlayerAttachedObject(playerid, 8);
  900. if(GetPVarType(playerid, "SpecOff"))
  901. {
  902. SpawnPlayer(playerid);
  903. return 1;
  904. }
  905. if(GetPVarInt(playerid, "Injured") == 1)
  906. {
  907. foreach(new i: Player)
  908. {
  909. if(EMSAccepted[i] == playerid)
  910. {
  911. EMSAccepted[i] = INVALID_PLAYER_ID;
  912. GameTextForPlayer(i, "~w~EMS Caller~n~~r~Has Died", 5000, 1);
  913. EMSCallTime[i] = 0;
  914. DisablePlayerCheckpoint(i);
  915. }
  916. }
  917. SendClientMessageEx(playerid, COLOR_WHITE, "You appear to be stuck in limbo, medics are trying to revive you.");
  918. KillEMSQueue(playerid);
  919. ResetPlayerWeaponsEx(playerid);
  920. return 1;
  921. }
  922. if(GetPVarInt(playerid, "EventToken") == 0)
  923. {
  924. if(!GetPVarType(playerid, "IsInArena"))
  925. {
  926. if(HungerPlayerInfo[playerid][hgInEvent] != 1)
  927. {
  928. SetPVarInt(playerid, "Injured", 1);
  929. SetPVarInt(playerid, "InjuredWait", gettime()+5);
  930. new Float:mX, Float:mY, Float:mZ;
  931. GetPlayerPos(playerid, mX, mY, mZ);
  932. SetPVarFloat(playerid, "MedicX", mX);
  933. SetPVarFloat(playerid, "MedicY", mY);
  934. SetPVarFloat(playerid, "MedicZ", mZ);
  935. SetPVarInt(playerid, "MedicVW", GetPlayerVirtualWorld(playerid));
  936. SetPVarInt(playerid, "MedicInt", GetPlayerInterior(playerid));
  937. }
  938. }
  939. }
  940. if(GetPVarType(playerid, "IsInArena"))
  941. {
  942. new
  943. iPlayer = GetPVarInt(playerid, "IsInArena"),
  944. iKiller = GetPVarInt(killerid, "IsInArena"),
  945. szMessage[96];
  946. if(GetPVarInt(playerid, "AOSlotPaintballFlag") != -1)
  947. {
  948. switch(PlayerInfo[playerid][pPaintTeam])
  949. {
  950. case 1:
  951. {
  952. DropFlagPaintballArena(playerid, iPlayer, 2);
  953. }
  954. case 2:
  955. {
  956. DropFlagPaintballArena(playerid, iPlayer, 1);
  957. }
  958. }
  959. }
  960. if(reason >= 0 && reason <= 46)
  961. {
  962. new weapon[24];
  963. ++PlayerInfo[killerid][pKills];
  964. ++PlayerInfo[playerid][pDeaths];
  965. if(PlayerInfo[killerid][pPaintTeam] == 1)
  966. {
  967. if(PlayerInfo[killerid][pPaintTeam] == PlayerInfo[playerid][pPaintTeam])
  968. {
  969. --PaintBallArena[iKiller][pbTeamRedKills];
  970. ++PaintBallArena[iPlayer][pbTeamBlueKills];
  971. SetHealth(killerid, 0);
  972. PlayerInfo[killerid][pKills] -= 2;
  973. ++PlayerInfo[killerid][pDeaths];
  974. --PlayerInfo[playerid][pDeaths];
  975. SendClientMessageEx(killerid, COLOR_WHITE, "You have been warned, do not team-kill!");
  976. }
  977. else
  978. {
  979. ++PaintBallArena[iKiller][pbTeamRedKills];
  980. ++PaintBallArena[iPlayer][pbTeamBlueDeaths];
  981. }
  982. }
  983. if(PlayerInfo[killerid][pPaintTeam] == 2)
  984. {
  985. if(PlayerInfo[killerid][pPaintTeam] == PlayerInfo[playerid][pPaintTeam])
  986. {
  987. --PaintBallArena[iKiller][pbTeamBlueKills];
  988. ++PaintBallArena[iPlayer][pbTeamRedKills];
  989. SetHealth(killerid, 0);
  990. PlayerInfo[killerid][pKills] -= 2;
  991. ++PlayerInfo[killerid][pDeaths];
  992. --PlayerInfo[playerid][pDeaths];
  993. SendClientMessageEx(killerid, COLOR_WHITE, "You have been warned, do not team-kill!");
  994. }
  995. ++PaintBallArena[iKiller][pbTeamBlueKills];
  996. ++PaintBallArena[iPlayer][pbTeamRedDeaths];
  997. }
  998. GetWeaponName(reason,weapon,sizeof(weapon));
  999. if(PaintBallArena[iKiller][pbTimeLeft] < 12)
  1000. {
  1001. GivePlayerCash(killerid, 1000);
  1002. format(szMessage,sizeof(szMessage),"[Paintball Arena] %s has earned $1000 bonus for a sudden death kill!",GetPlayerNameEx(killerid));
  1003. SendPaintballArenaMessage(iKiller, COLOR_YELLOW, szMessage);
  1004. ////SendAudioToPlayer(killerid, 19, 100);
  1005. }
  1006. if(reason == 0) format(szMessage,sizeof(szMessage),"[Paintball Arena] %s has killed %s with their bare hands!",GetPlayerNameEx(killerid),GetPlayerNameEx(playerid));
  1007. else format(szMessage,sizeof(szMessage),"[Paintball Arena] %s has killed %s with a %s.",GetPlayerNameEx(killerid),GetPlayerNameEx(playerid),weapon);
  1008. }
  1009. else
  1010. {
  1011. ++PlayerInfo[playerid][pDeaths];
  1012. format(szMessage,sizeof(szMessage),"[Paintball Arena] %s has died.",GetPlayerNameEx(playerid));
  1013. }
  1014. SendPaintballArenaMessage(iPlayer, COLOR_RED, szMessage);
  1015. }
  1016. if(GetPVarInt(playerid, "Injured") == 0)
  1017. {
  1018. new arenaid = GetPVarInt(playerid, "IsInArena");
  1019. if(GetPVarInt(playerid, "EventToken") >= 1 || (arenaid >= 0 && (PaintBallArena[arenaid][pbGameType] < 4 || PaintBallArena[arenaid][pbGameType] > 5)))
  1020. {
  1021. DisablePlayerCheckpoint(playerid);
  1022. ResetPlayerWeapons(playerid);
  1023. }
  1024. else
  1025. {
  1026. ResetPlayerWeaponsEx(playerid);
  1027. }
  1028. }
  1029. if(IsPlayerConnected(killerid) && PlayerInfo[killerid][pAdmin] < 2 && GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
  1030. {
  1031. switch(reason)
  1032. {
  1033. case 49: {
  1034. new szMessage[128];
  1035. format(szMessage, sizeof(szMessage), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has possibly just car-rammed %s (ID %d) to death.", GetPlayerNameEx(killerid), killerid, GetPlayerNameEx(playerid), playerid);
  1036. ABroadCast(COLOR_YELLOW, szMessage, 2);
  1037. }
  1038. case 50: if(IsAHelicopter(GetPlayerVehicleID(killerid))) {
  1039. new szMessage[128];
  1040. format(szMessage, sizeof(szMessage), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has possibly just blade-killed %s (ID %d).", GetPlayerNameEx(killerid), killerid, GetPlayerNameEx(playerid), playerid);
  1041. ABroadCast(COLOR_YELLOW, szMessage, 2);
  1042. }
  1043. default: switch(GetPlayerWeapon(killerid)) {
  1044. case 32, 28, 29: {
  1045. new szMessage[128];
  1046. format(szMessage, sizeof(szMessage), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has possibly just driver-shot %s (ID %d) to death.", GetPlayerNameEx(killerid), killerid, GetPlayerNameEx(playerid), playerid);
  1047. ABroadCast(COLOR_YELLOW, szMessage, 2);
  1048. }
  1049. }
  1050. }
  1051. }
  1052. if (gPlayerCheckpointStatus[playerid] > 4 && gPlayerCheckpointStatus[playerid] < 11)
  1053. {
  1054. DisablePlayerCheckpoint(playerid);
  1055. gPlayerCheckpointStatus[playerid] = CHECKPOINT_NONE;
  1056. }
  1057. if(IsPlayerConnected(killerid))
  1058. {
  1059. if(PlayerInfo[playerid][pHeadValue] >= 1)
  1060. {
  1061. if(GoChase[killerid] == playerid) // && GetPVarInt(killerid, "HitCooldown") <= 0)
  1062. {
  1063. new szMessage[86 + MAX_PLAYER_NAME];
  1064. new takemoney = PlayerInfo[playerid][pHeadValue];//floatround((PlayerInfo[playerid][pHeadValue] / 4) * 2);
  1065. GivePlayerCash(killerid, floatround(takemoney * 0.9));
  1066. GivePlayerCash(playerid, -takemoney);
  1067. format(szMessage, sizeof(szMessage),"Hitman %s has fulfilled the contract on %s and collected $%d.",GetPlayerNameEx(killerid),GetPlayerNameEx(playerid),takemoney);
  1068. foreach(new i: Player) if(IsAHitman(i)) SendClientMessage(i, COLOR_YELLOW, szMessage);
  1069. format(szMessage, sizeof(szMessage),"You have been critically injured by a hitman and lost $%d.",takemoney);
  1070. PlayerInfo[playerid][pContractDetail][0] = 0;
  1071. ResetPlayerWeaponsEx(playerid);
  1072. SendClientMessageEx(playerid, COLOR_YELLOW, szMessage);
  1073. PlayerInfo[playerid][pHeadValue] = 0;
  1074. PlayerInfo[killerid][pCHits] += 1;
  1075. GotHit[playerid] = 0;
  1076. GetChased[playerid] = INVALID_PLAYER_ID;
  1077. GoChase[killerid] = INVALID_PLAYER_ID;
  1078. new weaponname[32];
  1079. GetWeaponName(reason, weaponname, sizeof(weaponname));
  1080. new iHitPercent = floatround(takemoney * 0.10);
  1081. iHMASafe_Val += iHitPercent;
  1082. format(szMiscArray, sizeof szMiscArray, "[hit] %s (%d) has killed %s (%d) [%s] for $%s ($%s deposited to safe).", GetPlayerNameEx(killerid), GetPlayerSQLId(killerid), GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), weaponname, number_format(takemoney), number_format(iHitPercent));
  1083. Log("logs/hitman.log", szMiscArray);
  1084. }
  1085. }
  1086. if(GoChase[playerid] == killerid)
  1087. {
  1088. new szMessage[86 + MAX_PLAYER_NAME];
  1089. new takemoney = PlayerInfo[killerid][pHeadValue]; //floatround((PlayerInfo[killerid][pHeadValue] / 4) * 2);
  1090. GivePlayerCash(killerid, takemoney);
  1091. format(szMessage, sizeof(szMessage),"Hitman %s has failed the contract on %s and lost $%s.", GetPlayerNameEx(playerid), GetPlayerNameEx(killerid), number_format(takemoney));
  1092. foreach(new i: Player) if(IsAHitman(i)) SendClientMessage(i, COLOR_YELLOW, szMessage);
  1093. GivePlayerCash(playerid, -takemoney);
  1094. format(szMessage, sizeof(szMessage),"You have just killed a hitman and gained $%s, removing the contract on your head.", number_format(takemoney));
  1095. PlayerInfo[killerid][pContractDetail][0] = 0;
  1096. SendClientMessageEx(killerid, COLOR_YELLOW, szMessage);
  1097. PlayerInfo[killerid][pHeadValue] = 0;
  1098. PlayerInfo[playerid][pFHits] += 1;
  1099. GotHit[playerid] = 0;
  1100. GetChased[killerid] = INVALID_PLAYER_ID;
  1101. GoChase[playerid] = INVALID_PLAYER_ID;
  1102. new weaponname[32], iGroupID = PlayerInfo[killerid][pMember];
  1103. GetWeaponName(reason, weaponname, sizeof(weaponname));
  1104. format(szMessage, sizeof szMessage, "[HMA] %s (%d) has has failed to kill %s (%d) with a %s.", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerNameEx(killerid), GetPlayerSQLId(killerid), weaponname);
  1105. GroupLog(iGroupID, szMessage);
  1106. }
  1107. }
  1108. SetPlayerColor(playerid,TEAM_HIT_COLOR);
  1109. if(IsValidDynamic3DTextLabel(RFLTeamN3D[playerid])) {
  1110. #if defined TEXTLABEL_DEBUG
  1111. Streamer_SetIntData(STREAMER_TYPE_3D_TEXT_LABEL, RFLTeamN3D[playerid], E_STREAMER_EXTRA_ID, 5);
  1112. #endif
  1113. DestroyDynamic3DTextLabel(RFLTeamN3D[playerid]);
  1114. RFLTeamN3D[playerid] = Text3D:-1;
  1115. }
  1116. if(PlayerTied[playerid]) {
  1117. DeletePVar(playerid, "IsFrozen");
  1118. TogglePlayerControllable(playerid, 1);
  1119. PlayerTied[playerid] = 0;
  1120. }
  1121. // SetPVarInt(playerid, "MedicAid", 1);
  1122. return 1;
  1123. }