Lurk
Active Member
- Joined
- Dec 4, 2017
- Messages
- 336
- Reaction score
- 48
Hello, I have this code
I want to get the ammount of points a player checking on his account id and the add/remove points from him. The thing is I think I'm getting a field or idk an object or something like that, I need the integer value of account id. I'm getting this error on console
Lua:
function getAccountPoints(cid)
local id = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '" ..getPlayerName(cid).. "';")
print("id: " ..id.. "")
local res = db.getResult('select `points` from `znote_accounts` where `account_id` = \''..id..'\'')
if(res:getID() == -1) then
return false
end
local ret = res:getDataInt("points")
res:free()
return tonumber(ret)
end
function doAccountAddPoints(cid, count)
local id = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '" ..getPlayerName(cid).. "';")
print("id: " ..id.. "")
return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) + count .."' WHERE `account_id` ='"..id.."'")
end
function doAccountRemovePoints(cid, count)
local id = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '" ..getPlayerName(cid).. "';")
print("id: " ..id.. "")
return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) - count .."' WHERE `account_id` ='"..id.."'")
end
I want to get the ammount of points a player checking on his account id and the add/remove points from him. The thing is I think I'm getting a field or idk an object or something like that, I need the integer value of account id. I'm getting this error on console
Code:
[21:26:50.095] [Error - Action Interface]
[21:26:50.099] data/actions/scripts/points.lua:onUse
[21:26:50.103] Description:
[21:26:50.105] data/lib/048-ppoints.lua:15: attempt to concatenate local 'id' (a table value)
[21:26:50.110] stack traceback:
[21:26:50.113] data/lib/048-ppoints.lua:15: in function 'doAccountAddPoints'
[21:26:50.119] data/actions/scripts/points.lua:8: in function <data/actions/scripts/points.lua:5>
Last edited: