RegisterServerEvent(ārdsk_borsa:calculateNewPriceā)
AddEventHandler(ārdsk_borsa:calculateNewPriceā, function(item)
MySQL.Async.fetchAll(āSELECT * FROM borsa WHERE Nome = @nameā, {
[ā@nameā] = item
}, function(result)
local attuale = result[1].Attuale
local min = result[1].Min
local max = result[1].Max
local med = result[1].Med
local med = ((min + max) / 2)
local newPrice = math.random(min, max)
MySQL.Async.execute('UPDATE borsa SET Attuale=@RND, Med=@MED WHERE Nome = @name', {
['@RND'] = newPrice,
['@MED'] = med,
['@name'] = item
}, function(rowsChanged)
print(item .." has new price " .. newPrice .. " price was " .. attuale)
end)
end)
end)
have fun, updating the actual Item while selling or buying
I worked on a script to buy and sell stocks. Not in the phone, you go to a place and then you buy or sell.
The problem I saw itĀ“s that what the phone is showing as prices of the stocks doesnt match with the prices shown in my script. My script checks the DB when you open the menu.
Other problem itĀ“s that diferent players in the same time see different prices in the phone. Any Idea? How can I make that the phone check DB when oppening the app āBourseā?
I got it to work so far ^^ that I can enter items in the database myself etc. but how can you do it in such a way that people can only sell at these prices, for example?