• Congratulations to the OTLand January Mapping Competition Winner! The grand prize of Otland Premium goes to Andréew.
  • Sign up for February Mapping Competition! The prize includes Otland Premium time.
  • There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

premium points tfs 1.x

theduck

Member
Joined
Dec 6, 2018
Messages
173
Best answers
0
Reaction score
16
I would like every time the player logs in
appears how many premiun points he has
Code:
local points = db.executeQuery('SELECT `premium_points` FROM `accounts` WHERE `id`=' .. player:getAccountId() ..';')
player:sendTextMessage(MESSAGE_EVENT_ADVANCE,"Your Account has " .. points .. " premium points.")
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,345
Best answers
528
Reaction score
3,104
Lua:
local res = db.executeQuery('SELECT `premium_points` FROM `accounts` WHERE id=' .. player:getAccountId() ..';')
if res then
    local points = result.getNumber(res, 'premium_points')
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE,"Your Account has " .. points .. " premium points.")
end
result.free(res)
 
OP
T

theduck

Member
Joined
Dec 6, 2018
Messages
173
Best answers
0
Reaction score
16
Lua:
local res = db.executeQuery('SELECT `premium_points` FROM `accounts` WHERE id=' .. player:getAccountId() ..';')
if res then
    local points = result.getNumber(res, 'premium_points')
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE,"Your Account has " .. points .. " premium points.")
end
result.free(res)
')' expected near '" .. player:getAccountId() .. "'
 
OP
T

theduck

Member
Joined
Dec 6, 2018
Messages
173
Best answers
0
Reaction score
16
You have to put it inside of onLogin.
executeQuery' (a nil value)
stack traceback:
[C]: in function 'executeQuery'

yes I tested at login and globalevents to keep appearing to the player both got error
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,345
Best answers
528
Reaction score
3,104
Change db.executeQuery to db.storeQuery.
 
OP
T

theduck

Member
Joined
Dec 6, 2018
Messages
173
Best answers
0
Reaction score
16
Change db.executeQuery to db.storeQuery.
Your Account has 2927 premium points.

worked on login
you know how I can do it works on the function
function onThink (interval, lastExecution)
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,345
Best answers
528
Reaction score
3,104
Lua:
function Player.getPremiumPoints(self)
    local res = db.storeQuery('SELECT `premium_points` FROM `accounts` WHERE id=' .. self:getAccountId() ..';')
    local points = 0
    if res then
        points = result.getNumber(res, 'premium_points')
    end
    result.free(res)
    return points
end

function onThink(interval, lastExecution)
    for _, player in pairs(Game.getPlayers()) do
        local points = player:getPremiumPoints()
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('You have %d premium points.', points))
    end
end
 
Last edited:
OP
T

theduck

Member
Joined
Dec 6, 2018
Messages
173
Best answers
0
Reaction score
16
Lua:
function Player.getPremiumPoints(self)
    local res = db.storeQuery('SELECT `premium_points` FROM `accounts` WHERE id=' .. player:getAccountId() ..';')
    local points = 0
    if res then
        points = result.getNumber(res, 'premium_points')
    end
    result.free(res)
    return points
end

function onThink(interval, lastExecution)
    for _, player in pairs(Game.getPlayers()) do
        local points = player:getPremiumPoints()
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('You have %d premium points.', points))
    end
end
attempt to index global 'player' (a nil value)
stack traceback:
 
Top