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

Solved Auto points per level not working :s

gerard95

Keep cool :)
Joined
Dec 31, 2011
Messages
276
Reaction score
16
I got a script from Otland, to give points per level. For ZnoteAcc, but it ain't working.
What's failing? :eek:

Lua:
local t, storage = {
    {160, 5},
    {200, 10},
    {245, 15},
}, 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 getCreatureStorage(cid, storage) < i then
            db.executeQuery('UPDATE znote_accounts SET points=points+'.. v[2] ..' WHERE account_id=' .. getPlayerAccountId(cid))
            doCreatureSetStorage(cid, storage, i)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have earned '.. v[2] ..' Points!')
            doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' Advanced to ' .. v[1] .. 'lvl and got ' .. v[2] .. ' Points.')
            break
        end
    end
    return true
end

XML:
<event type="advance" name="Pointsystem" event="script" value="emporia/pointsystem.lua"/>

And at login.lua -> registerCreatureEvent(cid, "pointsystem")

Thank you guys![/i]
 
<event type="advance" name="Pointsystem" event="script" value="emporia/pointsystem.lua"/>
registerCreatureEvent(cid, "pointsystem")
 
Not working mate! Any clue? Need help asap!
And if you fix it somehow, will the existent players will have them or it will be only for new accounts/players? Or I have to give them manually?

Thank you again!
 
So the script goes like this?
Lua:
local v = t[i], storage = {
    {160, 5},
    {200, 10},
    {245, 15},
}, 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 getCreatureStorage(cid, storage) < i then
            db.executeQuery('UPDATE znote_accounts SET points=points+'.. v[2] ..' WHERE account_id=' .. getPlayerAccountId(cid))
            doCreatureSetStorage(cid, storage, i)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have earned '.. v[2] ..' Points!')
            doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' Advanced to ' .. v[1] .. 'lvl and got ' .. v[2] .. ' Points.')
            break
        end
    end
    return true
end

Thank you Ninja! :)[/i][/i]
 
Console error:
[Error - LuaInterface::loadFile] data/creaturescripts/scripts/emporia/pointsystem.lua:1: unexpected symbol near '='
[Error - Event::checkScript] Cannot load script (data/creaturescripts/scripts/emporia/pointsystem.lua)
data/creaturescripts/scripts/emporia/pointsystem.lua:1: unexpected symbol near '='

Uhm? :(
 
Code:
local t, storage = {
    {160, 5},
    {200, 10},
    {245, 15}
}, 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 getCreatureStorage(cid, storage) < i then
            db.executeQuery('UPDATE znote_accounts SET points=points+'.. v[2] ..' WHERE account_id=' .. getPlayerAccountId(cid))
            doCreatureSetStorage(cid, storage, i)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have earned '.. v[2] ..' Points!')
            doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' Advanced to ' .. v[1] .. 'lvl and got ' .. v[2] .. ' Points.')
            break
        end
    end
    return true
end
 
Is there any errors?
Hope You Luck helping those people who post about 20-30 thread per day asking for help and just say Doesn't Work.
Neither. Not working... Any clue again? TT'
Thank you :c
There is SomeThing Called Errors in Console it pops up when you try a bad script.if it didn't pop uo and the script didn't work then just say what you were Doing and how you test it and your source
 
Wow tetra, calm down o.o.
There are no errors in Console. And I did not post anything, because I thought I posted everything Ninja or others could need.
And I was doing nothing, I just restarted the server and tried to make a character level 160, and 200, but nothing happened, thats why.
 
Also for what I can see you dont use any storage ID, which mean even if the player takes 160 and gets 5 points, he will still get points at level 161, 162 etc.
Change that.
Code:
local v = t, storage = {
{160, 5},
{200, 10},
{245, 15},
}, 256
To something like this:
Code:
local t = {
--    [storage], level, points
    [xxxxxID] = {160, 30},
  [xxxxxID] = {200, 30},
[xxxxxID] = {250, 30}

}
Which will give the player a storage ID so he can't get the reward again.
 
Last edited:
local t, storage = {
{160, 5},
{200, 10},
{245, 15}
}, 256

256 in this case is the storage key, you'll only receive the points once.

- - - Updated - - -

He registered it incorrectly in login.lua, nothing wrong with the script :p
 
Yea but I tried out the same script. Did not work maybe beacuse Im using TFS 0.4 I don't but it didn't workout that way. So the players recvied points at every level after 160. Im no pro at LUA but still.
 
try to level up from 159 to 160 not database edit
Sorry for that cold reply i was depressed abit
I did it via in-game. It's ok, I was annoyed as well, thank you anyway :D

- - - Updated - - -

My lua "script" is still not working and you said it should work, right? I do not know what is wrong or what is failing. Still nobody got a valid auto-points script, or any fix which could work? :p
Thank you :3

- - - Updated - - -

Ninja fixed it finally with this script:
Code:
local t, storage = {
    {160, 5},
    {200, 10},
    {245, 15}
}, 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 getCreatureStorage(cid, storage) < i then
            db.executeQuery('UPDATE znote_accounts SET points=points+'.. v[2] ..' WHERE account_id=' .. getPlayerAccountId(cid))
            doCreatureSetStorage(cid, storage, i)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have earned '.. v[2] ..' Points!')
            doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' Advanced to ' .. v[1] .. 'lvl and got ' .. v[2] .. ' Points.')
            break
        end
    end
    return true
end

Thank you so much guys!!
 
Last edited by a moderator:
Back
Top