Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Client
- weaponDamages = {}
- weaponDamages[8] = 35
- weaponDamages[22] = 10
- weaponDamages[23] = 0
- weaponDamages[24] = 47
- weaponDamages[25] = 20
- weaponDamages[28] = 5
- weaponDamages[29] = 11
- weaponDamages[32] = 5
- weaponDamages[30] = 8
- weaponDamages[31] = 6
- weaponDamages[33] = 23
- weaponDamages[34] = 50
- weaponDamages[51] = 40
- addEventHandler("onClientPlayerDamage", getRootElement(), function(attacker, weapon, part, loss)
- if weaponDamages[weapon] then
- cancelEvent()
- end
- if attacker and weapon == 23 then
- triggerServerEvent("onPlayerTazer", root, source, attacker)
- cancelEvent()
- end
- end)
- addEventHandler("onClientPlayerDamage", root, function(attacker, weapon, bodypart, loss)
- if attacker == getLocalPlayer() then
- if attacker and weapon and bodypart and loss then
- if weaponDamages[weapon] then
- triggerServerEvent("damageCalcServer", root, attacker, weapon, bodypart, loss)
- end
- end
- elseif getLocalPlayer() == source then
- if attacker and weapon and bodypart and loss then
- if weaponDamages[weapon] then
- cancelEvent()
- end
- end
- end
- end)
- -- Server
- function damagePlayer(player, amount, damager, weapon)
- outputChatBox("Step 1")
- if isElement(player) then
- outputChatBox("Step 2")
- local armor = getPedArmor(player)
- local health = getElementHealth(player)
- if armor > 0 then
- if armor >= amount then
- setPedArmor(player, armor - amount)
- outputChatBox("Step 3")
- else
- outputChatBox("Step 4")
- setPedArmor(player, 0)
- amount = math.abs(armor - amount)
- setElementHealth(player, health - amount)
- if getElementHealth(player) - amount <= 0 then
- killPed(player, damager, weapon, 3, false)
- outputChatBox("Step 5")
- end
- end
- else
- if getElementHealth(player) - amount <= 0 then
- killPed(player, damager, weapon, 3, false)
- outputChatBox("Step 6")
- end
- setElementHealth(player, health - amount)
- end
- end
- end
- addEvent("damageCalcServer", true)
- addEventHandler("damageCalcServer", root, function(attacker, weapon, bodypart, loss, player)
- if attacker and weapon and bodypart and loss then
- basicDMG = weaponDamages[weapon]
- if weapon == 0 then
- if getPedFightingStyle(attacker) == 7 or getPedFightingStyle(attacker) == 15 or getPedFightingStyle(attacker) == 16 then
- loss = loss / 2
- end
- end
- if attacker and weapon == 23 then
- if getElementData(attacker, "Duty") and getElementData(attacker, "Fraktion") == 1 or getElementData(attacker, "Fraktion") == 6 or getElementData(attacker, "Fraktion") == 8 then
- triggerTazer(player, attacker)
- end
- end
- if bodypart == 9 then
- multiply = 1.5
- else
- multiply = 1.0
- end
- if weaponDamages[weapon] then
- damagePlayer(player, basicDMG * multiply, attacker, weapon)
- else
- damagePlayer(player, loss, attacker, weapon)
- end
- if getElementData(attacker, "imGW") == true and getElementData(player, "imGW") == true then
- if getElementData(player, "Fraktion") ~= getElementData(attacker, "Fraktion") then
- triggerClientEvent(attacker, "add_damage", attacker, basicDMG * multiply)
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement