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

Znote Shop System with Command

Schwarzbeere

BraveOnline Developer
Joined
Feb 16, 2017
Messages
68
Reaction score
3
Location
Germany
Hey guys,

is there a working Znote Shop System where !shop is working on TFS1.2?

Znote setup working great.. but !shop doesn't work ingame :-/ .. tested on normal account.

There is no Error, just dont recieve it.. :-/

Any Idea?


The Script I used for place the Item and the Outfits and the mounts is:

Lua:
-- Znote Shop v1.0 for Znote AAC on TFS 0.3.6+ Crying Damson.
function onSay(cid, words, param)
    local storage = 54073 -- Make sure to select non-used storage. This is used to prevent SQL load attacks.
    local cooldown = 15 -- in seconds.
   
    if getPlayerStorageValue(cid, storage) <= os.time() then
        setPlayerStorageValue(cid, storage, os.time() + cooldown)
        local accid = getAccountNumberByPlayerName(getCreatureName(cid))
       
        -- Create the query
        local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. ";")
       
        -- Detect if we got any results
        if orderQuery ~= false then
            -- Fetch order values
            local q_id = result.getDataInt(orderQuery, "id")
            local q_type = result.getDataInt(orderQuery, "type")
            local q_itemid = result.getDataInt(orderQuery, "itemid")
            local q_count = result.getDataInt(orderQuery, "count")
            result.free(orderQuery)
           
            -- ORDER TYPE 1 (Regular item shop products)
            if q_type == 1 then
                -- Get wheight
                local playerCap = getPlayerFreeCap(cid)
                local itemweight = getItemWeightById(q_itemid, q_count)
                    if playerCap >= itemweight then
                        local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                        result.free(delete)
                        doPlayerAddItem(cid, q_itemid, q_count)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!")
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
                    end
            end
            -- ORDER TYPE 5 (Outfit and addon)
            if q_type == 5 then
                -- Make sure player don't already have this outfit and addon
                if not canPlayerWearOutfit(cid, q_itemid, q_count) then
                    local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                    result.free(delete)
                    doPlayerAddOutfit(cid,q_itemid,q_count)
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
                end
            end

            -- ORDER TYPE 6 (Mounts)
            if q_type == 6 then
                -- Make sure player don't already have this outfit and addon
                if not getPlayerMount(cid, q_itemid) then -- Failed to find a proper hasMount 0.3 function?
                    local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                    result.free(delete)
                    doPlayerAddMount(cid, q_itemid)
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!")
                end
            end
           
            -- Add custom order types here
            -- Type 1 is for itemids (Already coded here)
            -- Type 2 is for premium (Coded on web)
            -- Type 3 is for gender change (Coded on web)
            -- Type 4 is for character name change (Coded on web)
            -- Type 5 is for character outfit and addon (Already coded here)
            -- Type 6 is for mounts (Already coded here)
            -- So use type 7+ for custom stuff, like etc packages.
            -- if q_type == 7 then
            -- end
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.")
        end
       
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time())
    end
    return false
end
 
I checked this script, but the error is on line 26.

local itemweight = getItemWeightById(q_itemid, q_count)

Console says theres an error.
What is the error? If there is an error or an issue you need include that with your question.

A screenshot will do or even copy and pasting the error from the console, make sure to include the error if it is text in code tags.
 
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/shop.lua:onSay
data/talkactions/scripts/lua:26: attempt to call global 'getItemWeightById' <a nil value>
stack traceback:
    [C]: in function 'getItemWeightById'
    data/talkactions/sctipts/shop.lua:26: in function <data/talkactions/scripts/shop.lua:2>
 
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/shop.lua:onSay
data/talkactions/scripts/lua:26: attempt to call global 'getItemWeightById' <a nil value>
stack traceback:
    [C]: in function 'getItemWeightById'
    data/talkactions/sctipts/shop.lua:26: in function <data/talkactions/scripts/shop.lua:2>
Znote AAC 1.4 - [TFS 0.2.13+] & [TFS 0.3.6+/0.4]

So you are going to swap those out.

This is 1.2
forgottenserver/compat.lua at 1.2 · otland/forgottenserver · GitHub
 
Last edited:
Thanks man, it worked now :)

But now I get these in the Server:

Code:
[Error - mysql_store_result] Query: DELETE FROM 'znote_shop_orders' WHERE 'id' = 14;
Message:

It's deleted from the orders, but why I get this message?

And if I buy Mounts or Outfits it says nothing.

Code:
-- Znote Shop v1.0 for Znote AAC on TFS 0.3.6+ Crying Damson.
function onSay(cid, words, param)
    local storage = 54073 -- Make sure to select non-used storage. This is used to prevent SQL load attacks.
    local cooldown = 3 -- in seconds.
    if getPlayerStorageValue(cid, storage) <= os.time() then
        setPlayerStorageValue(cid, storage, os.time() + cooldown)
        local accid = getAccountNumberByPlayerName(getCreatureName(cid))
  
        -- Create the query
        local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. ";")
  
        -- Detect if we got any results
        if orderQuery ~= false then
            -- Fetch order values
            local q_id = result.getDataInt(orderQuery, "id")
            local q_type = result.getDataInt(orderQuery, "type")
            local q_itemid = result.getDataInt(orderQuery, "itemid")
            local q_count = result.getDataInt(orderQuery, "count")
            result.free(orderQuery)
      
            -- ORDER TYPE 1 (Regular item shop products)
            if q_type == 1 then
                -- Get wheight
                local playerCap = getPlayerFreeCap(cid)
                local itemweight = getItemWeight(q_itemid, q_count)
                    if playerCap >= itemweight then
                        local delete = db.storeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                        result.free(delete)
                        doPlayerAddItem(cid, q_itemid, q_count)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemName(q_itemid).."(s)!")
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more cap.")
                    end
            else doPlayerSendTextMessage (cid, MESSAGE_STATUS_WARNING, "You have nothing ordered.")
            end
            -- Add custom order types here
            -- Type 2 is reserved for premium days and is handled on website, not needed here.
            -- Type 3 is reserved for character gender(sex) change and is handled on website as well.
            -- So use type 4+ for custom stuff, like etc packages.
            -- if q_type == 4 then
            -- end
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.")
        end
  
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time())
    end
    return false
end

It's not inside the script if I get it right, or?
 
Last edited:
Back
Top