forked from minetest-mods/global_exchange
Fix crash
This commit is contained in:
parent
1b83375c8f
commit
72f0a7832a
@ -50,6 +50,9 @@ ON Orders (Poster, Type, Time, Item, Rate);
|
|||||||
CREATE INDEX if not exists index_inbox
|
CREATE INDEX if not exists index_inbox
|
||||||
ON Inbox (Recipient);
|
ON Inbox (Recipient);
|
||||||
|
|
||||||
|
CREATE VIEW if not exists distinct_items AS
|
||||||
|
SELECT DISTINCT Item FROM Orders;
|
||||||
|
|
||||||
END TRANSACTION;
|
END TRANSACTION;
|
||||||
]=]
|
]=]
|
||||||
|
|
||||||
@ -649,6 +652,11 @@ function ex_methods.buy(self, p_name, ex_name, item_name, amount, rate)
|
|||||||
local db = self.db
|
local db = self.db
|
||||||
|
|
||||||
local bal = self:get_balance(p_name)
|
local bal = self:get_balance(p_name)
|
||||||
|
|
||||||
|
if not bal then
|
||||||
|
return false, "Nonexistent account."
|
||||||
|
end
|
||||||
|
|
||||||
if bal < amount * rate then
|
if bal < amount * rate then
|
||||||
return false, "Not enough money."
|
return false, "Not enough money."
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user