• 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!

Dodanie postaci do aukcji onStartup

Verdis

Ciekawy świata.
Joined
May 28, 2012
Messages
394
Reaction score
9
Location
Poland
Witam,
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:
Back
Top