local events = {
'AdvanceSave'
}
local AccPorIp = 4
local config = {
[0] = {
--club, coat
items = {{2398, 1}, {2461, 1}, {2467, 1}, {2649, 1}},
--container rope, shovel, red apple
container = {{2120, 1}, {2554, 1}, {2674, 2}}
},
[1] = {
--equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf
items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
--container platinum coin, rope, shovel, mana potion
container = {{7620, 5}}
},
[2] = {
--equipment spellbook, snakebite rod, magician's robe, mage hat, studded legs, leather boots scarf
items = {{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
--container platinum coin, rope, shovel, mana potion
container = {{7620, 5}}
},
[3] = {
--equipment dwarven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet
items = {{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
--container platinum coin, rope, shovel, health potion, mana potion
container = {{7618, 5}, {7620, 5}}
},
[4] = {
--equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf
items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
--container platinum coin, jagged sword, daramian mace, rope, shovel, health potion, mana potion
container = {{8602, 1}, {2439, 1}, {7618, 5}, {7620, 5}}
}
}
function onLogin(player)
local mc = 0
for _, verificar in ipairs(Game.getPlayers()) do
if player:getIp() == verificar:getIp() then
mc = mc + 1
if mc > AccPorIp then return false end
end
end
local targetVocation = config[player:getVocation():getId()]
local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
if player:getLastLoginSaved() <= 0 then
loginStr = loginStr .. " Please choose your outfit."
player:sendOutfitWindow()
player:openChannel(CHANNEL_DEFAULT)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "If you wish to change your hometown talk to Kasmir, Quentin, Father Zuke or Isaaru and ask for a transfer.")
-- First time login items
if targetVocation then
for i = 1, #targetVocation.items do
player:addItem(targetVocation.items[i][1], targetVocation.items[i][2])
end
local backpack = player:getVocation():getId() == 0 and player:addItem(1987) or player:addItem(1988)
if backpack then
for i = 1, #targetVocation.container do
backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
end
end
end
-- First time login tell other players about it!
print("\nWelcome to our newest member ["..player:getName().."]!\n")
db.query("INSERT INTO `znote_global_storage` (`key`,`value`) VALUES ('1stLog_"..player:getAccountId().."', '"..os.time().."');")
local players = Game.getPlayers()
local playerName = player:getName()
for _, onlineplayer in ipairs(players) do
onlineplayer:sendTextMessage(MESSAGE_EVENT_ORANGE, "Welcome to our newest member ["..playerName.."]!")
end
else
if loginStr ~= "" then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, loginStr)
player:openChannel(CHANNEL_DEFAULT)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "The following talkactions are avaible: !bosscheck, !spells, !soft, !aol, !blesscheck, !critical, !dodge.")
end
loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "If you wish to change your hometown talk to Kasmir, Quentin, Father Zuke or Isaaru and ask for a transfer.")
end
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, loginStr)
-- Stamina
nextUseStaminaTime[player.uid] = 0
-- Promotion
local vocation = player:getVocation()
local promotion = vocation:getPromotion()
local value = player:getStorageValue(PlayerStorageKeys.promotion)
if value == 1 then
player:setVocation(promotion)
end
-- Events
player:registerEvent("PlayerDeath")
player:registerEvent("DropLoot")
-- Fix HP/Mana/Cap to match CIP, assume player left rook at level 8
if player:getVocation():getId() == 0 then
calchp = 5 * (player:getLevel() + 29)
calcmana = 5 * (player:getLevel() + 10)
calccap = 10 * (player:getLevel() + 39)
elseif player:getVocation():getId() == 1 or player:getVocation():getId() == 5 then
calchp = 5 * (player:getLevel() + 29)
calcmana = 5 * ((6 * player:getLevel()) - (5 * 8) + 10)
calccap = 10 * (player:getLevel() + 39)
elseif player:getVocation():getId() == 2 or player:getVocation():getId() == 6 then
calchp = 5 * (player:getLevel() + 29)
calcmana = 5 * ((6 * player:getLevel()) - (5 * 8) + 10)
calccap = 10 * (player:getLevel() + 39)
elseif player:getVocation():getId() == 3 or player:getVocation():getId() == 7 then
calchp = 5 * ((2 * player:getLevel()) - 8 + 29)
calcmana = 5 * ((3 * player:getLevel())- (2 * 8) + 10)
calccap = 10 * ((2 * player:getLevel()) - 8 + 39)
elseif player:getVocation():getId() == 4 or player:getVocation():getId() == 8 then
calchp = 5 *((3 * player:getLevel()) - (2 * 8) + 29)
calcmana = 5 *(player:getLevel() + 10)
calccap = 5 *((5 * player:getLevel()) - (5 * 8) + 94)
end
if player:getMaxHealth() ~= calchp then
player:setMaxHealth(calchp)
player:addHealth(calchp)
end
if player:getMaxMana() ~= calcmana then
player:setMaxMana(calcmana)
player:addMana(calcmana)
end
if player:getCapacity() ~= (calccap * 100) then
player:setCapacity(calccap * 100)
end
player:setOutfit(player:getOutfit())
return true
end