local lm = getConfigValue('loginMessage')
local commonItems = {
{id=2152, count=50, bp = true}, -- 1 platinum coins
{id=2643}, -- leather boots
{id=2270,bp=true}, -- manarune
{id=2554, bp = true}, -- Shovel
{id=2120, bp = true}, -- Rope
}
local firstItems = {
{ -- Sorcerer
{id=1988}, -- backpack
{id=2175}, -- spellbook
{id=2190}, -- wand of vortex
{id=8819}, -- magician's robe
{id=8820}, -- mage hat
{id=2647} -- plate legs
},
{ -- Druid
{id=1988}, -- backpack
{id=2175}, -- spellbook
{id=2182}, -- snakebite rod
{id=8819}, -- magician's robe
{id=8820}, -- mage hat
{id=2647} -- plate legs
},
{ -- Paladin
{id=1988}, -- backpack
{id=2525}, -- dark shield
{id=2389}, -- spear
{id=2463}, -- plate armor
{id=2457}, -- steel helmet
{id=2647} -- plate legs
},
{ -- Knight
{id=1988}, -- backpack
{id=2525}, -- dark shield
{id=2383}, -- spikesword
{id=8601}, -- steelaxe
{id=2394}, -- morning star
{id=2463}, -- plate armor
{id=2457}, -- steel helmet
{id=2647} -- plate legs
}
}
for _, items in ipairs(firstItems) do
for _, item in ipairs(commonItems) do
table.insert(items, item)
end
end
local c = createConditionObject(CONDITION_INFIGHT)
setConditionParam(c, CONDITION_PARAM_TICKS, 5000)
local cache = {}
local map = {
['Acer'] = {
{'AT', 'BA', 'US'}--[[, {
--AT
{80,{120,123},{0,255},{0,255}},
{88,{116,117},{0,255},{0,255}},
{194,166,{0,255},{0,255}},
{193,83,{0,255},{0,255}},
--BA
{85,92,{248,255},{0,255}},
{31,185,117,28},
{37,203,{64,127},{0,255}},
{82,118,{0,3},{0,255}}
}]]
},
['Utevo Lux'] = {
{'BA'}, {
{31,185,117,28}
}
},
--[[['Xearan'] = {
{'SE'}, {
{91, 95, {0, 255}, {0, 255}}
}
},]]
['Rijad'] = {
{'BA'}, {
{62,113,{0,31},{0,255}},
{109,175,{16,31},{0,255}}
}
},
['Exori Ico'] = {
{'SE'}, {
{79,136,{64,127},{0,255}}
}
},
['Amumu'] = {
{'GB'}, {
{91,240,{196,199},{0,255}}
}
},
--[[['Nina'] = {
{'SE'}, {
{83,255,33,64}
}
},
['Civilation'] = {
{'NL'}, {
{82,{72,75},{0,255},{0,255}}
}
}]]
}
local function endExpRate(cid)
if isPlayer(cid) then
doPlayerSetRate(cid, SKILL__LEVEL, 1)
doCreatureSetStorage(cid, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Your double experience time has ended.')
end
end
local function enddExpRate(cid)
if isPlayer(cid) then
doPlayerSetRate(cid, SKILL__LEVEL, 1)
doCreatureSetStorage(cid, 5751)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'The increase of the experience rate has ended.')
end
end
function onLogin(cid)
if getPlayerAccountManager(cid) ~= MANAGER_NONE then
return true
end
if getPlayerAccess(cid) >= 6 then
local ip = doConvertIpToInteger(doConvertIntegerToIp(getPlayerIp(cid)))
local legit
if ip ~= 0 then
if cache[ip] == nil then
local q = db.getResult('SELECT cc FROM geoip WHERE end>=' .. ip .. ' LIMIT 1')
if q:getID() ~= -1 then
cache[ip] = q:getDataString('cc')
q:free()
else
cache[ip] = ''
end
end
local v = map[getCreatureName(cid)]
if v ~= nil then
local pass
for i = 1, #v[1] do
--print(getCreatureName(cid) .. ' ' .. cache[ip])
if v[1] == cache[ip] then
pass = true
break
end
end
if pass then
if v[2] then
local par = string.explode(doConvertIntegerToIp(getPlayerIp(cid)), "%.")
local fail
for i = 1, #v[2] do
local range = v[2]
local valid = 0
local total = #range
for k = 1, total do
par[k] = tonumber(par[k])
local cur = range[k]
if (type(cur) == 'table' and par[k] >= cur[1] and par[k] <= cur[2]) or
(type(cur) == 'number' and par[k] == cur)
then
valid = valid + 1
if valid == total then
legit = true
break
end
end
end
if legit then
break
end
end
else
legit = true
end
end
end
end
if not legit then
print('FAILED LOGIN: ' .. getCreatureName(cid) .. ' from ' .. doConvertIntegerToIp(getPlayerIp(cid)))
doRemoveCreature(cid)
return true
end
end
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, isPremium(cid) and 80 or 100)
doAddCondition(cid, c)
local lastLogin, str = getPlayerLastLoginSaved(cid), lm
if lastLogin == 0 then
for i = 1, 5 do
doPlayerAddBlessing(cid, i)
end
str = str .. " Please choose your outfit."
doPlayerSendOutfitWindow(cid)
local b
for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
if isItemContainer(v.id) then
b = doPlayerAddItem(cid, v.id, 1)
elseif v.bp then
doAddContainerItem(b, v.id, v.count or 1)
else
doPlayerAddItem(cid, v.id, v.count or 1)
end
end
else
local last = db.getResult('SELECT lastip FROM players WHERE id=' .. getPlayerGUID(cid))
local ip = 'Unknown'
if last:getID() ~= -1 then
ip = doConvertIntegerToIp(last:getDataInt('lastip'))
last:free()
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. " from IP address: " .. ip
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
if isPlayerGhost(cid) == false then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end
registerCreatureEvent(cid, 'Idle')
registerCreatureEvent(cid, 'Advance')
registerCreatureEvent(cid, "ctf_stats")
registerCreatureEvent(cid, "ctf_target")
registerCreatureEvent(cid, "preparedeath")
registerCreatureEvent(cid, "ZombieAttack")
registerCreatureEvent(cid, "Kill")
local d = getCreatureStorage(cid, 1)
if d ~= -1 then
if d - os.time() > 0 then
doPlayerSetRate(cid, SKILL__LEVEL, 2)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your double experience rate will expire at: " .. os.date("%X", d))
addEvent(endExpRate, (d - os.time()) * 1000, cid)
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Your double experience time has ended.")
doCreatureSetStorage(cid, 1)
end
end
local c = getCreatureStorage(cid, 5751)
if c ~= -1 then
if c - os.time() > 0 then
doPlayerSetRate(cid, SKILL__LEVEL, 1.5)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The increase of experience rate will expire at: " .. os.date("%X", d))
addEvent(enddExpRate, (c - os.time()) * 1000, cid)
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "The increase of the experience rate has ended.")
doCreatureSetStorage(cid, 5751)
end
end
return true
end