whitevo
Feeling good, thats what I do.
Why is that if do this:
and then use this:
I get the PREVIOUS value instead of the VALUE I set with db.query?
When I do this in mysql:
then it does show the correct VALUE I created with the db.query
On top of it all, if I log out or save character, the storage value reverts back!
Is it bug or intended?
EDIT: Incase you found this thread trough search engine, then you probably looking for something like this:
Code:
db.query("UPDATE `player_storage` SET `value` = "..v.." WHERE `key` = "..sv.." AND `player_id` = "..guid)
Code:
SV = player:getStorageValue(sv)
print(SV)
When I do this in mysql:
Code:
SELECT * FROM `player_storage` WHERE `key` = 10000 AND `player_id` = 1
On top of it all, if I log out or save character, the storage value reverts back!
Is it bug or intended?
EDIT: Incase you found this thread trough search engine, then you probably looking for something like this:
Code:
function setAccountSV(accID, sv, v)
local playerGUIDT = {}
local playerData = db.storeQuery("SELECT id FROM `players` WHERE account_id = "..accID)
if playerData then
repeat
local guid = result.getNumber(playerData, "id")
table.insert(playerGUIDT, guid)
until not result.next(playerData)
end
for _, guid in pairs(playerGUIDT) do
local playerData = db.storeQuery("SELECT value FROM `player_storage` WHERE player_id = "..guid.." AND `key` = "..sv)
local charName = getPlayerNameByGUID(guid)
if Player(charName) then
Player(charName):setStorageValue(sv, v)
elseif playerData then
db.query("UPDATE `player_storage` SET `value` = "..v.." WHERE `key` = "..sv.." AND `player_id` = "..guid)
else
db.query("INSERT INTO `player_storage`(`player_id`, `key`, `value`) VALUES ("..guid..","..sv..","..v..")")
end
end
end
Last edited: