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

TalkAction Buy Premium Using talkaction cost Premium Points

Sirion_Mido

Experienced Member
Joined
Jul 22, 2012
Messages
579
Reaction score
43
Location
E-G-Y-P-T
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 give.
    
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:
local cfg {
   days = 30 -- how many premium days want to add
   }
function onUse(cid, item)
    if doRemoveItem(item.uid) then     
        doPlayerAddPremiumDays(cid, cfg.days)
        doSendMagicEffect(getCreaturePosition(cid), 28)
        doPlayerSendTextMessage(cid,19, 'Your account added 30 premmium days!') -- message will send when use item
    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" />
 
Back
Top