function onLogin(cid)
local config =
{
days = 5
premiumStor = 321321
}
local FALSE = -1
local TRUE = 1
if getPlayerStorageValue(cid, config.premiumStor) == FALSE then
doPlayerAddPremiumDays(cid, days)
setPlayerStorageValue(cid, config.premiumStor, TRUE)
end
return TRUE
end
if getPlayerStorageValue(cid, config.premiumStor) == FALSE then
function onLogin(cid)
local config =
{
days = 5
premiumStor = 321321
}
local FALSE = -1
local TRUE = 1
if getAccountStorageValue(cid, config.premiumStor) == FALSE then
doPlayerAddPremiumDays(cid, days)
setAccountStorageValue(cid, config.premiumStor, TRUE)
end
return TRUE
end
local config =
{
days = 5,
storage = 321321
}
function onLogin(cid)
if(getAccountStorageValue(cid, config.storage) == -1) then
doPlayerAddPremiumDays(cid, config.days)
setAccountStorageValue(cid, config.storage, 1)
end
return TRUE
end
function onLogin(cid)
local config =
{
days = 5
premiumStor = 321321
}
local FALSE = -1
local TRUE = 1
if getAccountStorageValue(cid, config.premiumStor) == FALSE then
doPlayerAddPremiumDays(cid, config.days)
setAccountStorageValue(cid, config.premiumStor, TRUE)
end
return TRUE
end
<event type="login" name="FreePremium" script="free_premium.lua"/>
function getAccountStorageValue(accid, key)
local value = db.getResult("SELECT `value` FROM `account_storage` WHERE `account_id` = " .. accid .. " and `key` = " .. key .. " LIMIT 1;")
if(value:getID() ~= -1) then
return value:getDataInt("value")
else
return -1
end
value:free()
end
function setAccountStorageValue(accid, key, value)
local getvalue = db.getResult("SELECT `value` FROM `account_storage` WHERE `account_id` = " .. accid .. " and `key` = " .. key .. " LIMIT 1;")
if(getvalue:getID() ~= -1) then
db.executeQuery("UPDATE `account_storage` SET `value` = " .. accid .. " WHERE `key`=" .. key .. " LIMIT 1');")
getvalue:free()
return 1
else
db.executeQuery("INSERT INTO `account_storage` (`account_id`, `key`, `value`) VALUES (" .. accid .. ", " .. key .. ", '"..value.."');")
return 1
end
end
CREATE TABLE `account_storage` (
`account_id` int(11) NOT NULL default '0',
`key` int(10) unsigned NOT NULL default '0',
`value` varchar(255) NOT NULL default '0',
UNIQUE KEY `account_id_2` (`account_id`,`key`),
KEY `account_id` (`account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;