Advertisement
Guest User

Untitled

a guest
May 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.66 KB | None | 0 0
  1. --Client
  2. weaponDamages = {}
  3. weaponDamages[8] = 35
  4. weaponDamages[22] = 10
  5. weaponDamages[23] = 0
  6. weaponDamages[24] = 47
  7. weaponDamages[25] = 20
  8. weaponDamages[28] = 5
  9. weaponDamages[29] = 11
  10. weaponDamages[32] = 5
  11. weaponDamages[30] = 8
  12. weaponDamages[31] = 6
  13. weaponDamages[33] = 23
  14. weaponDamages[34] = 50
  15. weaponDamages[51] = 40
  16.  
  17. addEventHandler("onClientPlayerDamage", getRootElement(), function(attacker, weapon, part, loss)
  18.     if weaponDamages[weapon] then
  19.         cancelEvent()
  20.     end
  21.     if attacker and weapon == 23 then
  22.         triggerServerEvent("onPlayerTazer", root, source, attacker)
  23.         cancelEvent()
  24.     end
  25. end)
  26.  
  27. addEventHandler("onClientPlayerDamage", root, function(attacker, weapon, bodypart, loss)
  28.     if attacker == getLocalPlayer() then
  29.         if attacker and weapon and bodypart and loss then
  30.             if weaponDamages[weapon] then
  31.                 triggerServerEvent("damageCalcServer", root, attacker, weapon, bodypart, loss)
  32.             end
  33.         end
  34.     elseif getLocalPlayer() == source then
  35.         if attacker and weapon and bodypart and loss then
  36.             if weaponDamages[weapon] then
  37.                 cancelEvent()
  38.             end
  39.         end
  40.     end
  41. end)
  42.  
  43. -- Server
  44.  
  45. function damagePlayer(player, amount, damager, weapon)
  46.     outputChatBox("Step 1")
  47.     if isElement(player) then
  48.         outputChatBox("Step 2")
  49.         local armor = getPedArmor(player)
  50.         local health = getElementHealth(player)
  51.  
  52.         if armor > 0 then
  53.             if armor >= amount then
  54.                 setPedArmor(player, armor - amount)
  55.                 outputChatBox("Step 3")
  56.             else
  57.                 outputChatBox("Step 4")
  58.                 setPedArmor(player, 0)
  59.                 amount = math.abs(armor - amount)
  60.                 setElementHealth(player, health - amount)
  61.                 if getElementHealth(player) - amount <= 0 then
  62.                     killPed(player, damager, weapon, 3, false)
  63.                     outputChatBox("Step 5")
  64.                 end
  65.             end
  66.         else
  67.             if getElementHealth(player) - amount <= 0 then
  68.                 killPed(player, damager, weapon, 3, false)
  69.                 outputChatBox("Step 6")
  70.             end
  71.             setElementHealth(player, health - amount)
  72.         end
  73.     end
  74. end
  75.  
  76. addEvent("damageCalcServer", true)
  77. addEventHandler("damageCalcServer", root, function(attacker, weapon, bodypart, loss, player)
  78.     if attacker and weapon and bodypart and loss then
  79.         basicDMG = weaponDamages[weapon]
  80.         if weapon == 0 then
  81.             if getPedFightingStyle(attacker) == 7 or getPedFightingStyle(attacker) == 15 or getPedFightingStyle(attacker) == 16 then
  82.                 loss = loss / 2
  83.             end
  84.         end
  85.         if attacker and weapon == 23 then
  86.             if getElementData(attacker, "Duty") and getElementData(attacker, "Fraktion") == 1 or getElementData(attacker, "Fraktion") == 6 or getElementData(attacker, "Fraktion") == 8 then
  87.                 triggerTazer(player, attacker)
  88.             end
  89.         end
  90.         if bodypart == 9 then
  91.             multiply = 1.5
  92.         else
  93.             multiply = 1.0
  94.         end
  95.         if weaponDamages[weapon] then
  96.             damagePlayer(player, basicDMG * multiply, attacker, weapon)
  97.         else
  98.             damagePlayer(player, loss, attacker, weapon)
  99.         end
  100.         if getElementData(attacker, "imGW") == true and getElementData(player, "imGW") == true then
  101.             if getElementData(player, "Fraktion") ~= getElementData(attacker, "Fraktion") then
  102.                 triggerClientEvent(attacker, "add_damage", attacker, basicDMG * multiply)
  103.             end
  104.         end
  105.     end
  106. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement