Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. -- Check house auctions
  2. local resultId = db.storeQuery("SELECT `id`, `highest_bidder`, `last_bid`, (SELECT `balance` FROM `players` WHERE `players`.`id` = `highest_bidder`) AS `balance` FROM `houses` WHERE `owner` = 0 AND `bid_end` != 0 AND `bid_end` < " .. os.time())
  3. if resultId ~= false then
  4. repeat
  5. local house = House(result.getDataInt(resultId, "id"))
  6. if house ~= nil then
  7. local highestBidder = result.getDataInt(resultId, "highest_bidder")
  8. local balance = result.getDataLong(resultId, "balance")
  9. local lastBid = result.getDataInt(resultId, "last_bid")
  10. if balance >= lastBid then
  11. db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder)
  12. house:setOwnerGuid(highestBidder)
  13. end
  14. db.asyncQuery("UPDATE `houses` SET `last_bid` = 0, `bid_end` = 0, `highest_bidder` = 0, `bid` = 0 WHERE `id` = " .. house:getId())
  15. end
  16. until not result.next(resultId)
  17. result.free(resultId)
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement