function getAccountStorageValue(accid, key)
local resultId = db.storeQuery("SELECT `account_id`, `key` FROM `account_storage` WHERE `account_id` = " .. accid .. " and `key` = " .. key)
if resultId ~= false then
return result.getNumber(resultId, 'key')
else
return -1
end
return resultId:free()
end
function setAccountStorageValue(accid, key, value)
local resultId = db.storeQuery("SELECT `value` FROM `account_storage` WHERE `account_id` = " .. accid .. " and `key` = " .. key)
if resultId ~= false then
db.query("UPDATE `account_storage` SET `value` = " .. accid .. " WHERE `key`=" .. key .. " LIMIT 1');")
else
db.query("INSERT INTO `account_storage` (`account_id`, `key`, `value`) VALUES (" .. accid .. ", " .. key .. ", '"..value.."');")
end
return true
end
Modo de uso :
function onLogin(player)
local storage = 545465
local pid = player:getGuid()
local query = db.storeQuery("SELECT `account_id` FROM `players` WHERE `id` = ".. pid)
local value = result.getNumber(query, 'account_id')
if getAccountStorageValue(value, storage) < 1 then
player:addPremiumDays(3)
setAccountStorageValue(value, storage, 1)
end
return true
end
Script original veio do teckman, eu adaptei pras novas versões.
info
Grupo: Conde
Registrado: 07/04/15
Posts: 962
Reputação: +258
Gênero: Masculino
Essa é uma função que criei a uns meses já.
Primeiro vá ao seu phpmyadmin e execute essa query na db :
Agora só usar nos scripts ou na lib :
function getAccountStorageValue(accid, key) local resultId = db.storeQuery("SELECT `account_id`, `key` FROM `account_storage` WHERE `account_id` = " .. accid .. " and `key` = " .. key) if resultId ~= false then return result.getNumber(resultId, 'key') else return -1 end return resultId:free() end function setAccountStorageValue(accid, key, value) local resultId = db.storeQuery("SELECT `value` FROM `account_storage` WHERE `account_id` = " .. accid .. " and `key` = " .. key) if resultId ~= false then db.query("UPDATE `account_storage` SET `value` = " .. accid .. " WHERE `key`=" .. key .. " LIMIT 1');") else db.query("INSERT INTO `account_storage` (`account_id`, `key`, `value`) VALUES (" .. accid .. ", " .. key .. ", '"..value.."');") end return true endModo de uso :
function onLogin(player) local storage = 545465 local pid = player:getGuid() local query = db.storeQuery("SELECT `account_id` FROM `players` WHERE `id` = ".. pid) local value = result.getNumber(query, 'account_id') if getAccountStorageValue(value, storage) < 1 then player:addPremiumDays(3) setAccountStorageValue(value, storage, 1) end return true endScript original veio do teckman, eu adaptei pras novas versões.
You see!~