Here is my reborn system, there you have a easy way to config it.
creaturescripts.xml
login.lua
Lua:
local config =
{
levelLimit = 400, --limit of course
kickTime = 60000, --(in miliseconds) time before player gets kicked
removeInventory = true, --remove items from inventory after reset? (to prevent players using items with level required after reset)
newLevel = 20, --new level after reset
newExp = 4500, --new exp after reset
resetSkills = true, --reset skills?
skillLevel = 11, --new skills level after reset
resetMagic = true, --reset magic level?
newMagic = 2, --new magic level after reset
resetHealth = true, --reset health?
newHealth = 180, --new player health/healthmax after reset
resetMana = true, --reset mana?
newMana = 240, --new player mana/manamax after reset
resetVocation = true --delete promotion?
}
local displayMessage, message = true, "You have reached the level limit, you will be kicked in " .. config.kickTime / 1000 .. " seconds."
function onAdvance(cid, skill, oldlevel, newLevel)
if(skill == SKILL__LEVEL and isPlayer(cid)) then
if newLevel >= config.levelLimit then
local queries = {}
local id = getPlayerGUID(cid)
if displayMessage then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, message)
end
if config.removeInventory then
table.insert(queries, "delete from player_items where player_id = " .. id .. ";")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Save your items on the depot or will be deleted after the reset.")
end
if config.resetSkills then
for i = 1, 6 do
table.insert(queries, "update player_skills set value = " .. config.skillLevel .. ", count = 0 where skillid = " .. i - 1 .. " and player_id = " .. id .. ";")
end
end
table.insert(queries, "update players set level = " .. config.newLevel .. ", experience = " .. config.newExp .. "" .. (config.resetMagic and ", maglevel = " .. config.newMagic .. "" or "") .. (config.resetHealth and ", health = " .. config.newHealth .. ", healthmax = " .. config.newHealth .. "" or "") .. (config.resetMana and ", mana = " .. config.newMana .. ", manamax = " .. config.newMana .. "" or "") .. (config.resetVocation and ", promotion = 0" or "") .. ";")
addEvent(reset, config.kickTime, getCreatureName(cid), queries)
else
if config.levelLimit - newLevel <= 10 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need " .. config.levelLimit - newLevel .. " levels more to reach the limit".. (config.removeInventory and ", remember to save your items at the depot" or "") .. ".")
end
end
end
return true
end
function reset(p, queries)
if getPlayerByName(p) ~= nil then
doRemoveCreature(getCreatureByName(p))
db.executeQuery("update players set online = 0 where id = " .. getPlayerGUIDByName(p) .. ";")
end
for i = 1, table.maxn(queries) do
if not db.executeQuery(queries[i]) then
print("[RESET] Unable to execute query: " .. queries[i])
end
end
return true
end
creaturescripts.xml
XML:
<event type="advance" name="reset" event="script" value="reset.lua"/>
login.lua
Lua:
registerCreatureEvent(cid, "reset")