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

avesta znote npc shop

Ganjita

Active Member
Joined
Dec 15, 2009
Messages
494
Reaction score
37
someone can help me?, i have a znote acc converted for avesta but the shop dont found properly, for the shop i have that npc

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)    npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                        npcHandler:onThink()                        end

function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end

    local accid = getAccountNumberByPlayerName(getPlayerName(cid))
    local orderQuery = mysqlQuery("SELECT `points` FROM `znote_accounts` WHERE `account_id` = ".. accid .." LIMIT 1;", "points")
    local shop_points = getNumberValue(orderQuery.points)

    if msgcontains(msg, "list") then
        npcHandler:say("Here you are.")
        doShowTextDialog(cid, 2195, "** Shop List **\n\nBoots of Haste [20 points]\nSoft Boots [50 points]")
     
    elseif msgcontains(msg, "boots of haste") then
        npcHandler:say('Do you want to buy 1 boots of haste for 20 points?')
        pontos = 20
        item_id = 2195
        quant = 1
        topic = 1
 
    elseif msgcontains(msg, "soft boots") then
        npcHandler:say('Do you want to buy 1 soft boots for 50 points?')
        pontos = 50
        item_id = 2640
        quant = 1
        topic = 1
 
    end
 
    -- Confirm Yes or No
    if topic == 1 and msgcontains(msg, "yes") then
        if shop_points > 0 then
            npcHandler:say("Enjoy it young adventurer!")
            doPlayerAddItem(cid, item_id, quant)
            mysqlQuery("UPDATE `znote_accounts` SET `points` = ".. shop_points - pontos .." WHERE `account_id` = ".. accid .." LIMIT 1;", "UPDATE")
            topic = 0
        else
            npcHandler:say('You do not have enough points!')
            topic = 0
        end
    else
        npcHandler:say("Sorry, but you are not allowed to buy equipments with me.")
    end
 
    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


but when i say for example

ganjita:boots of haste
npc:Sorry, but you are not allowed to buy equipments with me.

how i can repair that?
 
i recommend to use talkactions:
Code:
<talkaction words="!shop" event="script" value="znoteshop.lua"/>
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 = 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 and getTileInfo(getCreaturePosition(cid)).protection then
                        --backpack check
                        local backpack = getPlayerSlotItem(cid, 3)
                        local gotItem = false
                        if(backpack and backpack.itemid > 0) then
                            local received = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, q_itemid,q_count)
                            if(received ~= false) then
                                db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!")
                                gotItem = true
                            end
                        end

                        if(not gotItem) then
                            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no available space in backpack to receive that item.")
                        end                       
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP and Need ProtectZone!")
                    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
 
i recommend to use talkactions:
Code:
<talkaction words="!shop" event="script" value="znoteshop.lua"/>
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 = 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 and getTileInfo(getCreaturePosition(cid)).protection then
                        --backpack check
                        local backpack = getPlayerSlotItem(cid, 3)
                        local gotItem = false
                        if(backpack and backpack.itemid > 0) then
                            local received = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, q_itemid,q_count)
                            if(received ~= false) then
                                db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!")
                                gotItem = true
                            end
                        end

                        if(not gotItem) then
                            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no available space in backpack to receive that item.")
                        end                      
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP and Need ProtectZone!")
                    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
The problem is to im use avesta por 74 the tallactopn dont found
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local topic = nil
 
function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)    npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                        npcHandler:onThink()                        end
 
function creatureSayCallback(cid, type, msg)
 
    if(npcHandler.focus ~= cid) then
        return false
    end
 
    local t
 
    local accid = getAccountNumberByPlayerName(getPlayerName(cid))
    local orderQuery = mysqlQuery("SELECT `points` FROM `znote_accounts` WHERE `account_id` = ".. accid .." LIMIT 1;", "points")
    local shop_points = getNumberValue(orderQuery.points)
 
    if msgcontains(msg, "list") then
        npcHandler:say("Here you are.")
        doShowTextDialog(cid, 2195, "** Shop List **\n\nBoots of Haste [20 points]\nSoft Boots [50 points]")
    elseif msgcontains(msg, "boots of haste") then
        npcHandler:say('Do you want to buy a pair of boots of haste for 20 points?')
        pontos = 20
        item_id = 2195
        quant = 1
        t = 1
    elseif msgcontains(msg, "soft boots") then
        npcHandler:say('Do you want to buy a pair of soft boots for 50 points?')
        pontos = 50
        item_id = 2640
        quant = 1
        t = 1
    elseif topic == 1 then
        if msgcontains(msg, "yes") then
            if shop_points >= pontos then -- How many points you need?
                npcHandler:say("Enjoy it young adventurer!")
                doPlayerGiveItem(cid, item_id, quant)
                mysqlQuery("UPDATE `znote_accounts` SET `points` = ".. shop_points - pontos .." WHERE `account_id` = ".. accid .." LIMIT 1;", "UPDATE")
            else
                npcHandler:say("You do not have enough points!")
            end
        else
            npcHandler:say("Another time then.")
        end
    end
    t = topic
    return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local topic = nil

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)    npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                        npcHandler:onThink()                        end

function creatureSayCallback(cid, type, msg)

    if(npcHandler.focus ~= cid) then
        return false
    end

    local t

    local accid = getAccountNumberByPlayerName(getPlayerName(cid))
    local orderQuery = mysqlQuery("SELECT `points` FROM `znote_accounts` WHERE `account_id` = ".. accid .." LIMIT 1;", "points")
    local shop_points = getNumberValue(orderQuery.points)

    if msgcontains(msg, "list") then
        npcHandler:say("Here you are.")
        doShowTextDialog(cid, 2195, "** Shop List **\n\nBoots of Haste [20 points]\nSoft Boots [50 points]")
    elseif msgcontains(msg, "boots of haste") then
        npcHandler:say('Do you want to buy a pair of boots of haste for 20 points?')
        pontos = 20
        item_id = 2195
        quant = 1
        t = 1
    elseif msgcontains(msg, "soft boots") then
        npcHandler:say('Do you want to buy a pair of soft boots for 50 points?')
        pontos = 50
        item_id = 2640
        quant = 1
        t = 1
    elseif topic == 1 then
        if msgcontains(msg, "yes") then
            if shop_points >= pontos then -- How many points you need?
                npcHandler:say("Enjoy it young adventurer!")
                doPlayerGiveItem(cid, item_id, quant)
                mysqlQuery("UPDATE `znote_accounts` SET `points` = ".. shop_points - pontos .." WHERE `account_id` = ".. accid .." LIMIT 1;", "UPDATE")
            else
                npcHandler:say("You do not have enough points!")
            end
        else
            npcHandler:say("Another time then.")
        end
    end
    t = topic
    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

thanks ond!, i will try right now.

why do you not use nicaw acc for avesta?

because i like the forum page >.< and i dont know how to make it
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local topic = nil

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)    npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                        npcHandler:onThink()                        end

function creatureSayCallback(cid, type, msg)

    if(npcHandler.focus ~= cid) then
        return false
    end

    local t

    local accid = getAccountNumberByPlayerName(getPlayerName(cid))
    local orderQuery = mysqlQuery("SELECT `points` FROM `znote_accounts` WHERE `account_id` = ".. accid .." LIMIT 1;", "points")
    local shop_points = getNumberValue(orderQuery.points)

    if msgcontains(msg, "list") then
        npcHandler:say("Here you are.")
        doShowTextDialog(cid, 2195, "** Shop List **\n\nBoots of Haste [20 points]\nSoft Boots [50 points]")
    elseif msgcontains(msg, "boots of haste") then
        npcHandler:say('Do you want to buy a pair of boots of haste for 20 points?')
        pontos = 20
        item_id = 2195
        quant = 1
        t = 1
    elseif msgcontains(msg, "soft boots") then
        npcHandler:say('Do you want to buy a pair of soft boots for 50 points?')
        pontos = 50
        item_id = 2640
        quant = 1
        t = 1
    elseif topic == 1 then
        if msgcontains(msg, "yes") then
            if shop_points >= pontos then -- How many points you need?
                npcHandler:say("Enjoy it young adventurer!")
                doPlayerGiveItem(cid, item_id, quant)
                mysqlQuery("UPDATE `znote_accounts` SET `points` = ".. shop_points - pontos .." WHERE `account_id` = ".. accid .." LIMIT 1;", "UPDATE")
            else
                npcHandler:say("You do not have enough points!")
            end
        else
            npcHandler:say("Another time then.")
        end
    end
    t = topic
    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

the npc dont found, when i try buy boots of haste, or soft boots i say:

19:31 Admin Warcore: boots of haste
19:31 Quentin: Do you want to buy a pair of boots of haste for 20 points?
19:31 Admin Warcore: yes

but the npc dont say nothing, how i can repair that?
 
the npc dont found, when i try buy boots of haste, or soft boots i say:

19:31 Admin Warcore: boots of haste
19:31 Quentin: Do you want to buy a pair of boots of haste for 20 points?
19:31 Admin Warcore: yes

but the npc dont say nothing, how i can repair that?

fixed
 
I try to use talk action, but I get "attempt to call global mysqlQuery


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 = 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 = mysqlQuery("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 = getItemWeightById(q_itemid, q_count)
                    if playerCap >= itemweight then
                        mysqlQuery("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 .." "..getItemNameById(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

Before I had db.executeQuery instead of just mysqlQuery. Same error but 'db' instead of 'mysqlQuery'
 
I try to use talk action, but I get "attempt to call global mysqlQuery


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 = 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 = mysqlQuery("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 = getItemWeightById(q_itemid, q_count)
                    if playerCap >= itemweight then
                        mysqlQuery("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 .." "..getItemNameById(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

Before I had db.executeQuery instead of just mysqlQuery. Same error but 'db' instead of 'mysqlQuery'
Which server do you use?
 
Back
Top Bottom