Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- PvP protection system by Znote
- -- This script launches when you(cid) is being attacked.
- -- If you are attacked by a player who is higher than 25% your own level,
- -- or lower than 25% of your level, then they will not deal any damage toward you
- -- what so ever.
- function onStatsChange(cid, attacker, type, combat, value)
- if isPlayer(attacker) then
- -- calculations (Make sure they are EXACLY the same as pvptarget.lua).
- local maxCalc = getPlayerLevel(cid) * 1.25
- local minCalc = getPlayerLevel(cid) * 0.75
- local maxCal = getPlayerLevel(attacker) * 1.25
- local minCal = getPlayerLevel(attacker) * 0.75
- -- integer friendly results
- local maxLvl = math.floor(maxCalc)
- local minLvl = math.floor(minCalc)
- local maxL = math.floor(maxCal)
- local minL = math.floor(minCal)
- if getPlayerLevel(attacker) >= minLvl and getPlayerLevel(attacker) <= maxLvl then
- if getPlayerLevel(cid) >= minL and getPlayerLevel(cid) <= maxL then
- return true
- end
- end
- else -- if attacker is not a player. (meaning monster or object like traps).
- return true
- end
- end
Add Comment
Please, Sign In to add comment