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

How can I link coins to shop points?

Jpstafe

Well-Known Member
Joined
Aug 8, 2011
Messages
507
Reaction score
68
Hello good morning otland community, I would like you to squeeze my coin and it will be charged to the point of the shop.. How can I make that happen?
items.xml:
coins:
XML:
<item id="7506" article="a" name="venebra coin">
        <attribute key="weight" value="10" />
    </item>
I want to double-click it and make it disappear and load in the OTCLIENT shop
shop.png
 
Solution
Lua:
local function doPlayerAddPremiumPoints(cid, count)
   db.query('UPDATE accounts SET premium_points = premium_points+'.. count ..' WHERE id = ' .. getAccountNumberByPlayerName(getCreatureName(cid)))
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   local player = Player(cid)
   doPlayerAddPremiumPoints(cid, 1)
   player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you received 1 store points in your account")
   player:getPosition():sendMagicEffect(28)
   item:remove(1)
   return true
end
What is your engine's version? And do you use Znote or Gesior? Without information, I can't know. There's a script that clicks the item when it appears in the store, but I need to know your TFS version. Znote? Gesior? MyAAC?
 
What is your engine's version? And do you use Znote or Gesior? Without information, I can't know. There's a script that clicks the item when it appears in the store, but I need to know your TFS version. Znote? Gesior? MyAAC?
I'm using MYACC, in sql database, I added this: it came in the shop.lua:
XML:
--[[ SQL TABLE

CREATE TABLE `shop_history` (
  `id` int(11) NOT NULL,
  `account` int(11) NOT NULL,
  `player` int(11) NOT NULL,
  `date` datetime NOT NULL,
  `title` varchar(100) NOT NULL,
  `cost` int(11) NOT NULL,
  `details` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE `shop_history`
  ADD PRIMARY KEY (`id`);
ALTER TABLE `shop_history`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

]]--
 
You still haven't talked about your version of TFS...
actions
Lua:
local function addPremiumPoints(player, count)
    local playerName = player:getName(player)
    local accountId = getAccountNumberByPlayerName(playerName)
   
    if accountId ~= -1 then
        local query = db.prepare('UPDATE accounts SET premium_points = premium_points + ? WHERE id = ?')
        query:execute(count, accountId)
        return true
    else
        print("Error getting account ID for player:", playerName)
        return false
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player then
        if player:addPremiumPoints(1) then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 store point in your account.")
            player:getPosition():sendMagicEffect(28)
            item:remove(1)
            return true
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Error adding store points.")
        end
    end
    return false
end
 
You still haven't talked about your version of TFS...
actions
Lua:
local function addPremiumPoints(player, count)
    local playerName = player:getName(player)
    local accountId = getAccountNumberByPlayerName(playerName)
  
    if accountId ~= -1 then
        local query = db.prepare('UPDATE accounts SET premium_points = premium_points + ? WHERE id = ?')
        query:execute(count, accountId)
        return true
    else
        print("Error getting account ID for player:", playerName)
        return false
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player then
        if player:addPremiumPoints(1) then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 store point in your account.")
            player:getPosition():sendMagicEffect(28)
            item:remove(1)
            return true
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Error adding store points.")
        end
    end
    return false
end
Yes, my version is TFS 1.2 : what folder does this code go in?
 
data/actions
<action itemid="7506" script="venebra coin.lua"/>
XML:
Lua Script Error: [Action Interface]

data/actions/scripts/donations/venebracoin.lua:eek:nUse

data/actions/scripts/donations/venebracoin.lua:18: attempt to call method 'addPremiumPoints' (a nil value)

stack traceback:

        [C]: in function 'addPremiumPoints'

        data/actions/scripts/donations/venebracoin.lua:18: in function <data/actions/scripts/donations/venebracoin.lua:1
When I squeeze the coin I get this error on the console
 
Lua:
local function doPlayerAddPremiumPoints(cid, count)
   db.query('UPDATE accounts SET premium_points = premium_points+'.. count ..' WHERE id = ' .. getAccountNumberByPlayerName(getCreatureName(cid)))
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   local player = Player(cid)
   doPlayerAddPremiumPoints(cid, 1)
   player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you received 1 store points in your account")
   player:getPosition():sendMagicEffect(28)
   item:remove(1)
   return true
end
 
Solution
Lua:
local function doPlayerAddPremiumPoints(cid, count)
   db.query('UPDATE accounts SET premium_points = premium_points+'.. count ..' WHERE id = ' .. getAccountNumberByPlayerName(getCreatureName(cid)))
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   local player = Player(cid)
   doPlayerAddPremiumPoints(cid, 1)
   player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you received 1 store points in your account")
   player:getPosition():sendMagicEffect(28)
   item:remove(1)
   return true
end
!NICE BRO!!!! WORK 100% TY TY TY
 
Back
Top