• 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 Buy something through command not using gold

leokart7

New Member
Joined
Mar 19, 2015
Messages
46
Reaction score
0
So I have two different types of currency in my OT. One is the standard one and the other one is the Premium Points. In my OT it came with a custom !buypremium but it only charges 20,000 and i want it to charge 50 premium points instead of that. Can someone help?
ID OF PREMIUM POINTS = 2157

THE FORGOTTEN SERVER 0.3.6 TIBIA 8.6

this is the buy premium command in my OT:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Buy premium command" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="buypremium_config"><![CDATA[
        config = {
            days = 90,
            cost = 10000,
            maxDays = 360
        }
    ]]></config>
    <talkaction words="!buypremium; !pacc" event="buffer"><![CDATA[
        domodlib('buypremium_config')
        if(getPlayerPremiumDays(cid) > config.maxDays) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can not buy more than " .. config.days + config.maxDays .. " days of Premium Account.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            return
        end

        if(not doPlayerRemoveMoney(cid, config.cost)) then
            doPlayerSendCancel(cid, "You don't have enough money, " .. config.days .. " days premium account costs " .. config.cost .. " gold coins.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            return
        end

        doPlayerAddPremiumDays(cid, config.days)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought " .. config.days .. " days of premium account.")
    ]]></talkaction>
</mod>
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Buy premium command" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="buypremium_config"><![CDATA[
        config = {
            days = 90,
            cost = 10000,
            maxDays = 360
        }
    ]]></config>
    <talkaction words="!pacc" event="buffer"><![CDATA[
        domolib('buypremium_config')
        if(getPlayerPremiumDays(cid) > config.maxDays) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can not buy more than " .. config.days + config.maxDays .. " days of Premium Account.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            return
        end

        if getPlayerItemCount(cid,2157) <= 49 then
            doPlayerSendCancel(cid, "You don't have enough premium points" .. config. days .. "costs 50 premium points.") then
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            return
        end

        if getPlayerItemCount(cid,2157) >=50
            doPlayerAddPremiumDays(cid, config.days) then
            doPlayerRemoveItem(cid,2157,50) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought " .. config.days .."days of PREMIUM.")
        ]]></talkaction>

</mod>

I tried doing it myself but it gives me some type of error saying unexpecteded symbolt near then in line 13. But there is no then in line 13.
Does someone know why isnt it working?
 
This is not needed (it's also missing then and an end to close it).
Code:
if getPlayerItemCount(cid,2157) >=50
But you can just remove it since it stops (return) if the item count is 49 or less.

Remove the then here.
Code:
doPlayerSendCancel(cid, "You don't have enough premium points" .. config. days .. "costs 50 premium points.") then
then should be placed at the end of an if statement.
 
This is not needed (it's also missing then and an end to close it).
Code:
if getPlayerItemCount(cid,2157) >=50
But you can just remove it since it stops (return) if the item count is 49 or less.

Remove the then here.
Code:
doPlayerSendCancel(cid, "You don't have enough premium points" .. config. days .. "costs 50 premium points.") then
then should be placed at the end of an if statement.

Dunno how I missed that :p
 
@RazorBlade and @Limos thank you! It fixed the problems happening in the console before but now its saying

[29/03/2015 13:42:34] [Lua Error]
[29/03/2015 13:42:34] [string "loadBuffer"]:18: unexpected symbol near 'then'
 
@Limos now it's giving this
[29/03/2015 13:50:22] [Error - TalkAction Interface]
[29/03/2015 13:50:22] buffer
[29/03/2015 13:50:22] Description:
[29/03/2015 13:50:22] [string "loadBuffer"]:5: attempt to call global 'domolib' (a nil value)
 
Back
Top