CREATE TABLE IF NOT EXISTS `accounts_storage` (
`id` int(11) NOT NULL DEFAULT '0',
`key` int(10) NOT NULL DEFAULT '0',
`value` varchar(255) NOT NULL DEFAULT '0',
UNIQUE KEY `id_key` (`id`,`key`),
KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
function setAcccountStorageValue(cid, key, value)
local result = db.getResult("SELECT `key` FROM `accounts_storage` WHERE (`id` = '" .. getPlayerAccountId(cid) .. "' and `key` = '" .. key .. "');")
if result:getDataInt("key") == nil then
return db.executeQuery("INSERT INTO `accounts_storage` (`id`, `key`, `value`) VALUES (" .. getPlayerAccountId(cid) .. ", " .. key .. ", " .. value .. ")"), result:free()
else
return db.executeQuery("UPDATE `accounts_storage` SET `value` = " .. value .. " WHERE (`id` = '" .. getPlayerAccountId(cid) .. "' and `key` = '" .. key .. "');"), result:free()
end
end
function getAccountStorageValue(cid, key)
local value = db.getResult("SELECT `value` FROM `accounts_storage` WHERE (`id` = '" .. getPlayerAccountId(cid) .. "' and `key` = '" .. key .. "');")
return value:getDataInt("value"), value:free()
end
local lastLogin = getPlayerLastLoginSaved(cid)
if(lastLogin > 0) then
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, text)
else
doPlayerSendOutfitWindow(cid)
end
local lastLogin = getPlayerLastLoginSaved(cid)
if(lastLogin > 0) then
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, text)
else
doPlayerSendOutfitWindow(cid)
if getAccountStorageValue(cid, 1000) < 1 then
setPlayerStorageValue(cid, 11551, (getPlayerStorageValue(cid,11551) + 3))
setAccountStorageValue(cid, 1000, 1)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, "You've received 3 free VIP days.")
end
end
local config = {
loginMessage = getConfigValue('loginMessage'),
useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}
function onLogin(cid)
fly.login(cid)
local loss = getConfigValue('deathLostPercent')
if(loss ~= nil) then
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
end
local accountManager = getPlayerAccountManager(cid)
if(accountManager == MANAGER_NONE) then
local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
if(lastLogin > 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
else
str = str .. " Please choose your outfit."
doPlayerSendOutfitWindow(cid)
if getAccountStorageValue(cid, 1000) < 1 then
setPlayerStorageValue(cid, 11551, (getPlayerStorageValue(cid,11551) + 3))
setAccountStorageValue(cid, 1000, 1)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, "You've received 3 free VIP days.")
end
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
elseif(accountManager == MANAGER_NAMELOCK) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
elseif(accountManager == MANAGER_ACCOUNT) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
end
if(not isPlayerGhost(cid)) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end
registerCreatureEvent(cid, "ZombieAttack")
registerCreatureEvent(cid, "Mail")
registerCreatureEvent(cid, "GuildMotd")
registerCreatureEvent(cid, "Idle")
registerCreatureEvent(cid, "getmoney")
registerCreatureEvent(cid, "getmoney2")
if(config.useFragHandler) then
registerCreatureEvent(cid, "SkullCheck")
end
registerCreatureEvent(cid, "playerd")
registerCreatureEvent(cid, "logoout")
registerCreatureEvent(cid, "BlessLogin")
registerCreatureEvent(cid, "ReportBug")
registerCreatureEvent(cid, "AdvanceSave")
registerCreatureEvent(cid, "forever amulet")
registerCreatureEvent(cid, "skull amulet")
registerCreatureEvent(cid, "charge amulet")
return true
end
function setAcccountStorageValue(cid, key, value)
local result = db.getResult("SELECT `key` FROM `accounts_storage` WHERE (`id` = '" .. getPlayerGUID(cid) .. "' and `key` = '" .. key .. "');")
if result:getDataInt("key") == nil then
return db.executeQuery("INSERT INTO `accounts_storage` (`id`, `key`, `value`) VALUES (" .. getPlayerGUID(cid) .. ", " .. key .. ", " .. value .. ")"), result:free()
else
return db.executeQuery("UPDATE `accounts_storage` SET `value` = " .. value .. " WHERE (`id` = '" .. getPlayerGUID(cid) .. "' and `key` = '" .. key .. "');"), result:free()
end
end
function getAccountStorageValue(cid, key)
local value = db.getResult("SELECT `value` FROM `accounts_storage` WHERE (`id` = '" .. getPlayerGUID(cid) .. "' and `key` = '" .. key .. "');")
return value:getDataInt("value"), value:free()
end
function setAcccountStorageValue(cid, key, value)
local result = db.getResult("SELECT `key` FROM `accounts_storage` WHERE (`id` = '" .. getPlayerAccountId(cid) .. "' and `key` = '" .. key .. "');")
if result:getDataInt("key") == nil then
return db.executeQuery("INSERT INTO `accounts_storage` (`id`, `key`, `value`) VALUES (" .. getPlayerAccountId(cid) .. ", " .. key .. ", " .. value .. ")"), result:free()
else
return db.executeQuery("UPDATE `accounts_storage` SET `value` = " .. value .. " WHERE (`id` = '" .. getPlayerAccountId(cid) .. "' and `key` = '" .. key .. "');"), result:free()
end
end
function getAccountStorageValue(cid, key)
local value = db.getResult("SELECT `value` FROM `accounts_storage` WHERE (`id` = '" .. getPlayerAccountId(cid) .. "' and `key` = '" .. key .. "');")
return value:getDataInt("value"), value:free()
end
local config = {
loginMessage = getConfigValue('loginMessage'),
useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}
function onLogin(cid)
fly.login(cid)
local loss = getConfigValue('deathLostPercent')
if(loss ~= nil) then
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
end
local accountManager = getPlayerAccountManager(cid)
if(accountManager == MANAGER_NONE) then
local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
if(lastLogin > 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
else
str = str .. " Please choose your outfit."
doPlayerSendOutfitWindow(cid)
if getAccountStorageValue(getPlayerGUID(cid), 1000) < 1 then
setPlayerStorageValue(cid, 11551, (getPlayerStorageValue(cid,11551) + 3))
setAccountStorageValue(getPlayerGUID(cid), 1000, 1)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, "You've received 3 free VIP days.")
end
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
elseif(accountManager == MANAGER_NAMELOCK) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
elseif(accountManager == MANAGER_ACCOUNT) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
end
if(not isPlayerGhost(cid)) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end
registerCreatureEvent(cid, "ZombieAttack")
registerCreatureEvent(cid, "Mail")
registerCreatureEvent(cid, "GuildMotd")
registerCreatureEvent(cid, "Idle")
registerCreatureEvent(cid, "getmoney")
registerCreatureEvent(cid, "getmoney2")
if(config.useFragHandler) then
registerCreatureEvent(cid, "SkullCheck")
end
registerCreatureEvent(cid, "playerd")
registerCreatureEvent(cid, "logoout")
registerCreatureEvent(cid, "BlessLogin")
registerCreatureEvent(cid, "ReportBug")
registerCreatureEvent(cid, "AdvanceSave")
registerCreatureEvent(cid, "forever amulet")
registerCreatureEvent(cid, "skull amulet")
registerCreatureEvent(cid, "charge amulet")
return true
end