local vocations = {
[1] = {town_id = 1, max_health = 45, max_mana = 5, max_cap = 425}, -- Sorcerer
[2] = {town_id = 2, max_health = 100, max_mana = 100, max_cap = 100}, -- Druid
[3] = {town_id = 3, max_health = 100, max_mana = 100, max_cap = 100}, -- Paladin
[4] = {town_id = 4, max_health = 100, max_mana = 100, max_cap = 100} -- Knight
}
function onLogin(player)
if player:getLastLoginSaved() > 0 or player:getLevel() > 1 then
return true
end
local vocation_id = player:getVocation():getBase():getId()
if not vocations[vocation_id] then
return true
end
player:setMaxHealth(vocations[vocation_id].max_health)
player:setMaxMana(vocations[vocation_id].max_mana)
player:setCapacity(vocations[vocation_id].max_cap)
local town = Town(vocations[vocation_id].town_id)
local temple_pos = town:getTemplePosition()
player:setTown(town)
player:teleportTo(temple_pos)
temple_pos:sendMagicEffect(CONST_ME_TELEPORT)
return true
end
function onLogin(player)
local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
if player:getLastLoginSaved() <= 0 then
loginStr = loginStr .. " Please choose your outfit."
player:sendOutfitWindow()
else
if loginStr ~= "" then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
end
loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
end
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
-- Stamina
nextUseStaminaTime[player.uid] = 0
-- Promotion
local vocation = player:getVocation()
local promotion = vocation:getPromotion()
if player:isPremium() then
local value = player:getStorageValue(STORAGEVALUE_PROMOTION)
if not promotion and value ~= 1 then
player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
elseif value == 1 then
player:setVocation(promotion)
end
elseif not promotion then
player:setVocation(vocation:getDemotion())
end
-- Events
player:registerEvent("PlayerDeath")
player:registerEvent("DropLoot")
return true
end