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

CreatureEvent Points onAdvance LeveL + Auto Broadcast

Blorin Mage

Member
Joined
Jan 26, 2012
Messages
90
Reaction score
13
{300, 10}--300 is level to recive points\10 is amount of points will be recived
Lua:
local t, storage = {
	{300, 10}
}, 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 accounts SET premium_points=premium_points+'.. v[2] ..' WHERE id=' .. getPlayerAccountId(cid))
            doCreatureSetStorage(cid, storage, i)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have recived '.. v[2] ..' Premium Points!')
			doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' Advenced To LeveL ' .. v[1] .. ' And Got ' .. v[2] .. ' Premium Points.')
        end
    end
    return true
end
open login.lua and rigster
Lua:
registerCreatureEvent(cid,'points')
after
Lua:
registerCreatureEvent(cid, "ReportBug")
open creaturescripts.xml and put this
Lua:
<event type="advance" name="points" event="script" value="points.lua"/>
 
Last edited:
How do you make it so like at 100 you get 10 points, 150 you get 20 and 200 you get 30? I tried adding another line, but then it just doesnt work at all.. can I get some help?
 
Add credits to Cykotitan which created this script. :p

@Extrodus, it should look like this for multiple lines.

Code:
[COLOR=#aa9900][B]local[/B][/COLOR] t[COLOR=#66cc66],[/COLOR] storage [COLOR=#66cc66]=[/COLOR] [COLOR=#66cc66]{[/COLOR]
        {200, 20},     [COLOR=#66cc66]
        {[/COLOR][COLOR=#cc66cc]300[/COLOR][COLOR=#66cc66],[/COLOR] [COLOR=#cc66cc]10[/COLOR][COLOR=#66cc66]}[/COLOR] [COLOR=#66cc66]
        }[/COLOR][COLOR=#66cc66],[/COLOR] [COLOR=#cc66cc]256[/COLOR]
 
How do you make it so like at 100 you get 10 points, 150 you get 20 and 200 you get 30? I tried adding another line, but then it just doesnt work at all.. can I get some help?
Lua:
local t, storage = {
	{100, 10},
        {150, 20},
        {200, 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 getCreatureStorage(cid, storage) < i then
            db.executeQuery('UPDATE accounts SET premium_points=premium_points+'.. v[2] ..' WHERE id=' .. getPlayerAccountId(cid))
            doCreatureSetStorage(cid, storage, i)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have recived '.. v[2] ..' Premium Points!')
			doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' Advenced To LeveL ' .. v[1] .. ' And Got ' .. v[2] .. ' Premium Points.')
        end
    end
    return true
end
 
OTSYS_SQLITE3_PREPARE(): SQLITE ERROR: no such column: premium_points (UPDATE accounts SET premium_points=premium_points+10 WHERE id=868)
 
OTSYS_SQLITE3_PREPARE(): SQLITE ERROR: no such column: premium_points (UPDATE accounts SET premium_points=premium_points+10 WHERE id=868)
You need to add the field premium_points:
ALTER TABLE accounts ADD premium_points INT(11) NOT NULL DEFAULT '0';
 
This is the script i have been looking for!! thanks for release and rep++ for you my friend!! :D

- - - Updated - - -

Can u edit so it adds the points in Honor_points table in player?
 
Im using the forgotten 0.4 and it doesnt work for me. I have that table inside my phpmyadmin... I have followed the instructions and no result. Also there is no any error in the console. I can event read the message of congratulations, its like if I hadnt done anything. I changed instead of 300,10 -> 250,5

You can see here:

Code:
local t, storage = {
	{250, 5}
}, 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 accounts SET premium_points=premium_points+'.. v[2] ..' WHERE id=' .. getPlayerAccountId(cid))
            doCreatureSetStorage(cid, storage, i)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have recived '.. v[2] ..' Premium Points!')
			doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' Advenced To LeveL ' .. v[1] .. ' And Got ' .. v[2] .. ' Premium Points.')
        end
    end
 
This script for TFS 3.4 i believe, 8.54...

Code:
function onAdvance(cid, skill, oldLevel, newLevel)
if isPlayer(cid) then
	doPlayerAddPoints(cid, count)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have advanced from level " .. getPlayerLevel(cid) - 1 .. " to level " .. getPlayerLevel(cid) .. ".")
	doBroadcastMessage("Player " .. getPlayerName(cid) .. " has advanced to level " .. getPlayerLevel(cid) .. ".")
end
return true
end

On your Database put this in. query this.

ALTER TABLE accounts ADD COLUMN points VARCHAR(128);

In your 50-function file add this.

Code:
function doPlayerAddPoints(cid, count)
    return db.executeQuery("UPDATE `accounts` SET `points` = ".. getAccountPoints(cid) + count .." WHERE `name` = ".. getPlayerAccount(cid).."")
end

Code:
function getAccountPoints(cid)
    local res = db.getResult('SELECT `orbs` FROM `accounts` WHERE `name` = '..getPlayerAccount(cid)..'')
    if(res:getID() == -1) then
       return 0
    end
    local ret = res:getDataInt("points")
    res:free()
    return tonumber(ret)
end
 
Last edited:
Im having some problems, when i reach level 300(etc) i get the message like: 14:35 Congratulations! You have advanced to level 300 and you have recived 10 Premium Points!
But i didnt recive anyting on the website?
Theres no bug in the consol and ive updated a table in the DB, whats wrong? Running on 0.3.7


Edit:

I recive premium_points in my DB but im running on Znote acc and my "points" are located in `znote_accounts`.`points`, how do i change that in the script?
REP+++++ FOR HELP!


Wierd bug, when im creating a new account and gain level 300 some other account gets the points?! whats wrong?!
 
Last edited:
Back
Top