Keraxel
Ω Obfuscator Ω
Idea: http://otland.net/f35/level-diference-protection-pvp-22098/
The script allows for attack only players with level which is lower or highter from typed number (config.maxDiff).
Also I've added percent type so you can set it in percents. For example:
Works only with TFS 0.3.3+
data/creaturescripts/scripts/levelDiff.lua
data/creaturescripts/creaturescripts.xml
data/creaturescripts/scripts/login.lua,
Before:
Add:
Regards,
Keraxel.
The script allows for attack only players with level which is lower or highter from typed number (config.maxDiff).
Also I've added percent type so you can set it in percents. For example:
Code:
maxDiff = 30
player1 level - 100
player2 level - 131 - 31% more than player1
So theese players cannot attack each other.
Works only with TFS 0.3.3+
data/creaturescripts/scripts/levelDiff.lua
Lua:
local config = {
diffType = 1, -- 1 = NORMAL/ 2 = PERCENT
maxDiff = 30
}
function onCombat(cid, target)
if isPlayer(cid) ~= TRUE or isPlayer(target) ~= TRUE then
return TRUE
end
if config. diffType == 1 then -- if NORMAL
if math.abs(getPlayerLevel(cid) - getPlayerLevel(target)) > config.maxDiff then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER)
return FALSE
end
elseif config.diffType == 2 then --if PERCENT
local levels = {getPlayerLevel(cid), getPlayerLevel(target)}
table.sort(levels)
if (((levels[2] - levels[1]) * 100) / levels[1]) > config.maxDiff then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER)
return FALSE
end
else
print("DEBUG: Wrong config.diffType")
end
return TRUE
end
data/creaturescripts/creaturescripts.xml
PHP:
<event type="combat" name="KillProtection" script="levelDiff.lua" />
data/creaturescripts/scripts/login.lua,
Before:
Lua:
return TRUE
Lua:
registerCreatureEvent(cid, "KillProtection")
Regards,
Keraxel.
Last edited: