• 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 Shop system command in-game [!shop] won't work! Znote AAC

EvoSoft

Is Da Mapper
Joined
Mar 10, 2010
Messages
693
Reaction score
5
Location
Northen part of Sweden
Alright, so I'm back again :p

The shop system that follows with Znote AAC is working perfect on the website and the database.
Although in-game it won't work.
When I purchase an item from the shop, I'm supposed to say !shop in-game to receive that item.
Currently when I'm saying !shop, it first says nothing, and then the second time it says "11:02 Can only be executed once every 15 seconds. Remaining cooldown: XX"
The znote_shop_orders folder in the database is full of orders, still the !shop command won't work...
Here's the code:


Code:
-- Znote Shop v1.0 for Znote AAC on TFS 0.2.13+ Mystic Spirit.
function onSay(cid, words, param)
    local storage = 39672 -- 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 .. " LIMIT 1;")
     
        -- 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
                        db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                        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
            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


NOTE:: Using TFS_10+
 
Last edited:
Only way i see right now is:
Code:
local q_type = result.getDataInt(orderQuery, "type")
q_type of players orders is not 1, so this statement
Code:
if q_type == 1 then
(...)
end
is not true and this code wouldnt run. Check database for item types or replace your code with this and search in server logs for "<shop.lua>"
Code:
-- Znote Shop v1.0 for Znote AAC on TFS 0.2.13+ Mystic Spirit.
function onSay(cid, words, param)
    local storage = 39672 -- 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 .. " LIMIT 1;")
    
        -- 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
                        db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                        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 print('<shop.lua> Order type not found (value:'.. q_type ..') on orderID=' .. q_id)
            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

If you want this script to work - orders must be of type 1 (or you'll need to modify this script).
 
yea,
e51f206e033ff9e41e793e4df1ecfa02.png
 
Okey, i've edited this script so it would only parse orders with type of 1 (2 = pacc by acc maker, 3 = gender by acc maker). Your shop just havent parsed those orders. Try this one:
Code:
-- Znote Shop v1.0 for Znote AAC on TFS 0.2.13+ Mystic Spirit.
function onSay(cid, words, param)
    local storage = 39672 -- 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`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. " AND `type` = 1 LIMIT 1;")
   
        -- Detect if we got any results
        if orderQuery ~= false then
            -- Fetch order values
            local q_id = result.getDataInt(orderQuery, "id")
            local q_itemid = result.getDataInt(orderQuery, "itemid")
            local q_count = result.getDataInt(orderQuery, "count")
            result.free(orderQuery)

            local playerCap = getPlayerFreeCap(cid)
            local itemweight = getItemWeight(q_itemid, q_count)
                if playerCap >= itemweight then
                    db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                    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 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
 
Back
Top