Hello I'm wondering if anyone know how to make this script work, it seems to give the points but store is not updated with the new points. Is there any way to "reload"?
This is the store function
Thanks
Lua:
local hundredPoints = 100
local fiftyPoints = 50
local addpoints = 50
local addpointss = 100
function onUse(player, item, fromPosition, target, toPosition)
if item:getId() == hundredPoints then
db.query("UPDATE znote_accounts SET points = points + "..addpointss.." WHERE account_id = ".. player:getAccountId() .."")
elseif item:getId() == fiftyPoints then
db.query("UPDATE znote_accounts SET points = points + "..addpoints.." WHERE account_id = ".. player:getAccountId() .."")
end
item:getPosition():sendMagicEffect(28)
item:remove()
player:save()
return true
end
Code:
function getPoints(player)
local points = 0
local resultId = db.storeQuery("SELECT `points` FROM `znote_accounts` WHERE `id` = " .. player:getAccountId())
if resultId ~= false then
points = result.getDataInt(resultId, "points")
result.free(resultId)
end
return points
end
Thanks