Witam,
mam pytanie czy poniższy kod jest napisany w sposób optymalny..?
mam pytanie czy poniższy kod jest napisany w sposób optymalny..?
local config = {
min_level = 500,
online = 0,
offline_time = 30,
}
function onStartup()
local players = db.getResult("SELECT `id`, `name` FROM `players` WHERE `lastlogin` < ".. os.time() - 60*60*24*config.offline_time .." AND `online` = "..config.online.." AND `level` > "..config.min_level.."")
local check = db.getResult("SELECT `id` FROM `characters_auctions`")
if players:getID() ~= -1 and check:getID() == -1 then
i = 0
repeat
local id = players:getDataInt("id")
db.executeQuery("INSERT INTO `characters_auctions` (`id` ,`finish_time` ,`char_id` ,`buy_now` ,`bid` ,`bidder`) VALUES ('NULL', '" ..(os.time() + 3600*24) .. "', '" .. id .. "', '0', '10', '0');")
db.executeQuery("UPDATE `players` SET `account_id` = 1 WHERE `id` = "..id.."");
i = i + 1
until not players:next() or i == 3
players:free()
end
return true
end
Last edited: