Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addEvent ( "damageWasDealt", true )
- addEvent ( "damageWasDealtOnWasted", true )
- addEvent ( "givepointsfordamagekills", true )
- addEvent ( "onRoundFinish", false )
- --addEvent ( "onPlayerWastedTriggered", true )
- local wvKills = { [0] = 0 }
- for i=1, 120 do
- wvKills[i] = wvKills[i-1] + i
- end
- local playerDamages = { ["standard"] = {}, ["gangwar"] = {} }
- local playerKills = { ["standard"] = {}, ["gangwar"] = {} }
- local playersGaveDamage = { ["standard"] = {} }
- local playersBecameDamage = { ["standard"] = {} }
- local weaponDamages = { ["standard"] = {
- [0] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
- [4] = { [3] = 10, [4] = 20, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 20 },
- [8] = { [3] = 35, [4] = 35, [5] = 35, [6] = 35, [7] = 35, [8] = 35, [9] = 35 },
- [9] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
- [16] = { [3] = 120, [4] = 120, [5] = 120, [6] = 120, [7] = 120, [8] = 120, [9] = 120 }, -- Nur halber Schaden wird genommen
- [17] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
- [18] = { [3] = 0.02, [4] = 0.02, [5] = 0.02, [6] = 0.02, [7] = 0.02, [8] = 0.02, [9] = 0.02 },
- [19] = { [3] = 200, [4] = 200, [5] = 200, [6] = 200, [7] = 200, [8] = 200, [9] = 200 }, -- Nur halber Schaden wird genommen
- [22] = { [3] = 8, [4] = 6, [5] = 7, [6] = 7, [7] = 7, [8] = 7, [9] = 12 },
- [23] = { [3] = 10, [4] = 9, [5] = 9, [6] = 9, [7] = 9, [8] = 9, [9] = 15 },
- [24] = { [3] = 40, [4] = 36, [5] = 36, [6] = 36, [7] = 36, [8] = 36, [9] = 80 },
- [25] = { [3] = 20, [4] = 14, [5] = 16, [6] = 16, [7] = 16, [8] = 16, [9] = 25 },
- [26] = { [3] = 30, [4] = 20, [5] = 20, [6] = 20, [7] = 20, [8] = 20, [9] = 40 },
- [27] = { [3] = 30, [4] = 20, [5] = 20, [6] = 20, [7] = 20, [8] = 20, [9] = 40 },
- [28] = { [3] = 8, [4] = 6, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 10 },
- [29] = { [3] = 10, [4] = 8, [5] = 9, [6] = 9, [7] = 9, [8] = 9, [9] = 14 },
- [30] = { [3] = 10, [4] = 7, [5] = 8, [6] = 8, [7] = 8, [8] = 8, [9] = 14 },
- [31] = { [3] = 9, [4] = 7, [5] = 8, [6] = 8, [7] = 8, [8] = 8, [9] = 13 },
- [32] = { [3] = 8, [4] = 6, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 10 },
- [33] = { [3] = 20, [4] = 12, [5] = 15, [6] = 15, [7] = 15, [8] = 15, [9] = 25 },
- [34] = { [3] = 15, [4] = 10, [5] = 12, [6] = 12, [7] = 12, [8] = 12, [9] = 300 },
- [35] = { [3] = 90, [4] = 70, [5] = 70, [6] = 70, [7] = 70, [8] = 70, [9] = 150 },
- [36] = { [3] = 80, [4] = 50, [5] = 50, [6] = 50, [7] = 50, [8] = 50, [9] = 130 },
- --[37] = { [3] = 0.1, [4] = 0.1, [5] = 0.1, [6] = 0.1, [7] = 0.1, [8] = 0.1, [9] = 0.1 },
- [37] = { [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 },
- [38] = { [3] = 8, [4] = 5, [5] = 6, [6] = 6, [7] = 6, [8] = 6, [9] = 12 },
- [39] = { [3] = 80, [4] = 50, [5] = 50, [6] = 50, [7] = 50, [8] = 50, [9] = 130 }
- },
- ["gangwar"] = {
- [0] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
- [4] = { [3] = 10, [4] = 20, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 20 },
- [8] = { [3] = 35, [4] = 35, [5] = 35, [6] = 35, [7] = 35, [8] = 35, [9] = 35 },
- [9] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
- [16] = { [3] = 120, [4] = 120, [5] = 120, [6] = 120, [7] = 120, [8] = 120, [9] = 120 }, -- Nur halber Schaden wird genommen
- [17] = { [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5 },
- [18] = { [3] = 0.02, [4] = 0.02, [5] = 0.02, [6] = 0.02, [7] = 0.02, [8] = 0.02, [9] = 0.02 },
- [19] = { [3] = 200, [4] = 200, [5] = 200, [6] = 200, [7] = 200, [8] = 200, [9] = 200 }, -- Nur halber Schaden wird genommen
- [22] = { [3] = 8, [4] = 6, [5] = 7, [6] = 7, [7] = 7, [8] = 7, [9] = 12 },
- [23] = { [3] = 10, [4] = 9, [5] = 9, [6] = 9, [7] = 9, [8] = 9, [9] = 15 },
- [24] = { [3] = 40, [4] = 36, [5] = 36, [6] = 36, [7] = 36, [8] = 36, [9] = 80 },
- [25] = { [3] = 20, [4] = 14, [5] = 16, [6] = 16, [7] = 16, [8] = 16, [9] = 25 },
- [26] = { [3] = 30, [4] = 20, [5] = 20, [6] = 20, [7] = 20, [8] = 20, [9] = 40 },
- [27] = { [3] = 30, [4] = 20, [5] = 20, [6] = 20, [7] = 20, [8] = 20, [9] = 40 },
- [28] = { [3] = 8, [4] = 6, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 10 },
- [29] = { [3] = 10, [4] = 8, [5] = 9, [6] = 9, [7] = 9, [8] = 9, [9] = 14 },
- [30] = { [3] = 10, [4] = 7, [5] = 8, [6] = 8, [7] = 8, [8] = 8, [9] = 14 },
- [31] = { [3] = 9, [4] = 7, [5] = 8, [6] = 8, [7] = 8, [8] = 8, [9] = 13 },
- [32] = { [3] = 8, [4] = 6, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 10 },
- [33] = { [3] = 20, [4] = 12, [5] = 15, [6] = 15, [7] = 15, [8] = 15, [9] = 25 },
- [34] = { [3] = 15, [4] = 10, [5] = 12, [6] = 12, [7] = 12, [8] = 12, [9] = 300 },
- [35] = { [3] = 90, [4] = 70, [5] = 70, [6] = 70, [7] = 70, [8] = 70, [9] = 150 },
- [36] = { [3] = 80, [4] = 50, [5] = 50, [6] = 50, [7] = 50, [8] = 50, [9] = 130 },
- --[37] = { [3] = 0.1, [4] = 0.1, [5] = 0.1, [6] = 0.1, [7] = 0.1, [8] = 0.1, [9] = 0.1 },
- [37] = { [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 },
- [38] = { [3] = 8, [4] = 5, [5] = 6, [6] = 6, [7] = 6, [8] = 6, [9] = 12 },
- [39] = { [3] = 80, [4] = 50, [5] = 50, [6] = 50, [7] = 50, [8] = 50, [9] = 130 }
- } }
- local playerkills = {}
- dmggetdoneinround = {}
- local oldheadshotdmgs = {}
- local playerdamager = {}
- playertopdamager = {}
- local function round ( number )
- return number % 1 <= 0.5 and math.floor ( number ) or math.ceil ( number )
- end
- local function saveTopDamager ( player, attacker, damage )
- if not playerdamager[player] then
- playerdamager[player] = {}
- end
- if not playertopdamager[player] then
- playertopdamager[player] = { 0, nil }
- end
- playerdamager[player][attacker] = ( playerdamager[player][attacker] or 0 ) + damage
- if playertopdamager[player][1] < playerdamager[player][attacker] then
- playertopdamager[player][1] = playerdamager[player][attacker]
- playertopdamager[player][2] = attacker
- end
- end
- function resetTopDamager ( player, lobby, attacker )
- if playertopdamager[player] and playertopdamager[player][1] >= 100 and isElement ( playertopdamager[player][2] ) and not attacker or attacker ~= playertopdamager[player][2] then
- if lobby == "standard" then
- local prevassists = tdsGetElementData ( playertopdamager[player][2], "Assists" )
- if prevassists then
- tdsSetElementData ( playertopdamager[player][2], "Assists", prevassists + 1 )
- end
- elseif lobby == "gangwar" then
- local prevassists = tdsGetElementData ( playertopdamager[player][2], "GangwarAssists" )
- if prevassists then
- tdsSetElementData ( playertopdamager[player][2], "GangwarAssists", prevassists + 1 )
- end
- else
- local prevassists = tdsGetElementData ( playertopdamager[player][2], "LobbyAssists" )
- if prevassists then
- tdsSetElementData ( playertopdamager[player][2], "LobbyAssists", prevassists + 1 )
- end
- end
- end
- playerdamager[player] = nil
- playertopdamager[player] = nil
- end
- local _setElementHealth = setElementHealth
- function setElementHealth ( element, health )
- if getElementType ( element ) == "player" and tonumber ( health ) then
- if tonumber ( health ) <= 100 then
- setPedStat ( element, 24, 570 )
- else
- setPedStat ( element, 24, 570 + math.ceil ( tonumber ( health )/200 * 430 ) )
- end
- end
- return _setElementHealth ( element, health )
- end
- addEventHandler ( "damageWasDealt", root, function ( weapon, bodypart, loss, clientwhenfromserver )
- local attacker = client or clientwhenfromserver
- local hitted = source
- if isElement ( hitted ) and ( tdsGetElementData ( hitted, "status" ) == "playing" or tdsGetElementData ( hitted, "status" ) == "deatharena" ) and getElementDimension ( attacker ) == getElementDimension ( hitted ) then
- local x, y, z = getElementPosition ( attacker )
- local xp, yp, zp = getElementPosition ( hitted )
- local multiply = 1
- if math.sqrt ( ( xp - x ) ^ 2 + ( yp - y ) ^ 2 + ( zp - z ) ^ 2 ) <= 1 and weapon ~= 35 then
- multiply = 0.5
- end
- local lobby = tdsGetElementData ( attacker, "lobby" )
- local health = getElementHealth ( hitted )
- local armor = getPedArmor ( hitted )
- local totalhealth = health + armor
- if tdsGetElementData ( hitted, "status" ) == "playing" then
- 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
- local attackername = getPlayerName ( attacker )
- local sourcename = getPlayerName ( hitted )
- if lobby ~= "gangwar" then
- if playersGaveDamage[lobby] then
- if not playersGaveDamage[lobby][attackername] then
- playersGaveDamage[lobby][attackername] = {}
- end
- if not playersBecameDamage[lobby][sourcename] then
- playersBecameDamage[lobby][sourcename] = {}
- end
- end
- if not dmggetdoneinround[lobby] then
- dmggetdoneinround[lobby] = {}
- end
- dmggetdoneinround[lobby][hitted] = true
- dmggetdoneinround[lobby][attacker] = true
- end
- local newdmg = damage
- if totalhealth > damage then
- if health > 100 then
- newdmg = newdmg - ( health - 100 )
- if newdmg >= 0 then
- health = 100
- setElementHealth ( hitted, health )
- else
- health = 100 - newdmg
- setElementHealth ( hitted, health )
- end
- end
- if newdmg > 0 then
- if armor > newdmg then
- setPedArmor ( hitted, armor-newdmg )
- armor = armor-newdmg
- else
- setPedArmor ( hitted, 0 )
- setElementHealth ( hitted, health - ( newdmg - armor ) )
- health = health - ( newdmg - armor )
- armor = 0
- end
- end
- if attacker ~= hitted then
- saveTopDamager ( hitted, attacker, damage )
- if lobby == "standard" then
- tdsSetElementData ( attacker, "Damage", round ( tdsGetElementData ( attacker, "Damage" ) + damage ) )
- if tdsGetElementData ( attacker, "weaponhits"..weapon ) then
- tdsSetElementData ( attacker, "weaponhits"..weapon, tdsGetElementData ( attacker, "weaponhits"..weapon ) + 1 )
- end
- end
- tdsSetElementData ( hitted, "lastHitter", attackername )
- if lobby ~= "gangwar" then
- local attackerteam = getPlayerTeam ( attacker )
- playerDamages[lobby][attackername] = { ( playerDamages[lobby][attackername] and playerDamages[lobby][attackername][1] or 0 ) + damage, attackerteam }
- playersGaveDamage[lobby][attackername][sourcename] = ( playersGaveDamage[lobby][attackername][sourcename] or 0 ) + damage
- triggerClientEvent ( attacker, "giveDamageClient", attacker, damage )
- elseif not isInFunGangwar ( attacker ) then
- tdsSetElementData ( attacker, "GangwarDamage", round ( tdsGetElementData ( attacker, "GangwarDamage" ) + damage ) )
- end
- end
- if lobby ~= "gangwar" then
- playersBecameDamage[lobby][sourcename][attackername] = ( playersBecameDamage[lobby][sourcename][attackername] or 0 ) + damage
- end
- tdsSetElementData ( hitted, "lasthp", health + armor )
- if lobby == "gangwar" then
- gangwarPlayerGotDamage ( sourcename, attackername, damage )
- end
- else
- tdsSetElementData ( hitted, "lasthp", totalhealth )
- saveTopDamager ( hitted, attacker, totalhealth )
- killPed ( hitted, attacker, weapon, bodypart )
- end
- else
- local damage = ( weapon == 53 and 1 or weaponDamages["standard"][weapon] and weaponDamages["standard"][weapon][bodypart] or loss ) * multiply
- local newdmg = damage
- triggerClientEvent ( attacker, "playHitSound", attacker )
- if totalhealth > damage then
- if health > 100 then
- newdmg = newdmg - ( health - 100 )
- health = newdmg >= 0 and 100 or 100 - newdmg
- setElementHealth ( hitted, health )
- end
- if newdmg > 0 then
- if armor > newdmg then
- setPedArmor ( hitted, armor-newdmg )
- else
- setPedArmor ( hitted, 0 )
- setElementHealth ( hitted, health - ( newdmg - armor ) )
- end
- end
- else
- killPed ( hitted, attacker, weapon, bodypart )
- end
- end
- end
- end )
- addEventHandler ( "onPlayerWasted", root, function ( _, attackerp, weapon, part )
- local playerstatus = tdsGetElementData ( source, "status" )
- if playerstatus ~= "spectating" then
- if playerstatus ~= "deatharena" then
- local lobby = tdsGetElementData ( source, "lobby" )
- if lobby then
- local attacker = ( tdsGetElementData ( source, "lastHitter" ) and getPlayerFromName ( tdsGetElementData ( source, "lastHitter" ) ) ) or false
- local weapon = weapon
- local sourceteam = getPlayerTeam ( source ) or teams["Zuschauer"]
- local sourcecolors = { getTeamColor ( sourceteam ) }
- local damage = tdsGetElementData ( source, "lasthp" ) or 200
- if isElement ( attackerp ) and getElementType ( attackerp ) == "player" then
- attacker = attackerp
- if weapon == 19 then -- Raketen
- weapon = getPedWeapon ( attacker ) or 51
- end
- if lobby ~= "gangwar" and isElement ( attacker ) and tdsGetElementData ( attacker, "status" ) ~= "deatharena" and playersinlobby[lobby] and playersinlobby[lobby][1] then
- local attackerteam = getPlayerTeam ( attacker )
- local attackerteamname = attackerteam and getTeamName ( attackerteam ) or "Zuschauer"
- local attackercolors = nil
- if attackerteam then
- attackercolors = { getTeamColor ( attackerteam ) }
- else
- attackercolors = { 255, 255, 255 }
- end
- if playersinlobby[lobby] and playersinlobby[lobby][1] then
- triggerLatentClientEvent ( playersinlobby[lobby], "outputKillMessage", 50000, false, source, weapon, sourcecolors, part == 9, attacker, attackercolors )
- end
- if not playerkills[attacker] then
- playerkills[attacker] = {}
- end
- if attacker ~= source and lobby == "standard" then
- playerkills[attacker][source] = ( playerkills[attacker][source] or 0 ) + 1
- if playerkills[source] and playerkills[source][attacker] then
- playerkills[source][attacker] = nil
- end
- if playerkills[attacker][source] >= 15 then
- logKillPush ( tostring ( getPlayerName ( attacker ) ) .. " hat "..tostring ( getPlayerName ( source ) ).." schon "..playerkills[attacker][source].."x hintereinander getötet" )
- end
- end
- end
- elseif not attacker or attacker == source then
- tdsRemoveElementData ( source, "lasthp" )
- if lobby ~= "gangwar" then
- if lobby == "standard" then
- tdsSetElementData ( source, "Tode", tdsGetElementData ( source, "Tode" ) + 1 )
- setPlayerAnnounceValue ( source, "score", tdsGetElementData ( source, "Kills" )/tdsGetElementData ( source, "Tode" )*100 )
- else
- tdsSetElementData ( source, "LobbyDeaths", tdsGetElementData ( source, "LobbyDeaths" ) + 1 )
- end
- if playersinlobby[lobby] and playersinlobby[lobby][1] then
- triggerLatentClientEvent ( playersinlobby[lobby], "outputKillMessage", 50000, false, source, weapon, sourcecolors, part == 9 )
- end
- elseif playerstatus == "playing" then
- if not isInFunGangwar ( source ) then
- tdsSetElementData ( source, "GangwarTode", tdsGetElementData ( source, "GangwarTode" ) + 1 )
- end
- gangwarPlayerDied ( source, nil, damage )
- end
- return
- end
- resetTopDamager ( source, lobby, attackerp )
- if isElement ( attacker ) and tdsGetElementData ( attacker, "status" ) ~= "deatharena" then
- if lobby ~= "gangwar" then
- triggerClientEvent ( attacker, "giveKillClient", attacker )
- end
- local attackername, sourcename = getPlayerName ( attacker ), getPlayerName ( source )
- createKillLogMessage ( attackername, sourcename )
- if lobby == "standard" then
- local attackerteam = getPlayerTeam ( attacker )
- playerKills[lobby][attackername] = { ( playerKills[lobby][attackername] and playerKills[lobby][attackername][1] or 0 ) + 1, attackerteam }
- playerDamages[lobby][attackername] = { ( playerDamages[lobby][attackername] and playerDamages[lobby][attackername][1] or 0 ) + damage, attackerteam }
- local kills = tdsGetElementData ( attacker, "Kills" )
- tdsSetElementData ( attacker, "Kills", kills + 1 )
- tdsSetElementData ( source, "Tode", tdsGetElementData ( source, "Tode" ) + 1 )
- setPlayerAnnounceValue ( attacker, "score", tdsGetElementData ( attacker, "Kills" )/tdsGetElementData ( attacker, "Tode" )*100 )
- setPlayerAnnounceValue ( source, "score", tdsGetElementData ( source, "Kills" )/tdsGetElementData ( source, "Tode" )*100 )
- tdsSetElementData ( attacker, "Damage", math.floor ( tdsGetElementData ( attacker, "Damage" ) + damage ) )
- if tdsGetElementData ( attacker, "weaponkills"..weapon ) then
- tdsSetElementData ( attacker, "weaponkills"..weapon, tdsGetElementData ( attacker, "weaponkills"..weapon ) + 1 )
- end
- if tdsGetElementData ( attacker, "weaponhits"..weapon ) then
- tdsSetElementData ( attacker, "weaponhits"..weapon, tdsGetElementData ( attacker, "weaponhits"..weapon ) + 1 )
- end
- triggerClientEvent ( attacker, "giveDamageClient", attacker, damage )
- --[[local lvl = tdsGetElementData ( attacker, "level" )
- if wvKills[lvl+1] and kills >= wvKills[lvl+1] then
- if wvKills[lvl+2] and kills >= wvKills[lvl+2] then
- local lastint = 0
- for i=lvl, #wvKills do
- if kills >= wvKills[i] then
- lastint = i
- else
- break
- end
- end
- levelUpPlayer ( attacker, lastint )
- else
- levelUpPlayer ( attacker )
- end
- end]]
- checkKillsAchievement ( attacker )
- checkDeathsAchievement ( source )
- if source == theHunted then
- huntedGotKilled ( theHunter == attacker )
- end
- elseif lobby == "gangwar" and playerstatus == "playing" then
- gangwarPlayerDied ( source, attacker, damage )
- if not isInFunGangwar ( source ) then
- tdsSetElementData ( source, "GangwarTode", tdsGetElementData ( source, "GangwarTode" ) + 1 )
- end
- if not isInFunGangwar ( attacker ) then
- tdsSetElementData ( attacker, "GangwarKills", tdsGetElementData ( attacker, "GangwarKills" ) + 1 )
- tdsSetElementData ( attacker, "GangwarDamage", math.floor ( tdsGetElementData ( attacker, "GangwarDamage" ) + damage ) )
- end
- elseif lobby ~= "mainmenue" then
- if not playerKills[lobby] then
- playerKills[lobby] = {}
- playerDamages[lobby] = {}
- end
- local attackerteam = getPlayerTeam ( attacker )
- local attackername = getPlayerName ( attacker )
- playerKills[lobby][attackername] = { ( playerKills[lobby][attackername] and playerKills[lobby][attackername][1] or 0 ) + 1, attackerteam }
- playerDamages[lobby][attackername] = { ( playerDamages[lobby][attackername] and playerDamages[lobby][attackername][1] or 0 ) + damage, attackerteam }
- if tdsGetElementData ( attacker, "LobbyKills" ) then
- tdsSetElementData ( attacker, "LobbyKills", tdsGetElementData ( attacker, "LobbyKills" ) + 1 )
- tdsSetElementData ( source, "LobbyDeaths", tdsGetElementData ( source, "LobbyDeaths" ) + 1 )
- end
- triggerClientEvent ( attacker, "giveDamageClient", attacker, damage )
- end
- if part == 9 then
- setPedHeadless ( source, true )
- checkHeadshotKillsAchievement ( attacker )
- end
- if lobby ~= "gangwar" then
- if not playersGaveDamage[lobby][attackername] then
- playersGaveDamage[lobby][attackername] = {}
- end
- if not playersBecameDamage[lobby][sourcename] then
- playersBecameDamage[lobby][sourcename] = {}
- end
- playersGaveDamage[lobby][attackername][sourcename] = ( playersGaveDamage[lobby][attackername][sourcename] or 0 ) + damage
- playersBecameDamage[lobby][sourcename][attackername] = ( playersBecameDamage[lobby][sourcename][attackername] or 0 ) + damage
- end
- tdsRemoveElementData ( source, "lastHitter" )
- tdsRemoveElementData ( source, "lasthp" )
- end
- end
- end
- end
- playerdamager[source] = nil
- playertopdamager[source] = nil
- end )
- addEventHandler ( "onPlayerWeaponFire", root, function ( weapon )
- local lobby = tdsGetElementData ( source, "lobby" )
- if lobby and lobby == "standard" then
- if tdsGetElementData ( source, "weaponshots"..weapon ) then
- tdsSetElementData ( source, "weaponshots"..weapon, tdsGetElementData ( source, "weaponshots"..weapon ) + 1 )
- end
- end
- end )
- addEventHandler ( "onPlayerSpawn", root, function()
- tdsRemoveElementData ( source, "lastHitter" )
- setPedHeadless ( source, false )
- end )
- local function sortTableByBestInRound ( a, b )
- return a[3]*50+a[2] > b[3]*50+b[2]
- end
- addEventHandler ( "onRoundFinish", resourceRoot, function ( lobby )
- local damagearray = { [1] = {}, [2] = {}, [3] = {} }
- local bestdamages = {}
- dmggetdoneinround[lobby] = {}
- local counter = 0
- for pname, array in pairs ( playerDamages[lobby] ) do
- if array[2] == teams["Grove"] or array[2] == teams["2Grove"] then
- damagearray[1][pname] = { round ( array[1] ), ( playerKills[lobby][pname] and playerKills[lobby][pname][1] or 0 ) }
- elseif array[2] == teams["Triaden"] or array[2] == teams["2Triaden"] then
- damagearray[2][pname] = { round ( array[1] ), ( playerKills[lobby][pname] and playerKills[lobby][pname][1] or 0 ) }
- else
- damagearray[3][pname] = { round ( array[1] ), ( playerKills[lobby][pname] and playerKills[lobby][pname][1] or 0 ) }
- end
- counter = counter + 1
- bestdamages[counter] = { pname, round ( array[1] ), ( playerKills[lobby][pname] and playerKills[lobby][pname][1] or 0 ) }
- end
- if playersinlobby[lobby] and playersinlobby[lobby][1] then
- for i=#playersinlobby[lobby], 1, -1 do
- if isElement ( playersinlobby[lobby][i] ) then
- triggerLatentClientEvent ( playersinlobby[lobby], "syncDamagesAfterRound", 30000, false, playersinlobby[lobby][i], damagearray )
- break
- else
- table.remove ( playersinlobby[lobby], i )
- end
- end
- end
- playerDamages[lobby] = {}
- playerKills[lobby] = {}
- local alreadygiven = {}
- for attackername, array in pairs ( playersGaveDamage[lobby] ) do
- local attacker = getPlayerFromName ( attackername )
- if isElement ( attacker ) then
- if playersBecameDamage[lobby][attackername] then
- alreadygiven[attackername] = true
- triggerLatentClientEvent ( attacker, "syncDamagesGivenAfterRound", 30000, false, attacker, array, playersBecameDamage[lobby][attackername] )
- else
- triggerLatentClientEvent ( attacker, "syncDamagesGivenAfterRound", 30000, false, attacker, array )
- end
- end
- end
- for sourcename, array in pairs ( playersBecameDamage[lobby] ) do
- if not alreadygiven[sourcename] then
- local player = getPlayerFromName ( sourcename )
- if isElement ( player ) then
- triggerLatentClientEvent ( player, "syncDamagesTakenAfterRound", 30000, false, player, array )
- end
- end
- end
- playersGaveDamage[lobby] = {}
- playersBecameDamage[lobby] = {}
- table.sort ( bestdamages, sortTableByBestInRound )
- getTheMapForNextRound ( lobby, bestdamages )
- end, true, "high" )
- addCommandHandler ( "kill", function ( player )
- local lobby = tdsGetElementData ( player, "lobby" )
- if lobby and lobby ~= "mainmenue" and lobby ~= "gangwar" then
- if tdsGetElementData ( player, "status" ) == "playing" then
- get1Suicide ( player )
- local pname = getPlayerName ( player )
- if playersinlobby[lobby] and playersinlobby[lobby][1] then
- for i=1, #playersinlobby[lobby] do
- if isElement ( playersinlobby[lobby][i] ) then
- outputInformation ( playersinlobby[lobby][i], pname..langtext[tdsGetElementData ( playersinlobby[lobby][i], "language" )]["usedkill"], "info" )
- end
- end
- end
- local lastattacker = tdsGetElementData ( player, "lastHitter" )
- tdsRemoveElementData ( player, "lastHitter" )
- if lastattacker then
- lastattacker = getPlayerFromName ( lastattacker )
- if isElement ( lastattacker ) then
- checkKillsAchievement ( lastattacker )
- outputInformation ( lastattacker, pname..langtext[tdsGetElementData ( lastattacker, "language" )]["killescape"], "success" )
- outputInformation ( player, langtext[tdsGetElementData ( player, "language" )]["killgoesto"]..getPlayerName ( lastattacker ), "error" )
- killPed ( player, lastattacker, 999 )
- else
- killPed ( player )
- end
- else
- killPed ( player )
- end
- end
- end
- end )
- addEventHandler ( "givepointsfordamagekills", root, function ( bonus )
- local roundwon = tdsGetElementData ( client, "wonround" )
- local newbonus = math.floor ( bonus * ( roundwon == false and 0.5 or roundwon == true and 1.5 or 1 ) )
- tdsSetElementData ( client, "Punkte", math.floor ( tdsGetElementData ( client, "Punkte" ) + newbonus ) )
- local language = tdsGetElementData ( client, "language" )
- 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 )
- if source ~= client then
- logError ( "Jemand faket givepointsfordamagekills! "..tostring ( getPlayerName ( source ) ) .." - "..tostring ( getPlayerName ( client ) ) )
- end
- end )
- function loadLobbyDamage ( lobby, array )
- weaponDamages[lobby] = {}
- playerDamages[lobby] = {}
- dmggetdoneinround[lobby] = {}
- playerKills[lobby] = {}
- playersGaveDamage[lobby] = {}
- playersBecameDamage[lobby] = {}
- for i, v in pairs ( array ) do
- if type ( v ) == "table" then
- weaponDamages[lobby][i] = {}
- for ii, vv in pairs ( v ) do
- weaponDamages[lobby][i][ii] = vv
- end
- else
- weaponDamages[lobby][i] = v
- end
- end
- end
- function removeLobbyDamage ( lobby )
- weaponDamages[lobby] = nil
- playerDamages[lobby] = nil
- dmggetdoneinround[lobby] = nil
- playerKills[lobby] = nil
- playersGaveDamage[lobby] = nil
- playersBecameDamage[lobby] = nil
- end
- addEventHandler ( "onPlayerQuit", root, function ( )
- playerkills[source] = nil
- end )
- function setStandardLobbyHeadshotKills ( )
- for weaponID, array in pairs ( weaponDamages["standard"] ) do
- oldheadshotdmgs[weaponID] = weaponDamages["standard"][weaponID][9]
- weaponDamages["standard"][weaponID][9] = 300
- end
- end
- function resetStandardLobbyHeadshotKills ( )
- for weaponID, dmg in pairs ( oldheadshotdmgs ) do
- weaponDamages["standard"][weaponID][9] = dmg
- end
- end
- function getDamageByWeaponAndLobby ( weapon, lobby )
- return weaponDamages[lobby] and weaponDamages[lobby][weapon][3] or 0
- end
- --------------------------------
- local lifes = {}
- local _setElementHealth = setElementHealth
- function setElementHealth ( element, health )
- if getElementType ( element ) == "player" then
- if not lifes[element] then
- lifes[element] = { 0, getPedArmor ( element ) }
- end
- lifes[element][1] = health
- end
- return _setElementHealth ( element, health )
- end
- local _getElementHealth = getElementHealth
- function getElementHealth ( element )
- if getElementType ( element ) == "player" then
- if lifes[element] then
- return lifes[element][1]
- end
- end
- return _getElementHealth ( element )
- end
- local _setPedArmor = setPedArmor
- function setPedArmor ( element, armor )
- if getElementType ( element ) == "player" then
- if not lifes[element] then
- lifes[element] = { getElementHealth ( element ), 0 }
- end
- lifes[element][2] = armor
- end
- return _setPedArmor ( element, armor )
- end
- local _getPedArmor = getPedArmor
- function getPedArmor ( element )
- if getElementType ( element ) == "player" then
- if lifes[element] then
- return lifes[element][2]
- end
- end
- return _getPedArmor ( element )
- end
- local _spawnPlayer = spawnPlayer
- function spawnPlayer ( ... )
- local array = { ... }
- lifes[array[1]] = { 100, 0 }
- return _spawnPlayer ( ... )
- end
- addEventHandler ( "onPlayerQuit", root, function ( )
- lifes[source] = nil
- end )
- addEvent ( "damageInOtherWay", true )
- addEventHandler ( "damageInOtherWay", root, function ( damage, weapon, part )
- local armor = getPedArmor ( client )
- local health = getElementHealth ( client )
- if armor >= damage then
- setPedArmor ( client, armor - damage )
- tdsSetElementData ( client, "lasthp", health + armor - damage )
- else
- health = health + armor
- armor = 0
- health = health - damage
- tdsSetElementData ( client, "lasthp", health )
- if health > 0 then
- setElementHealth ( client, health )
- else
- local lasthitter = tdsGetElementData ( client, "lastHitter" ) and getPlayerFromName ( tdsGetElementData ( client, "lastHitter" ) ) or nil
- killPed ( client, lasthitter, weapon, part )
- end
- end
- end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement