Well I didn't make these functions, but I forgot where I found them.
So, credits to the original maker!
First run this query in your database:
Code:
CREATE TABLE `account_storage`
(
`account_id` INT NOT NULL DEFAULT 0,
`key` INT UNSIGNED NOT NULL DEFAULT 0,
`value` VARCHAR(255) NOT NULL DEFAULT '0',
KEY (`account_id`), UNIQUE (`account_id`, `key`),
FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE CASCADE
) ENGINE =MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=48 ;
And then go into data/lib/function.lua and add these functions:
PHP:
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
and
PHP:
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