• 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 !buypremium command for points

tuduras

Well-Known Member
Joined
Jun 4, 2017
Messages
352
Solutions
2
Reaction score
60
Hello Otlanders. Are You okay?
How to put in script cost for points premium instead money .
Here post my data/MODS
LUA:
<?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>
Thanks and Best Regards !
 
Hello Otlanders. Are You okay?
How to put in script cost for points premium instead money .
Here post my data/MODS
LUA:
<?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>
Thanks and Best Regards !
Hey bro.
Here’s a fixed and working version of the !buypremium command that lets players buy Premium Days using website points from ZnoteAAC instead of gold.

I tested this on TFS 1.4+, and it should also work fine for other 1.x versions.




Installation​


Create the script

Go to:

data/talkactions/scripts/
_________________________
Create a new file called:

buypremium_points.lua
_________________________
Paste this code inside:


local config = {
days = 30, -- how many days of premium the player gets
cost = 100, -- how many website points it costs
maxDays = 360 -- max premium days a player can have
}

function onSay(cid, words, param, channel)
local accountId = getPlayerAccountId(cid)
if not accountId then
doPlayerSendCancel(cid, "Internal error: account not found.")
return true
end

local currentPremiumDays = getPlayerPremiumDays(cid)
if currentPremiumDays > config.maxDays then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,
"You can't buy more than " .. config.maxDays .. " days of premium account.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

local query = db.storeQuery("SELECT points FROM znote_accounts WHERE account_id = " .. accountId)
if not query then
doPlayerSendCancel(cid, "Website points account not found.")
return true
end

local points = result.getDataInt(query, "points")
result.free(query)

if points < config.cost then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,
"You don't have enough points. " .. config.days .. " days cost " .. config.cost .. " points.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end

-- Subtract points
db.executeQuery("UPDATE znote_accounts SET points = points - " .. config.cost .. " WHERE account_id = " .. accountId .. ";")

-- Add Premium Days
doPlayerAddPremiumDays(cid, config.days)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,
"You bought " .. config.days .. " days of Premium Account using " .. config.cost .. " points.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
return true
end



Add the command in data/talkactions/talkactions.xml:


<talkaction words="!buypremium" script="buypremium_points.lua"/>

Usage​


In-game, the player just types:
!buypremium
If they have enough ZnoteAAC points → it subtracts the cost and gives them Premium Days.
If not enough points → they get a message saying how many they need.

Notes​


  • Works with znote_accounts.points.
  • If you use MyAAC or Gesior with different column names (like premium_points), just update the SQL queries.

    best regards.
 
I'm using MyACC . enough change znote_point to premium_point??maybe you can get your bearings. Last i moved from znote to myacc :/
points.webp
Can You convert from ZNOTE to MYACC ? Please ;'p
 
Last edited:
I'm using MyACC . enough change znote_point to premium_point??maybe you can get your bearings. Last i moved from znote to myacc :/
View attachment 95971
Can You convert from ZNOTE to MYACC ? Please ;'p
If you're using MyAAC, yes — you just need to change
znote_accounts → accounts
and
points → premium_points

So your SQL lines should look like this:
local query = db.storeQuery("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. accountId)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. config.cost .. " WHERE `id` = " .. accountId .. ";")

Everything else in the script stays the same
That will make it work perfectly with MyAAC instead of ZnoteAAC.
 
I made all like You wrote and occurs error . You maybe know what it is?
err points.webp

In middle of the script is :
LUA:
local points = result.getDataInt(query, "points")
Ill try to change to premium_point

EDIT: yes I had to change middle of the script to premium_points
solved thanks
 
Back
Top