• 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!

Shop Points at a Certain level doesn't work

Tyson12302

New Member
Joined
Aug 6, 2014
Messages
264
Reaction score
4
I searched a couple scripts where you get Shop points at a certain level here is the script that i have in my creaturescripts/scripts/points.lua.
Code:
local t, storage = {
{30, 30},
{190, 30},
{220, 30},
{250, 30},
{280, 30},
{300, 30},
{315, 30},
{330, 30}
}, 256

function onAdvance(cid, skill, oldLevel, newLevel)
if skill ~= SKILL__LEVEL then
return true
end
for i = 1, #t do
local v = t
if newLevel >= v[1] and getStorage(storage) < i then
db.executeQuery('UPDATE accounts SET premium_points=premium_points+'.. v[2] ..' WHERE id=' .. getPlayerAccountId(cid))
doSetStorage(storage, i)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have earned '.. v[2] ..' Premium Points!')
doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' advenced to ' .. v[1] .. 'lvl and got ' .. v[2] .. ' ptz to sms shop.')
break
end
end
return true
end

login.lua
Code:
registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    registerCreatureEvent(cid, "PlayerAdvance")
    registerCreatureEvent(cid, "Inq")
    registerCreatureEvent(cid, "death")
    return true
end

And creaturescript.xml
Code:
<event type="advance" name="pointsforlvl" event="script" value="points.lua"/>

I get a error in the console when i reach the level.
"attempt to compare table with numbers"
 
Last edited by a moderator:
Best is to post the full error for next time and always post your server version, in every thread.

Change t to
Code:
t[i]
in local v = t
 
[08/06/2015 18:08:00] [Error - CreatureScript Interface]
[08/06/2015 18:08:00] data/creaturescripts/scripts/points.lua:eek:nAdvance
[08/06/2015 18:08:00] Description:
[08/06/2015 18:08:01] data/creaturescripts/scripts/points.lua:18: attempt to compare table with number
[08/06/2015 18:08:01] stack traceback:
[08/06/2015 18:08:01] data/creaturescripts/scripts/points.lua:18: in function <data/creaturescripts/scripts/points.lua:12>

Tibia Version 8.6/ 0.3.6

I'll try out that. I'll report back if it works.

The Red Broadcast worked when i reached the level, BUT the points dont appear online? Do i have to wait a certain time or are they meant to appear straight away?
I get this error on the console [08/06/2015 18:15:54] mysql_real_query(): UPDATE accounts SET premium_points=premium_points+30 WHERE id=3 - MYSQL ERROR: Unknown column 'premium_points' in 'field list' (1054)
 
Last edited by a moderator:
The error is gone, But the Points still didn't arrive in the Shop. I get the Broadcast message but the points down appear online.
 
In which shop? Make sure it's using the same column for premium points, else change the column name in the Lua script.
 
The Website Shop where people can buy items listed on the website.
Code:
local t, storage = {
{38, 30},
{40, 30},
{220, 30},
{250, 30},
{280, 30},
{300, 30},
{315, 30},
{330, 30}
}, 256

function onAdvance(cid, skill, oldLevel, newLevel)
if skill ~= SKILL__LEVEL then
return true
end
for i = 1, #t do
local v = t[i]
if newLevel >= v[1] and getStorage(storage) < i then
db.executeQuery('UPDATE accounts SET premium_points=premium_points+'.. v[2] ..' WHERE id=' .. getPlayerAccountId(cid))
doSetStorage(storage, i)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have earned '.. v[2] ..' Premium Points!')
doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' advenced to ' .. v[1] .. 'lvl and got ' .. v[2] .. ' ptz to sms shop.')
break
end
end
return true
end
where do i put the column on here?

I made the column with the same name and is still doesnt work.
 
Here is the column i am using on phpmyadmin
qR86AW2.png

And im using that on the lua file as you can see from my other post.
 
Alright i tried it with the SQL Code and it said that the Column Points doenst exist in the field list when it does. Heres the proof. Yeah i get this error again in console when getting the level, [08/06/2015 19:24:44] mysql_real_query(): UPDATE accounts SET points=points+30 WHERE id=3 - MYSQL ERROR: Unknown column 'points' in 'field list' (1054)
NIp49fS.png
 
Last edited:
[08/06/2015 19:24:44] mysql_real_query(): UPDATE accounts SET points=points+30 WHERE id=3 - MYSQL ERROR: Unknown column 'points' in 'field list' (1054)
lets take a look, thats says "points" in "accounts" ya?
and ur script says "premium_points"
points and premium_points are 2 different things
 
I changed them all. I just figured out that a SQL code that acutally works here it is
Code:
UPDATE`otserv`.`znote_accounts`SET`points`='70'WHERE`znote_accounts`.`points`=60LIMIT1;
This code works if i use it. How can i implement this to the LUA script?
 
I changed it and tried it on a different account and now it doesn't even broadcast the message when i get the level. It only works on 1 account. When i try it on other accounts it doesnt work.
 
Last edited:
Back
Top