• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action OnUse item , Add X Points

Sirion_Mido

Experienced Member
Joined
Jul 22, 2012
Messages
579
Reaction score
43
Location
E-G-Y-P-T
Actions:
the script which add premium points on use item ;s

In data/libs create 048-ppoints.lua
and paste the following
Lua:
-- Sirion_Mido Says: Credites to: LucasFerraz
-- Sirion_Mido Says: Credites to: LucasFerraz
-- Sirion_Mido Says: Credites to: LucasFerraz
 
function getAccountPoints(cid)
    local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
    if(res:getID() == -1) then
       return false
    end
    local ret = res:getDataInt("premium_points")
    res:free()
    return tonumber(ret)
end
 
function doAccountAddPoints(cid, count)
    return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end

function doAccountRemovePoints(cid, count)
    return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) - count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
 
 
-- Sirion_Mido Says: Credites to: LucasFerraz
-- Sirion_Mido Says: Credites to: LucasFerraz
-- Sirion_Mido Says: Credites to: LucasFerraz



now:
In data/actions/scripts create points.lua
paste the following:
Lua:
local cfg = {
    amount = 10       -- here how many points you want
  }



function onUse(cid, item, fromPosition, itemEx, toPosition)  
  
                if getPlayerLevel(cid) > 8 then
                doAccountAddPoints(cid, cfg.amount)
                doCreatureSay(cid, "CONGRATULATIONS! You have recived 10 premium points!. ", TALKTYPE_ORANGE_1)
                doSendMagicEffect(getCreaturePosition(cid), 28)
                doRemoveItem(item.uid,1)
                else
                doPlayerSendCancel(cid,"You need level 8 or higher to use this item.")
                end
                return TRUE
                end

now xml part:
on data/actions.xml
paste the following:
XML:
    <action itemid="5952" event="script" value="points.lua"/>

Rep++ if it helpful for you.
 
Last edited:
Whats the error you get?, also what version of tfs are you useing, this has been tested for 9.60 servers
 
sorry i was no login for a while :D
i just checked the problems now , can tell me what is the problem again? :S

- - - Updated - - -

Iam So Sorry i did something stupid on the script , but i fixed now XD , hahaha
well i have solved the problem now on main post :D
and i will post here too
use this one

048-ppoints.lua
Lua:
-- Sirion_Mido Says: Credites to: LucasFerraz
-- Sirion_Mido Says: Credites to: LucasFerraz
-- Sirion_Mido Says: Credites to: LucasFerraz
 
function getAccountPoints(cid)
    local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
    if(res:getID() == -1) then
       return false
    end
    local ret = res:getDataInt("premium_points")
    res:free()
    return tonumber(ret)
end
 
function doAccountAddPoints(cid, count)
    return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
 
 
-- Sirion_Mido Says: Credites to: LucasFerraz
-- Sirion_Mido Says: Credites to: LucasFerraz
-- Sirion_Mido Says: Credites to: LucasFerraz

It Will Work Fine , iam sure :D
Rep++ if it works XD
 
Last edited:
Well, I do have another request. Not sure if it's realeased anwhere, in that case I can't find it.

I need a script that gives me an an item (such as the scroll) by using the command !premium (You will need 100 'donation points' to be able to perform the command. The item you get should give the player Premium Account in 20 days, by right-click it.


If you (or anybody) could help me out with this, I would be very thankful!
Cheers
 
DonHagman :

Here You Are.

In data/libs create 048-ppoints.lua
and paste the following
Lua:
function getAccountPoints(cid)
    local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
    if(res:getID() == -1) then
       return false
    end
    local ret = res:getDataInt("premium_points")
    res:free()
    return tonumber(ret)
end
 
function doAccountAddPoints(cid, count)
    return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
 
function doAccountRemovePoints(cid, count)
    return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) - count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end



In data/talkactons/scripts create premium.lua
and paste the following

Lua:
local points = 100   -- how many points it cost.
local item = 5952   -- what item it gived.
    
function onSay(cid, words, param)
if getAccountPoints(cid) < points then
doPlayerSendCancel(cid,'This item cost 100 premium points.')
else

doPlayerGiveItem(cid, item, 1)
doSendMagicEffect(getPlayerPosition(cid), 28)
doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE, 'You have bought scroll.')
doAccountRemovePoints(cid, points)
    



end
return TRUE
end

In data/actions/scripts create premium.lua
and paste the following

Lua:
function onUse(cid, item)
    if doRemoveItem(item.uid) then     
        doPlayerAddPremiumDays(cid, 20)
        doSendMagicEffect(getCreaturePosition(cid), 28)
        doPlayerSendTextMessage(cid,19, 'Your account added 20 premmium days!')
    end
return true
end

now xml part:
on data/talkactions/talkactions.xml
paste the following:
XML:
    <talkaction words="!premium ;/premium " script="premium.lua"/>

on data/actions/actions.xml
paste the following:
XML:
    <action itemid="5952" script="premium.lua" />
 
Replace db.executeQuery with db.query.
 
I get this error
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/hero badge.lua:onUse
data/global.lua:621: attempt to index local 'res' (a boolean value)
stack traceback:
        [C]: in function '__index'
        data/global.lua:621: in function 'getAccountPoints'
        data/global.lua:630: in function 'doAccountAddPoints'
        data/actions/scripts/hero badge.lua:8: in function <data/actions/scripts/hero badge.lua:5>

Code:
--- Prem points
function getAccountPoints(cid)
local res = db.storeQuery('select `premium_points` from accounts where name = \''..getPlayerAccountId(cid)..'\'')
if(res:getID() == -1) then
return false
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end

function doAccountAddPoints(cid, count)
return db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccountId(cid).."'")
end

function doAccountRemovePoints(cid, count)
return db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) - count .."' WHERE `name` ='"..getPlayerAccountId(cid).."'")
end
 
Back
Top