• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Reset StorageValue of player, DB execute

Fermantor

Active Member
Joined
Dec 16, 2009
Messages
209
Solutions
4
Reaction score
34
Location
Germany
I like the crates in RL Tibia, where you get an Item every hour. My problem was, that if I change the storage back via setPlayerStorage, it only works, if the player is online. So I tried to use db.querry, but it won't work :(
This is my code:
LUA:
function back(id) --as id here, the GUID is sent from the player
	db.query("UPDATE `player_storage` SET `value` = -1 WHERE `player_id` = " .. id .. " AND `key` = 11010")
end

I am using TSF 0.2.14 on the 9.61 OT (Mystic Spirit)
 
LUA:
local storage = 11010
for _, pid in ipairs(getPlayersOnline()) do
setPlayerStorageValue(pid, storage, -1) -- reset storage from players online
end
db.executeQuery("DELETE FROM `player_storage` WHERE `key` = "..storage) -- reset player offline
 
Back
Top