E
Evil Puncker
Guest
Okay so I have these functions:
the issue:
I can't use
because the first one will always return false and throw an "attempt to perform arithmetic on a boolean value " error
Lua:
function Player.getAccountStorageValue(self, key)
local toNumber = tonumber(key)
if not toNumber then
return false
end
local query = db.storeQuery("SELECT `value` FROM `account_storage` WHERE `account_id` = ".. self:getAccountId() .." AND `key` = ".. key)
if not query then
return false
end
local value = result.getNumber(query, "value")
result.free(query)
return value
end
function Player.setAccountStorageValue(self, key, value)
local toNumber = tonumber(key)
if not toNumber then
return false
end
local query = ""
if self:getAccountStorageValue(key) then
query = ("UPDATE `account_storage` SET `value` = ".. value .." WHERE `account_id` = ".. self:getAccountId() .." AND `key` = "..key)
else
query = ("INSERT INTO `account_storage` (`account_id`, `key`, `value`) VALUES (".. self:getAccountId() ..", ".. key ..", ".. value ..")")
end
return db.query(query)
end
the issue:
I can't use
Lua:
player:getAccountStorageValue(123)
player:setAccountStorageValue(123,1)
because the first one will always return false and throw an "attempt to perform arithmetic on a boolean value " error