Guest User

Untitled

a guest
Apr 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. -- PvP protection system by Znote
  2. -- This script launches when you(cid) is being attacked.
  3. -- If you are attacked by a player who is higher than 25% your own level,
  4. -- or lower than 25% of your level, then they will not deal any damage toward you
  5. -- what so ever.
  6. function onStatsChange(cid, attacker, type, combat, value)
  7.         if isPlayer(attacker) then
  8.  
  9.                 -- calculations (Make sure they are EXACLY the same as pvptarget.lua).
  10.                 local maxCalc = getPlayerLevel(cid) * 1.25
  11.                 local minCalc = getPlayerLevel(cid) * 0.75
  12.                
  13.                 local maxCal = getPlayerLevel(attacker) * 1.25
  14.                 local minCal = getPlayerLevel(attacker) * 0.75
  15.  
  16.                 -- integer friendly results
  17.                 local maxLvl = math.floor(maxCalc)
  18.                 local minLvl = math.floor(minCalc)
  19.                
  20.                 local maxL = math.floor(maxCal)
  21.                 local minL = math.floor(minCal)
  22.  
  23.                 if getPlayerLevel(attacker) >= minLvl and getPlayerLevel(attacker) <= maxLvl then
  24.                     if getPlayerLevel(cid) >= minL and getPlayerLevel(cid) <= maxL then
  25.                         return true
  26.                     end
  27.                 end
  28.         else -- if attacker is not a player. (meaning monster or object like traps).
  29.             return true
  30.         end
  31. end
Add Comment
Please, Sign In to add comment