Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.36 KB | None | 0 0
  1.  
  2. addEvent ( "damageWasDealt", true )
  3. addEvent ( "damageWasDealtOnWasted", true )
  4. addEvent ( "givepointsfordamagekills", true )
  5. addEvent ( "onRoundFinish", false )
  6. --addEvent ( "onPlayerWastedTriggered", true )
  7.  
  8.  
  9. local wvKills = { [0] = 0 }
  10. for i=1, 120 do
  11. wvKills[i] = wvKills[i-1] + i
  12. end
  13. local playerDamages = { ["standard"] = {}, ["gangwar"] = {} }
  14. local playerKills = { ["standard"] = {}, ["gangwar"] = {} }
  15. local playersGaveDamage = { ["standard"] = {} }
  16. local playersBecameDamage = { ["standard"] = {} }
  17. local weaponDamages = { ["standard"] = {
  18. [0] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
  19. [4] = { [3] = 10, [4] = 20, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 20 },
  20. [8] = { [3] = 35, [4] = 35, [5] = 35, [6] = 35, [7] = 35, [8] = 35, [9] = 35 },
  21. [9] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
  22. [16] = { [3] = 120, [4] = 120, [5] = 120, [6] = 120, [7] = 120, [8] = 120, [9] = 120 }, -- Nur halber Schaden wird genommen
  23. [17] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
  24. [18] = { [3] = 0.02, [4] = 0.02, [5] = 0.02, [6] = 0.02, [7] = 0.02, [8] = 0.02, [9] = 0.02 },
  25. [19] = { [3] = 200, [4] = 200, [5] = 200, [6] = 200, [7] = 200, [8] = 200, [9] = 200 }, -- Nur halber Schaden wird genommen
  26. [22] = { [3] = 8, [4] = 6, [5] = 7, [6] = 7, [7] = 7, [8] = 7, [9] = 12 },
  27. [23] = { [3] = 10, [4] = 9, [5] = 9, [6] = 9, [7] = 9, [8] = 9, [9] = 15 },
  28. [24] = { [3] = 40, [4] = 36, [5] = 36, [6] = 36, [7] = 36, [8] = 36, [9] = 80 },
  29. [25] = { [3] = 20, [4] = 14, [5] = 16, [6] = 16, [7] = 16, [8] = 16, [9] = 25 },
  30. [26] = { [3] = 30, [4] = 20, [5] = 20, [6] = 20, [7] = 20, [8] = 20, [9] = 40 },
  31. [27] = { [3] = 30, [4] = 20, [5] = 20, [6] = 20, [7] = 20, [8] = 20, [9] = 40 },
  32. [28] = { [3] = 8, [4] = 6, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 10 },
  33. [29] = { [3] = 10, [4] = 8, [5] = 9, [6] = 9, [7] = 9, [8] = 9, [9] = 14 },
  34. [30] = { [3] = 10, [4] = 7, [5] = 8, [6] = 8, [7] = 8, [8] = 8, [9] = 14 },
  35. [31] = { [3] = 9, [4] = 7, [5] = 8, [6] = 8, [7] = 8, [8] = 8, [9] = 13 },
  36. [32] = { [3] = 8, [4] = 6, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 10 },
  37. [33] = { [3] = 20, [4] = 12, [5] = 15, [6] = 15, [7] = 15, [8] = 15, [9] = 25 },
  38. [34] = { [3] = 15, [4] = 10, [5] = 12, [6] = 12, [7] = 12, [8] = 12, [9] = 300 },
  39. [35] = { [3] = 90, [4] = 70, [5] = 70, [6] = 70, [7] = 70, [8] = 70, [9] = 150 },
  40. [36] = { [3] = 80, [4] = 50, [5] = 50, [6] = 50, [7] = 50, [8] = 50, [9] = 130 },
  41. --[37] = { [3] = 0.1, [4] = 0.1, [5] = 0.1, [6] = 0.1, [7] = 0.1, [8] = 0.1, [9] = 0.1 },
  42. [37] = { [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 },
  43. [38] = { [3] = 8, [4] = 5, [5] = 6, [6] = 6, [7] = 6, [8] = 6, [9] = 12 },
  44. [39] = { [3] = 80, [4] = 50, [5] = 50, [6] = 50, [7] = 50, [8] = 50, [9] = 130 }
  45. },
  46. ["gangwar"] = {
  47. [0] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
  48. [4] = { [3] = 10, [4] = 20, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 20 },
  49. [8] = { [3] = 35, [4] = 35, [5] = 35, [6] = 35, [7] = 35, [8] = 35, [9] = 35 },
  50. [9] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
  51. [16] = { [3] = 120, [4] = 120, [5] = 120, [6] = 120, [7] = 120, [8] = 120, [9] = 120 }, -- Nur halber Schaden wird genommen
  52. [17] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
  53. [18] = { [3] = 0.02, [4] = 0.02, [5] = 0.02, [6] = 0.02, [7] = 0.02, [8] = 0.02, [9] = 0.02 },
  54. [19] = { [3] = 200, [4] = 200, [5] = 200, [6] = 200, [7] = 200, [8] = 200, [9] = 200 }, -- Nur halber Schaden wird genommen
  55. [22] = { [3] = 8, [4] = 6, [5] = 7, [6] = 7, [7] = 7, [8] = 7, [9] = 12 },
  56. [23] = { [3] = 10, [4] = 9, [5] = 9, [6] = 9, [7] = 9, [8] = 9, [9] = 15 },
  57. [24] = { [3] = 40, [4] = 36, [5] = 36, [6] = 36, [7] = 36, [8] = 36, [9] = 80 },
  58. [25] = { [3] = 20, [4] = 14, [5] = 16, [6] = 16, [7] = 16, [8] = 16, [9] = 25 },
  59. [26] = { [3] = 30, [4] = 20, [5] = 20, [6] = 20, [7] = 20, [8] = 20, [9] = 40 },
  60. [27] = { [3] = 30, [4] = 20, [5] = 20, [6] = 20, [7] = 20, [8] = 20, [9] = 40 },
  61. [28] = { [3] = 8, [4] = 6, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 10 },
  62. [29] = { [3] = 10, [4] = 8, [5] = 9, [6] = 9, [7] = 9, [8] = 9, [9] = 14 },
  63. [30] = { [3] = 10, [4] = 7, [5] = 8, [6] = 8, [7] = 8, [8] = 8, [9] = 14 },
  64. [31] = { [3] = 9, [4] = 7, [5] = 8, [6] = 8, [7] = 8, [8] = 8, [9] = 13 },
  65. [32] = { [3] = 8, [4] = 6, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 10 },
  66. [33] = { [3] = 20, [4] = 12, [5] = 15, [6] = 15, [7] = 15, [8] = 15, [9] = 25 },
  67. [34] = { [3] = 15, [4] = 10, [5] = 12, [6] = 12, [7] = 12, [8] = 12, [9] = 300 },
  68. [35] = { [3] = 90, [4] = 70, [5] = 70, [6] = 70, [7] = 70, [8] = 70, [9] = 150 },
  69. [36] = { [3] = 80, [4] = 50, [5] = 50, [6] = 50, [7] = 50, [8] = 50, [9] = 130 },
  70. --[37] = { [3] = 0.1, [4] = 0.1, [5] = 0.1, [6] = 0.1, [7] = 0.1, [8] = 0.1, [9] = 0.1 },
  71. [37] = { [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 },
  72. [38] = { [3] = 8, [4] = 5, [5] = 6, [6] = 6, [7] = 6, [8] = 6, [9] = 12 },
  73. [39] = { [3] = 80, [4] = 50, [5] = 50, [6] = 50, [7] = 50, [8] = 50, [9] = 130 }
  74. } }
  75. local playerkills = {}
  76. dmggetdoneinround = {}
  77. local oldheadshotdmgs = {}
  78. local playerdamager = {}
  79. playertopdamager = {}
  80.  
  81.  
  82. local function round ( number )
  83. return number % 1 <= 0.5 and math.floor ( number ) or math.ceil ( number )
  84. end
  85.  
  86.  
  87. local function saveTopDamager ( player, attacker, damage )
  88. if not playerdamager[player] then
  89. playerdamager[player] = {}
  90. end
  91. if not playertopdamager[player] then
  92. playertopdamager[player] = { 0, nil }
  93. end
  94. playerdamager[player][attacker] = ( playerdamager[player][attacker] or 0 ) + damage
  95. if playertopdamager[player][1] < playerdamager[player][attacker] then
  96. playertopdamager[player][1] = playerdamager[player][attacker]
  97. playertopdamager[player][2] = attacker
  98. end
  99. end
  100.  
  101.  
  102. function resetTopDamager ( player, lobby, attacker )
  103. if playertopdamager[player] and playertopdamager[player][1] >= 100 and isElement ( playertopdamager[player][2] ) and not attacker or attacker ~= playertopdamager[player][2] then
  104. if lobby == "standard" then
  105. local prevassists = tdsGetElementData ( playertopdamager[player][2], "Assists" )
  106. if prevassists then
  107. tdsSetElementData ( playertopdamager[player][2], "Assists", prevassists + 1 )
  108. end
  109. elseif lobby == "gangwar" then
  110. local prevassists = tdsGetElementData ( playertopdamager[player][2], "GangwarAssists" )
  111. if prevassists then
  112. tdsSetElementData ( playertopdamager[player][2], "GangwarAssists", prevassists + 1 )
  113. end
  114. else
  115. local prevassists = tdsGetElementData ( playertopdamager[player][2], "LobbyAssists" )
  116. if prevassists then
  117. tdsSetElementData ( playertopdamager[player][2], "LobbyAssists", prevassists + 1 )
  118. end
  119. end
  120. end
  121. playerdamager[player] = nil
  122. playertopdamager[player] = nil
  123. end
  124.  
  125.  
  126. local _setElementHealth = setElementHealth
  127.  
  128. function setElementHealth ( element, health )
  129. if getElementType ( element ) == "player" and tonumber ( health ) then
  130. if tonumber ( health ) <= 100 then
  131. setPedStat ( element, 24, 570 )
  132. else
  133. setPedStat ( element, 24, 570 + math.ceil ( tonumber ( health )/200 * 430 ) )
  134. end
  135. end
  136. return _setElementHealth ( element, health )
  137. end
  138.  
  139.  
  140. addEventHandler ( "damageWasDealt", root, function ( weapon, bodypart, loss, clientwhenfromserver )
  141. local attacker = client or clientwhenfromserver
  142. local hitted = source
  143.  
  144. if isElement ( hitted ) and ( tdsGetElementData ( hitted, "status" ) == "playing" or tdsGetElementData ( hitted, "status" ) == "deatharena" ) and getElementDimension ( attacker ) == getElementDimension ( hitted ) then
  145. local x, y, z = getElementPosition ( attacker )
  146. local xp, yp, zp = getElementPosition ( hitted )
  147. local multiply = 1
  148. if math.sqrt ( ( xp - x ) ^ 2 + ( yp - y ) ^ 2 + ( zp - z ) ^ 2 ) <= 1 and weapon ~= 35 then
  149. multiply = 0.5
  150. end
  151. local lobby = tdsGetElementData ( attacker, "lobby" )
  152. local health = getElementHealth ( hitted )
  153. local armor = getPedArmor ( hitted )
  154. local totalhealth = health + armor
  155. if tdsGetElementData ( hitted, "status" ) == "playing" then
  156. local damage = ( ( weapon == 53 and 1 ) or ( weaponDamages[lobby] and weaponDamages[lobby][weapon] and weaponDamages[lobby][weapon][bodypart] ) or weaponDamages["standard"][weapon] and weaponDamages["standard"][weapon][bodypart] or loss ) * multiply
  157. local attackername = getPlayerName ( attacker )
  158. local sourcename = getPlayerName ( hitted )
  159. if lobby ~= "gangwar" then
  160. if playersGaveDamage[lobby] then
  161. if not playersGaveDamage[lobby][attackername] then
  162. playersGaveDamage[lobby][attackername] = {}
  163. end
  164. if not playersBecameDamage[lobby][sourcename] then
  165. playersBecameDamage[lobby][sourcename] = {}
  166. end
  167. end
  168. if not dmggetdoneinround[lobby] then
  169. dmggetdoneinround[lobby] = {}
  170. end
  171. dmggetdoneinround[lobby][hitted] = true
  172. dmggetdoneinround[lobby][attacker] = true
  173. end
  174. local newdmg = damage
  175. if totalhealth > damage then
  176. if health > 100 then
  177. newdmg = newdmg - ( health - 100 )
  178. if newdmg >= 0 then
  179. health = 100
  180. setElementHealth ( hitted, health )
  181. else
  182. health = 100 - newdmg
  183. setElementHealth ( hitted, health )
  184.  
  185. end
  186. end
  187. if newdmg > 0 then
  188. if armor > newdmg then
  189. setPedArmor ( hitted, armor-newdmg )
  190. armor = armor-newdmg
  191. else
  192. setPedArmor ( hitted, 0 )
  193. setElementHealth ( hitted, health - ( newdmg - armor ) )
  194. health = health - ( newdmg - armor )
  195. armor = 0
  196. end
  197. end
  198. if attacker ~= hitted then
  199. saveTopDamager ( hitted, attacker, damage )
  200. if lobby == "standard" then
  201. tdsSetElementData ( attacker, "Damage", round ( tdsGetElementData ( attacker, "Damage" ) + damage ) )
  202. if tdsGetElementData ( attacker, "weaponhits"..weapon ) then
  203. tdsSetElementData ( attacker, "weaponhits"..weapon, tdsGetElementData ( attacker, "weaponhits"..weapon ) + 1 )
  204. end
  205. end
  206. tdsSetElementData ( hitted, "lastHitter", attackername )
  207. if lobby ~= "gangwar" then
  208. local attackerteam = getPlayerTeam ( attacker )
  209. playerDamages[lobby][attackername] = { ( playerDamages[lobby][attackername] and playerDamages[lobby][attackername][1] or 0 ) + damage, attackerteam }
  210. playersGaveDamage[lobby][attackername][sourcename] = ( playersGaveDamage[lobby][attackername][sourcename] or 0 ) + damage
  211. triggerClientEvent ( attacker, "giveDamageClient", attacker, damage )
  212. elseif not isInFunGangwar ( attacker ) then
  213. tdsSetElementData ( attacker, "GangwarDamage", round ( tdsGetElementData ( attacker, "GangwarDamage" ) + damage ) )
  214. end
  215. end
  216. if lobby ~= "gangwar" then
  217. playersBecameDamage[lobby][sourcename][attackername] = ( playersBecameDamage[lobby][sourcename][attackername] or 0 ) + damage
  218. end
  219. tdsSetElementData ( hitted, "lasthp", health + armor )
  220. if lobby == "gangwar" then
  221. gangwarPlayerGotDamage ( sourcename, attackername, damage )
  222. end
  223. else
  224. tdsSetElementData ( hitted, "lasthp", totalhealth )
  225. saveTopDamager ( hitted, attacker, totalhealth )
  226. killPed ( hitted, attacker, weapon, bodypart )
  227. end
  228. else
  229. local damage = ( weapon == 53 and 1 or weaponDamages["standard"][weapon] and weaponDamages["standard"][weapon][bodypart] or loss ) * multiply
  230. local newdmg = damage
  231. triggerClientEvent ( attacker, "playHitSound", attacker )
  232. if totalhealth > damage then
  233. if health > 100 then
  234. newdmg = newdmg - ( health - 100 )
  235. health = newdmg >= 0 and 100 or 100 - newdmg
  236. setElementHealth ( hitted, health )
  237. end
  238. if newdmg > 0 then
  239. if armor > newdmg then
  240. setPedArmor ( hitted, armor-newdmg )
  241. else
  242. setPedArmor ( hitted, 0 )
  243. setElementHealth ( hitted, health - ( newdmg - armor ) )
  244. end
  245. end
  246. else
  247. killPed ( hitted, attacker, weapon, bodypart )
  248. end
  249. end
  250. end
  251. end )
  252.  
  253.  
  254. addEventHandler ( "onPlayerWasted", root, function ( _, attackerp, weapon, part )
  255. local playerstatus = tdsGetElementData ( source, "status" )
  256. if playerstatus ~= "spectating" then
  257. if playerstatus ~= "deatharena" then
  258. local lobby = tdsGetElementData ( source, "lobby" )
  259. if lobby then
  260. local attacker = ( tdsGetElementData ( source, "lastHitter" ) and getPlayerFromName ( tdsGetElementData ( source, "lastHitter" ) ) ) or false
  261. local weapon = weapon
  262. local sourceteam = getPlayerTeam ( source ) or teams["Zuschauer"]
  263. local sourcecolors = { getTeamColor ( sourceteam ) }
  264. local damage = tdsGetElementData ( source, "lasthp" ) or 200
  265. if isElement ( attackerp ) and getElementType ( attackerp ) == "player" then
  266. attacker = attackerp
  267. if weapon == 19 then -- Raketen
  268. weapon = getPedWeapon ( attacker ) or 51
  269. end
  270. if lobby ~= "gangwar" and isElement ( attacker ) and tdsGetElementData ( attacker, "status" ) ~= "deatharena" and playersinlobby[lobby] and playersinlobby[lobby][1] then
  271. local attackerteam = getPlayerTeam ( attacker )
  272. local attackerteamname = attackerteam and getTeamName ( attackerteam ) or "Zuschauer"
  273. local attackercolors = nil
  274. if attackerteam then
  275. attackercolors = { getTeamColor ( attackerteam ) }
  276. else
  277. attackercolors = { 255, 255, 255 }
  278. end
  279. if playersinlobby[lobby] and playersinlobby[lobby][1] then
  280. triggerLatentClientEvent ( playersinlobby[lobby], "outputKillMessage", 50000, false, source, weapon, sourcecolors, part == 9, attacker, attackercolors )
  281. end
  282. if not playerkills[attacker] then
  283. playerkills[attacker] = {}
  284. end
  285. if attacker ~= source and lobby == "standard" then
  286. playerkills[attacker][source] = ( playerkills[attacker][source] or 0 ) + 1
  287. if playerkills[source] and playerkills[source][attacker] then
  288. playerkills[source][attacker] = nil
  289. end
  290. if playerkills[attacker][source] >= 15 then
  291. logKillPush ( tostring ( getPlayerName ( attacker ) ) .. " hat "..tostring ( getPlayerName ( source ) ).." schon "..playerkills[attacker][source].."x hintereinander getötet" )
  292. end
  293. end
  294. end
  295. elseif not attacker or attacker == source then
  296. tdsRemoveElementData ( source, "lasthp" )
  297. if lobby ~= "gangwar" then
  298. if lobby == "standard" then
  299. tdsSetElementData ( source, "Tode", tdsGetElementData ( source, "Tode" ) + 1 )
  300. setPlayerAnnounceValue ( source, "score", tdsGetElementData ( source, "Kills" )/tdsGetElementData ( source, "Tode" )*100 )
  301. else
  302. tdsSetElementData ( source, "LobbyDeaths", tdsGetElementData ( source, "LobbyDeaths" ) + 1 )
  303. end
  304. if playersinlobby[lobby] and playersinlobby[lobby][1] then
  305. triggerLatentClientEvent ( playersinlobby[lobby], "outputKillMessage", 50000, false, source, weapon, sourcecolors, part == 9 )
  306. end
  307. elseif playerstatus == "playing" then
  308. if not isInFunGangwar ( source ) then
  309. tdsSetElementData ( source, "GangwarTode", tdsGetElementData ( source, "GangwarTode" ) + 1 )
  310. end
  311. gangwarPlayerDied ( source, nil, damage )
  312. end
  313. return
  314. end
  315. resetTopDamager ( source, lobby, attackerp )
  316. if isElement ( attacker ) and tdsGetElementData ( attacker, "status" ) ~= "deatharena" then
  317. if lobby ~= "gangwar" then
  318. triggerClientEvent ( attacker, "giveKillClient", attacker )
  319. end
  320. local attackername, sourcename = getPlayerName ( attacker ), getPlayerName ( source )
  321. createKillLogMessage ( attackername, sourcename )
  322. if lobby == "standard" then
  323. local attackerteam = getPlayerTeam ( attacker )
  324. playerKills[lobby][attackername] = { ( playerKills[lobby][attackername] and playerKills[lobby][attackername][1] or 0 ) + 1, attackerteam }
  325. playerDamages[lobby][attackername] = { ( playerDamages[lobby][attackername] and playerDamages[lobby][attackername][1] or 0 ) + damage, attackerteam }
  326. local kills = tdsGetElementData ( attacker, "Kills" )
  327. tdsSetElementData ( attacker, "Kills", kills + 1 )
  328. tdsSetElementData ( source, "Tode", tdsGetElementData ( source, "Tode" ) + 1 )
  329. setPlayerAnnounceValue ( attacker, "score", tdsGetElementData ( attacker, "Kills" )/tdsGetElementData ( attacker, "Tode" )*100 )
  330. setPlayerAnnounceValue ( source, "score", tdsGetElementData ( source, "Kills" )/tdsGetElementData ( source, "Tode" )*100 )
  331. tdsSetElementData ( attacker, "Damage", math.floor ( tdsGetElementData ( attacker, "Damage" ) + damage ) )
  332. if tdsGetElementData ( attacker, "weaponkills"..weapon ) then
  333. tdsSetElementData ( attacker, "weaponkills"..weapon, tdsGetElementData ( attacker, "weaponkills"..weapon ) + 1 )
  334. end
  335. if tdsGetElementData ( attacker, "weaponhits"..weapon ) then
  336. tdsSetElementData ( attacker, "weaponhits"..weapon, tdsGetElementData ( attacker, "weaponhits"..weapon ) + 1 )
  337. end
  338. triggerClientEvent ( attacker, "giveDamageClient", attacker, damage )
  339. --[[local lvl = tdsGetElementData ( attacker, "level" )
  340. if wvKills[lvl+1] and kills >= wvKills[lvl+1] then
  341. if wvKills[lvl+2] and kills >= wvKills[lvl+2] then
  342. local lastint = 0
  343. for i=lvl, #wvKills do
  344. if kills >= wvKills[i] then
  345. lastint = i
  346. else
  347. break
  348. end
  349. end
  350. levelUpPlayer ( attacker, lastint )
  351. else
  352. levelUpPlayer ( attacker )
  353. end
  354. end]]
  355. checkKillsAchievement ( attacker )
  356. checkDeathsAchievement ( source )
  357. if source == theHunted then
  358. huntedGotKilled ( theHunter == attacker )
  359. end
  360. elseif lobby == "gangwar" and playerstatus == "playing" then
  361. gangwarPlayerDied ( source, attacker, damage )
  362. if not isInFunGangwar ( source ) then
  363. tdsSetElementData ( source, "GangwarTode", tdsGetElementData ( source, "GangwarTode" ) + 1 )
  364. end
  365. if not isInFunGangwar ( attacker ) then
  366. tdsSetElementData ( attacker, "GangwarKills", tdsGetElementData ( attacker, "GangwarKills" ) + 1 )
  367. tdsSetElementData ( attacker, "GangwarDamage", math.floor ( tdsGetElementData ( attacker, "GangwarDamage" ) + damage ) )
  368. end
  369. elseif lobby ~= "mainmenue" then
  370. if not playerKills[lobby] then
  371. playerKills[lobby] = {}
  372. playerDamages[lobby] = {}
  373. end
  374. local attackerteam = getPlayerTeam ( attacker )
  375. local attackername = getPlayerName ( attacker )
  376. playerKills[lobby][attackername] = { ( playerKills[lobby][attackername] and playerKills[lobby][attackername][1] or 0 ) + 1, attackerteam }
  377. playerDamages[lobby][attackername] = { ( playerDamages[lobby][attackername] and playerDamages[lobby][attackername][1] or 0 ) + damage, attackerteam }
  378. if tdsGetElementData ( attacker, "LobbyKills" ) then
  379. tdsSetElementData ( attacker, "LobbyKills", tdsGetElementData ( attacker, "LobbyKills" ) + 1 )
  380. tdsSetElementData ( source, "LobbyDeaths", tdsGetElementData ( source, "LobbyDeaths" ) + 1 )
  381. end
  382. triggerClientEvent ( attacker, "giveDamageClient", attacker, damage )
  383. end
  384. if part == 9 then
  385. setPedHeadless ( source, true )
  386. checkHeadshotKillsAchievement ( attacker )
  387. end
  388. if lobby ~= "gangwar" then
  389. if not playersGaveDamage[lobby][attackername] then
  390. playersGaveDamage[lobby][attackername] = {}
  391. end
  392. if not playersBecameDamage[lobby][sourcename] then
  393. playersBecameDamage[lobby][sourcename] = {}
  394. end
  395. playersGaveDamage[lobby][attackername][sourcename] = ( playersGaveDamage[lobby][attackername][sourcename] or 0 ) + damage
  396. playersBecameDamage[lobby][sourcename][attackername] = ( playersBecameDamage[lobby][sourcename][attackername] or 0 ) + damage
  397. end
  398. tdsRemoveElementData ( source, "lastHitter" )
  399. tdsRemoveElementData ( source, "lasthp" )
  400. end
  401. end
  402. end
  403. end
  404. playerdamager[source] = nil
  405. playertopdamager[source] = nil
  406. end )
  407.  
  408.  
  409. addEventHandler ( "onPlayerWeaponFire", root, function ( weapon )
  410. local lobby = tdsGetElementData ( source, "lobby" )
  411. if lobby and lobby == "standard" then
  412. if tdsGetElementData ( source, "weaponshots"..weapon ) then
  413. tdsSetElementData ( source, "weaponshots"..weapon, tdsGetElementData ( source, "weaponshots"..weapon ) + 1 )
  414. end
  415. end
  416. end )
  417.  
  418.  
  419. addEventHandler ( "onPlayerSpawn", root, function()
  420. tdsRemoveElementData ( source, "lastHitter" )
  421. setPedHeadless ( source, false )
  422. end )
  423.  
  424.  
  425. local function sortTableByBestInRound ( a, b )
  426. return a[3]*50+a[2] > b[3]*50+b[2]
  427. end
  428.  
  429.  
  430. addEventHandler ( "onRoundFinish", resourceRoot, function ( lobby )
  431. local damagearray = { [1] = {}, [2] = {}, [3] = {} }
  432. local bestdamages = {}
  433. dmggetdoneinround[lobby] = {}
  434. local counter = 0
  435. for pname, array in pairs ( playerDamages[lobby] ) do
  436. if array[2] == teams["Grove"] or array[2] == teams["2Grove"] then
  437. damagearray[1][pname] = { round ( array[1] ), ( playerKills[lobby][pname] and playerKills[lobby][pname][1] or 0 ) }
  438. elseif array[2] == teams["Triaden"] or array[2] == teams["2Triaden"] then
  439. damagearray[2][pname] = { round ( array[1] ), ( playerKills[lobby][pname] and playerKills[lobby][pname][1] or 0 ) }
  440. else
  441. damagearray[3][pname] = { round ( array[1] ), ( playerKills[lobby][pname] and playerKills[lobby][pname][1] or 0 ) }
  442. end
  443. counter = counter + 1
  444. bestdamages[counter] = { pname, round ( array[1] ), ( playerKills[lobby][pname] and playerKills[lobby][pname][1] or 0 ) }
  445. end
  446. if playersinlobby[lobby] and playersinlobby[lobby][1] then
  447. for i=#playersinlobby[lobby], 1, -1 do
  448. if isElement ( playersinlobby[lobby][i] ) then
  449. triggerLatentClientEvent ( playersinlobby[lobby], "syncDamagesAfterRound", 30000, false, playersinlobby[lobby][i], damagearray )
  450. break
  451. else
  452. table.remove ( playersinlobby[lobby], i )
  453. end
  454. end
  455. end
  456. playerDamages[lobby] = {}
  457. playerKills[lobby] = {}
  458.  
  459. local alreadygiven = {}
  460. for attackername, array in pairs ( playersGaveDamage[lobby] ) do
  461. local attacker = getPlayerFromName ( attackername )
  462. if isElement ( attacker ) then
  463. if playersBecameDamage[lobby][attackername] then
  464. alreadygiven[attackername] = true
  465. triggerLatentClientEvent ( attacker, "syncDamagesGivenAfterRound", 30000, false, attacker, array, playersBecameDamage[lobby][attackername] )
  466. else
  467. triggerLatentClientEvent ( attacker, "syncDamagesGivenAfterRound", 30000, false, attacker, array )
  468. end
  469. end
  470. end
  471. for sourcename, array in pairs ( playersBecameDamage[lobby] ) do
  472. if not alreadygiven[sourcename] then
  473. local player = getPlayerFromName ( sourcename )
  474. if isElement ( player ) then
  475. triggerLatentClientEvent ( player, "syncDamagesTakenAfterRound", 30000, false, player, array )
  476. end
  477. end
  478. end
  479. playersGaveDamage[lobby] = {}
  480. playersBecameDamage[lobby] = {}
  481. table.sort ( bestdamages, sortTableByBestInRound )
  482. getTheMapForNextRound ( lobby, bestdamages )
  483. end, true, "high" )
  484.  
  485.  
  486. addCommandHandler ( "kill", function ( player )
  487. local lobby = tdsGetElementData ( player, "lobby" )
  488. if lobby and lobby ~= "mainmenue" and lobby ~= "gangwar" then
  489. if tdsGetElementData ( player, "status" ) == "playing" then
  490. get1Suicide ( player )
  491. local pname = getPlayerName ( player )
  492. if playersinlobby[lobby] and playersinlobby[lobby][1] then
  493. for i=1, #playersinlobby[lobby] do
  494. if isElement ( playersinlobby[lobby][i] ) then
  495. outputInformation ( playersinlobby[lobby][i], pname..langtext[tdsGetElementData ( playersinlobby[lobby][i], "language" )]["usedkill"], "info" )
  496. end
  497. end
  498. end
  499. local lastattacker = tdsGetElementData ( player, "lastHitter" )
  500. tdsRemoveElementData ( player, "lastHitter" )
  501. if lastattacker then
  502. lastattacker = getPlayerFromName ( lastattacker )
  503. if isElement ( lastattacker ) then
  504. checkKillsAchievement ( lastattacker )
  505. outputInformation ( lastattacker, pname..langtext[tdsGetElementData ( lastattacker, "language" )]["killescape"], "success" )
  506. outputInformation ( player, langtext[tdsGetElementData ( player, "language" )]["killgoesto"]..getPlayerName ( lastattacker ), "error" )
  507. killPed ( player, lastattacker, 999 )
  508. else
  509. killPed ( player )
  510. end
  511. else
  512. killPed ( player )
  513. end
  514. end
  515. end
  516. end )
  517.  
  518.  
  519. addEventHandler ( "givepointsfordamagekills", root, function ( bonus )
  520. local roundwon = tdsGetElementData ( client, "wonround" )
  521. local newbonus = math.floor ( bonus * ( roundwon == false and 0.5 or roundwon == true and 1.5 or 1 ) )
  522. tdsSetElementData ( client, "Punkte", math.floor ( tdsGetElementData ( client, "Punkte" ) + newbonus ) )
  523. local language = tdsGetElementData ( client, "language" )
  524. outputChatBox ( langtext[language]["roundbonuspoints"][1]..math.floor ( bonus ) .. " ("..( newbonus - bonus >= 0 and "+ ".. math.abs ( newbonus - bonus ) or "- ".. math.abs ( newbonus - bonus ) )..")"..langtext[language]["roundbonuspoints"][2], client, 0, 125, 0, true )
  525. if source ~= client then
  526. logError ( "Jemand faket givepointsfordamagekills! "..tostring ( getPlayerName ( source ) ) .." - "..tostring ( getPlayerName ( client ) ) )
  527. end
  528. end )
  529.  
  530.  
  531. function loadLobbyDamage ( lobby, array )
  532. weaponDamages[lobby] = {}
  533. playerDamages[lobby] = {}
  534. dmggetdoneinround[lobby] = {}
  535. playerKills[lobby] = {}
  536. playersGaveDamage[lobby] = {}
  537. playersBecameDamage[lobby] = {}
  538. for i, v in pairs ( array ) do
  539. if type ( v ) == "table" then
  540. weaponDamages[lobby][i] = {}
  541. for ii, vv in pairs ( v ) do
  542. weaponDamages[lobby][i][ii] = vv
  543. end
  544. else
  545. weaponDamages[lobby][i] = v
  546. end
  547. end
  548. end
  549.  
  550.  
  551. function removeLobbyDamage ( lobby )
  552. weaponDamages[lobby] = nil
  553. playerDamages[lobby] = nil
  554. dmggetdoneinround[lobby] = nil
  555. playerKills[lobby] = nil
  556. playersGaveDamage[lobby] = nil
  557. playersBecameDamage[lobby] = nil
  558. end
  559.  
  560.  
  561. addEventHandler ( "onPlayerQuit", root, function ( )
  562. playerkills[source] = nil
  563. end )
  564.  
  565.  
  566. function setStandardLobbyHeadshotKills ( )
  567. for weaponID, array in pairs ( weaponDamages["standard"] ) do
  568. oldheadshotdmgs[weaponID] = weaponDamages["standard"][weaponID][9]
  569. weaponDamages["standard"][weaponID][9] = 300
  570. end
  571. end
  572.  
  573.  
  574. function resetStandardLobbyHeadshotKills ( )
  575. for weaponID, dmg in pairs ( oldheadshotdmgs ) do
  576. weaponDamages["standard"][weaponID][9] = dmg
  577. end
  578. end
  579.  
  580.  
  581. function getDamageByWeaponAndLobby ( weapon, lobby )
  582. return weaponDamages[lobby] and weaponDamages[lobby][weapon][3] or 0
  583. end
  584.  
  585.  
  586.  
  587.  
  588.  
  589. --------------------------------
  590.  
  591. local lifes = {}
  592.  
  593. local _setElementHealth = setElementHealth
  594. function setElementHealth ( element, health )
  595. if getElementType ( element ) == "player" then
  596. if not lifes[element] then
  597. lifes[element] = { 0, getPedArmor ( element ) }
  598. end
  599. lifes[element][1] = health
  600. end
  601. return _setElementHealth ( element, health )
  602. end
  603.  
  604. local _getElementHealth = getElementHealth
  605. function getElementHealth ( element )
  606. if getElementType ( element ) == "player" then
  607. if lifes[element] then
  608. return lifes[element][1]
  609. end
  610. end
  611. return _getElementHealth ( element )
  612. end
  613.  
  614. local _setPedArmor = setPedArmor
  615. function setPedArmor ( element, armor )
  616. if getElementType ( element ) == "player" then
  617. if not lifes[element] then
  618. lifes[element] = { getElementHealth ( element ), 0 }
  619. end
  620. lifes[element][2] = armor
  621. end
  622. return _setPedArmor ( element, armor )
  623. end
  624.  
  625. local _getPedArmor = getPedArmor
  626. function getPedArmor ( element )
  627. if getElementType ( element ) == "player" then
  628. if lifes[element] then
  629. return lifes[element][2]
  630. end
  631. end
  632. return _getPedArmor ( element )
  633. end
  634.  
  635.  
  636.  
  637. local _spawnPlayer = spawnPlayer
  638. function spawnPlayer ( ... )
  639. local array = { ... }
  640. lifes[array[1]] = { 100, 0 }
  641. return _spawnPlayer ( ... )
  642. end
  643.  
  644.  
  645. addEventHandler ( "onPlayerQuit", root, function ( )
  646. lifes[source] = nil
  647. end )
  648.  
  649. addEvent ( "damageInOtherWay", true )
  650. addEventHandler ( "damageInOtherWay", root, function ( damage, weapon, part )
  651. local armor = getPedArmor ( client )
  652. local health = getElementHealth ( client )
  653. if armor >= damage then
  654. setPedArmor ( client, armor - damage )
  655. tdsSetElementData ( client, "lasthp", health + armor - damage )
  656. else
  657. health = health + armor
  658. armor = 0
  659. health = health - damage
  660. tdsSetElementData ( client, "lasthp", health )
  661. if health > 0 then
  662. setElementHealth ( client, health )
  663. else
  664. local lasthitter = tdsGetElementData ( client, "lastHitter" ) and getPlayerFromName ( tdsGetElementData ( client, "lastHitter" ) ) or nil
  665. killPed ( client, lasthitter, weapon, part )
  666. end
  667. end
  668. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement