- Joined
- Dec 30, 2007
- Messages
- 529
- Solutions
- 5
- Reaction score
- 191
Hello,
I've made a script to support PvP on optional pvp servers. Players that kills higher level will get experience as on pvp enforced server.
Features:
- Real tibia formula for pvp-enforced servers
- doesn't give exp in pvp arenas (pvp tiles)
- divide exp to the whole deathlist (that are lower level of course)
creaturescripts/scripts/pvpenfo.lua
Add this line to creaturescripts.xml
Add this line to creaturescripts/scripts/login.lua
Tested and works on 9.1+ server.
Have fun.
I've made a script to support PvP on optional pvp servers. Players that kills higher level will get experience as on pvp enforced server.
Features:
- Real tibia formula for pvp-enforced servers
- doesn't give exp in pvp arenas (pvp tiles)
- divide exp to the whole deathlist (that are lower level of course)
creaturescripts/scripts/pvpenfo.lua
Code:
function onPrepareDeath(cid, deathList)
local tile = getTileInfo(getPlayerPosition(cid))
if(tile.hardcore == false) then
local pl_count = table.getn(deathList)
local j = 0
for _, pid in ipairs(deathList) do
if (isPlayer(cid) and isPlayer(pid) and getPlayerLevel(cid) > getPlayerLevel(pid)) then
local priorita = 1 - (j * 0.1)
local exp = 0
if (pl_count > 2) then
exp = math.floor((((1 - (getPlayerLevel(pid) * 1.0) / getPlayerLevel(cid)) * 0.05 * getPlayerExperience(cid)) / pl_count) * priorita)
else
exp = math.floor((((1 - (getPlayerLevel(pid) * 1.0) / getPlayerLevel(cid)) * 0.05 * getPlayerExperience(cid)) / (pl_count + 2)) * priorita)
end
doPlayerAddExp(pid, exp)
local pos = getPlayerPosition(pid)
doPlayerSendTextMessage(pid, MESSAGE_EXPERIENCE, "You gained " .. exp .. " experience for killing higher level than you.", exp, COLOR_WHITE, pos)
for _, spec in ipairs(getSpectators(pos, 7, 5, false)) do
if (isPlayer(spec) and spec ~= pid) then
doPlayerSendTextMessage(spec, MESSAGE_EXPERIENCE, getCreatureName(pid) .. " gained " .. exp .. " experience for killing " .. getCreatureName(cid) .. ".", exp, COLOR_WHITE, pos)
end
end
end
j = j + 1
end
end
return true
end
Add this line to creaturescripts.xml
Code:
<event type="preparedeath" name="pvpenfo" event="script" value="pvpenfo.lua"/>
Add this line to creaturescripts/scripts/login.lua
Code:
registerCreatureEvent(cid, "pvpenfo")
Tested and works on 9.1+ server.
Have fun.
Last edited: