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

Actions.xml 12x

Indahouse

Member
Joined
May 13, 2015
Messages
79
Reaction score
13
Hello

On versions till 11.50 de have the actions.xml but in 12x IS a fólder called script, ok, i import a lua script for use in game tibia coin and add It to player, my question is my script not working ( because they load it directly ) or i need to add the line like on actions.xml ?( But this file not exists on 12x, i check all XML IS there no one about actions id etc)
 
Solution
E
okay it seems like you didn't read the link I posted :D

Lua:
local testAction = Action()

function testAction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local coinplayer = player:getCoinsBalance()+item:getCount()
    player:getPosition():sendMagicEffect(15)
    item:remove()
    player:setCoinsBalance(coinplayer)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received Store Coins.")
   return true
end

testAction:id(24774)
testAction:register()
Ah very nice , mm so i think my lua dont work right ? Because item exists but they don't do nothing when i use it

Lua:
local config = {
   idcoin = 24774
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   local player = Player(cid)
   local item = Item(item.uid)
   if player:getItemCount(config.idcoin) > 0 then
       local coinplayer = player:getCoinsBalance()+item:getCount()
       player:getPosition():sendMagicEffect(15)
       item:remove()
       player:setCoinsBalance(coinplayer)
       player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have recived Store Coins.")
   else
       player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have to carry Store coins in your backpack.")
   end
   return true
end
 
okay it seems like you didn't read the link I posted :D

Lua:
local testAction = Action()

function testAction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local coinplayer = player:getCoinsBalance()+item:getCount()
    player:getPosition():sendMagicEffect(15)
    item:remove()
    player:setCoinsBalance(coinplayer)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received Store Coins.")
   return true
end

testAction:id(24774)
testAction:register()
 
Solution
Yes i read it, and i start writting the script when i search for set coin balance i found the entire script on br, thanks for your help !

Lua:
local tibiaCoin = Action()

function tibiaCoin.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local coins = 1
  db.query("UPDATE `accounts` SET `coins` = `coins` + '" .. coins .. "' WHERE `id` = '" .. player:getAccountId() .. "';")
  player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You received "..coins.." Store Coins")
  item:remove(1)
  return true
end

tibiaCoin:id(24774)
tibiaCoin:register()
Post automatically merged:

@Evil Puncker i try with another, creating a ' Reward per level up ' but... im really new on it and i dont know all codes, if is good, doing so a Reward of this tibia coins per level up
There is the code i dont know if is good...( well not working, but if is a good start )

Lua:
function onAdvance(cid, skill, oldlevel, newlevel)

               if getPlayerLevel(cid) >= 8 and getPlayerStorageValue(cid, 99970) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99970, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins for reach level 8.")

            elseif getPlayerLevel(cid) >= 20 and getPlayerStorageValue(cid, 99971) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99971, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins for reach level 20.")

            elseif getPlayerLevel(cid) >= 30 and getPlayerStorageValue(cid, 99972) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99972, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins for reach level 30.")
                            
            elseif getPlayerLevel(cid) >= 40 and getPlayerStorageValue(cid, 99973) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99973, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins for reach level 40.")
                            
            elseif getPlayerLevel(cid) >= 50 and getPlayerStorageValue(cid, 99974) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99974, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins for reach level 50.")
                            
            elseif getPlayerLevel(cid) >= 60 and getPlayerStorageValue(cid, 99975) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99975, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins for reach level 60.")
                            
            elseif getPlayerLevel(cid) >= 70 and getPlayerStorageValue(cid, 99976) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99976, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins for reach level 70.")
                            
           elseif getPlayerLevel(cid) >= 80 and getPlayerStorageValue(cid, 99977) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99977, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins for advancing to Level 80.")

             elseif getPlayerLevel(cid) >= 90 and getPlayerStorageValue(cid, 99978) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99978, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins for advancing to Level 90.")
                
                            
            elseif getPlayerLevel(cid) >= 100 and getPlayerStorageValue(cid, 99979) ~= 1 then
                            doPlayerAddItem(cid, 24774, 10)
                            setPlayerStorageValue(cid, 99979, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 10 Tibia Coins for advancing to Level 100.")
                                                        
            
            elseif getPlayerLevel(cid) >= 110 and getPlayerStorageValue(cid, 99980) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99980, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins because you reached level 110.")
            
            elseif getPlayerLevel(cid) >= 120 and getPlayerStorageValue(cid, 99981) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99981, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins because you reached level 120.")           
            
            elseif getPlayerLevel(cid) >= 130 and getPlayerStorageValue(cid, 99982) ~= 1 then
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99982, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins because you reached level 130.")
                                                        
            elseif getPlayerLevel(cid) >= 140 and getPlayerStorageValue(cid, 99983) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 5)
                            setPlayerStorageValue(cid, 99983, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 5 Tibia Coins because you reached level 140.")
                            
            elseif getPlayerLevel(cid) >= 150 and getPlayerStorageValue(cid, 99984) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 15)
                            setPlayerStorageValue(cid, 99984, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 15 Tibia Coins because you reached level 150.")

            elseif getPlayerLevel(cid) >= 160 and getPlayerStorageValue(cid, 99985) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 10)
                            setPlayerStorageValue(cid, 99985, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 10 Tibia Coins because you reached level 160.")

            elseif getPlayerLevel(cid) >= 170 and getPlayerStorageValue(cid, 99986) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 10)
                            setPlayerStorageValue(cid, 99986, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 10 Tibia Coins because you reached level 170.")

            elseif getPlayerLevel(cid) >= 180 and getPlayerStorageValue(cid, 99987) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 10)
                            setPlayerStorageValue(cid, 99987, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 10 Tibia Coins because you reached level 180.")

            elseif getPlayerLevel(cid) >= 190 and getPlayerStorageValue(cid, 99988) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 10)
                            setPlayerStorageValue(cid, 99988, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 10 Tibia Coins because you reached level 190.")

            elseif getPlayerLevel(cid) >= 200 and getPlayerStorageValue(cid, 99989) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 25)
                            setPlayerStorageValue(cid, 99989, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 25 Tibia Coins because you reached level 200.")

            elseif getPlayerLevel(cid) >= 250 and getPlayerStorageValue(cid, 99990) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 50)
                            setPlayerStorageValue(cid, 99990, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 50 Tibia Coins because you reached level 250.")

            elseif getPlayerLevel(cid) >= 300 and getPlayerStorageValue(cid, 99991) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 70)
                            setPlayerStorageValue(cid, 99991, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 70 Tibia Coins because you reached level 300.")

            elseif getPlayerLevel(cid) >= 350 and getPlayerStorageValue(cid, 99992) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 50)
                            setPlayerStorageValue(cid, 99992, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 50 Tibia Coins because you reached level 350.")

            elseif getPlayerLevel(cid) >= 400 and getPlayerStorageValue(cid, 99993) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 80)
                            setPlayerStorageValue(cid, 99993, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 80 Tibia Coins because you reached level 400.")

            elseif getPlayerLevel(cid) >= 500 and getPlayerStorageValue(cid, 99994) ~= 1 then   
                            doPlayerAddItem(cid, 24774, 100)
                            setPlayerStorageValue(cid, 99994, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 100 Tibia Coins because you reached level 500.")

                            
 elseif getPlayerLevel(cid) >= 600 and getPlayerStorageValue(cid, 99995) ~= 1 then
                            doPlayerAddItem(cid, 24774, 100)
                            setPlayerStorageValue(cid, 99995, 1)
                            doPlayerSendTextMessage(cid, 19, "You have earn 100 Tibia Coins for reaching level 600.")

                                                
                            end
            return TRUE
end

Can you tell me what im doing wrong please
 
Last edited:
you forgot the header and the footer:

Code:
local creatureevent = CreatureEvent("example")

function creatureevent.onAdvance(player, skill, oldLevel, newLevel)
    -- your code goes here
    return true
end

creatureevent:register()

Lua:
local creatureevent = CreatureEvent("example")

function creatureevent.onAdvance(player, skill, oldLevel, newLevel)
    if player:getLevel() >= 8 and player:getStorageValue(99970) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99970, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins for reach level 8.")

    elseif player:getLevel() >= 20 and player:getStorageValue(99971) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99971, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins for reach level 20.")

    elseif player:getLevel() >= 30 and player:getStorageValue(99972) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99972, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins for reach level 30.")

    elseif player:getLevel() >= 40 and player:getStorageValue(99973) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99973, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins for reach level 40.")

    elseif player:getLevel() >= 50 and player:getStorageValue(99974) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99974, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins for reach level 50.")

    elseif player:getLevel() >= 60 and player:getStorageValue(99975) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99975, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins for reach level 60.")

    elseif player:getLevel() >= 70 and player:getStorageValue(99976) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99976, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins for reach level 70.")

    elseif player:getLevel() >= 80 and player:getStorageValue(99977) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99977, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins for advancing to Level 80.")

    elseif player:getLevel() >= 90 and player:getStorageValue(99978) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99978, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins for advancing to Level 90.")

    elseif player:getLevel() >= 100 and player:getStorageValue(99979) ~= 1 then
        player:addItem(24774, 10)
        player:setStorageValue(99979, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 10 Tibia Coins for advancing to Level 100.")

    elseif player:getLevel() >= 110 and player:getStorageValue(99980) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99980, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins because you reached level 110.")

    elseif player:getLevel() >= 120 and player:getStorageValue(99981) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99981, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins because you reached level 120.")

    elseif player:getLevel() >= 130 and player:getStorageValue(99982) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99982, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins because you reached level 130.")

    elseif player:getLevel() >= 140 and player:getStorageValue(99983) ~= 1 then
        player:addItem(24774, 5)
        player:setStorageValue(99983, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 5 Tibia Coins because you reached level 140.")

    elseif player:getLevel() >= 150 and player:getStorageValue(99984) ~= 1 then
        player:addItem(24774, 15)
        player:setStorageValue(99984, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 15 Tibia Coins because you reached level 150.")

    elseif player:getLevel() >= 160 and player:getStorageValue(99985) ~= 1 then
        player:addItem(24774, 10)
        player:setStorageValue(99985, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 10 Tibia Coins because you reached level 160.")

    elseif player:getLevel() >= 170 and player:getStorageValue(99986) ~= 1 then
        player:addItem(24774, 10)
        player:setStorageValue(99986, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 10 Tibia Coins because you reached level 170.")

    elseif player:getLevel() >= 180 and player:getStorageValue(99987) ~= 1 then
        player:addItem(24774, 10)
        player:setStorageValue(99987, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 10 Tibia Coins because you reached level 180.")

    elseif player:getLevel() >= 190 and player:getStorageValue(99988) ~= 1 then
        player:addItem(24774, 10)
        player:setStorageValue(99988, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 10 Tibia Coins because you reached level MESSAGE_INFO_DESCR0.")

    elseif player:getLevel() >= 200 and player:getStorageValue(99989) ~= 1 then
        player:addItem(24774, 25)
        player:setStorageValue(99989, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 25 Tibia Coins because you reached level 200.")

    elseif player:getLevel() >= 250 and player:getStorageValue(99990) ~= 1 then
        player:addItem(24774, 50)
        player:setStorageValue(99990, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 50 Tibia Coins because you reached level 250.")

    elseif player:getLevel() >= 300 and player:getStorageValue(99991) ~= 1 then
        player:addItem(24774, 70)
        player:setStorageValue(99991, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 70 Tibia Coins because you reached level 300.")

    elseif player:getLevel() >= 350 and player:getStorageValue(99992) ~= 1 then
        player:addItem(24774, 50)
        player:setStorageValue(99992, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 50 Tibia Coins because you reached level 350.")

    elseif player:getLevel() >= 400 and player:getStorageValue(99993) ~= 1 then
        player:addItem(24774, 80)
        player:setStorageValue(99993, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 80 Tibia Coins because you reached level 400.")

    elseif player:getLevel() >= 500 and player:getStorageValue(99994) ~= 1 then
        player:addItem(24774, 100)
        player:setStorageValue(99994, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 100 Tibia Coins because you reached level 500.")

    elseif player:getLevel() >= 600 and player:getStorageValue(99995) ~= 1 then
        player:addItem(24774, 100)
        player:setStorageValue(99995, 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have earn 100 Tibia Coins for reaching level 600.")
        end
    return true
end

creatureevent:register()
 
Last edited by a moderator:
@Evil Puncker ok it's creatureevent, I wasn't sure it's not the same way as before, already I'm not good hehe, in any case it works, I learned something, thank you frankly you are a genius

Is working, but giving an error on console,
Lua Script Error: [Scripts Interface]
D:\SERVER\otservbr-global\data\scripts\creaturescripts\others\recompense.lua:callback
...lobal\data\scripts\creaturescripts\others\recompense.lua:94: attempt to compare nil with number
stack traceback:
[C]: in function '__le'
...lobal\data\scripts\creaturescripts\others\recompense.lua:94: in function <...lobal\data\scripts\creaturescripts\others\recompense.lua:3>

@of course i edited this line: elseif player:getLevel() >= MESSAGE_INFO_DESCR0 and player:getStorageValue(99988) ~= 1 then and added correctly, but give's error also,
And not giving more error, just i see my addskill xxxx,level ( more than number 1 ) crashing, but well just for test the scritp
Thanks you really
 
Last edited:
Hello @Evil Puncker , i have learned a lot about the site you give me.
I try with a talkaction like !shop, but this one was not working like in talkaction exaplained, i have using a shop code from znote, and added first and last lines, but nothing happens, i try to do another customs talkactions, working perfectly but the shop not working, maybe anything in code is not working ?

Lua:
local znoteShop = TalkAction ("!Shop")
-- Znote Shop v1.1 for Znote AAC on TFS 1.2+
function onSay(player, 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 player:getStorageValue(storage) <= os.time() then
        player:setStorageValue(storage, os.time() + cooldown)

        local type_desc = {
            "itemids",
            "pending premium (skip)",
            "pending gender change (skip)",
            "pending character name change (skip)",
            "Outfit and addons",
            "Mounts",
            "Instant house purchase"
        }
        print("Player: " .. player:getName() .. " triggered !shop talkaction.")
        -- Create the query
        local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. player:getAccountId() .. ";")
        local served = false

        -- Detect if we got any results
        if orderQuery ~= false then
            repeat
                -- Fetch order values
                local q_id = result.getNumber(orderQuery, "id")
                local q_type = result.getNumber(orderQuery, "type")
                local q_itemid = result.getNumber(orderQuery, "itemid")
                local q_count = result.getNumber(orderQuery, "count")

                local description = "Unknown or custom type"
                if type_desc[q_type] ~= nil then
                    description = type_desc[q_type]
                end
                print("Processing type "..q_type..": ".. description)

                -- ORDER TYPE 1 (Regular item shop products)
                if q_type == 1 then
                    served = true
                    -- Get weight
                    if player:getFreeCapacity() >= ItemType(q_itemid):getWeight(q_count) then
                        db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                        player:addItem(q_itemid, q_count)
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received " .. q_count .. " x " .. ItemType(q_itemid):getName() .. "!")
                    else
                        player:sendTextMessage(MESSAGE_STATUS_WARNING, "Need more CAP!")
                    end
                end

                -- ORDER TYPE 5 (Outfit and addon)
                if q_type == 5 then
                    served = true

                    local itemid = q_itemid
                    local outfits = {}

                    if itemid > 1000 then
                        local first = math.floor(itemid/1000)
                        table.insert(outfits, first)
                        itemid = itemid - (first * 1000)
                    end
                    table.insert(outfits, itemid)

                    for _, outfitId in pairs(outfits) do
                        -- Make sure player don't already have this outfit and addon
                        if not player:hasOutfit(outfitId, q_count) then
                            db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                            player:addOutfit(outfitId)
                            player:addOutfitAddon(outfitId, q_count)
                            player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
                        else
                            player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
                        end
                    end
                end

                if Game.getClientVersion().min >= 870 then
                    -- ORDER TYPE 6 (Mounts)
                    if q_type == 6 then
                        served = true
                        -- Make sure player don't already have this outfit and addon
                        if not player:hasMount(q_itemid) then
                            db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                            player:addMount(q_itemid)
                            player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
                        else
                            player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this mount!")
                        end
                    end
                end

                -- ORDER TYPE 7 (Direct house purchase)
                if orderType == 7 then
                    served = true
                    local house = House(orderItemId)
                    -- Logged in player is not necessarily the player that bough the house. So we need to load player from db.
                    local buyerQuery = db.storeQuery("SELECT `name` FROM `players` WHERE `id` = "..orderCount.." LIMIT 1")
                    if buyerQuery ~= false then
                        local buyerName = result.getString(buyerQuery, "name")
                        result.free(buyerQuery)
                        if house then
                            db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
                            house:setOwnerGuid(orderCount)
                            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought the house "..house:getName().." on "..buyerName..", be sure to have the money for the rent in the bank.")
                            print("Process complete. [".. buyerName .."] has received house: ["..house:getName().."]")
                        end
                    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)
                -- Type 7 is for Instant house purchase (Already coded here)
                -- So use type 8+ for custom stuff, like etc packages.
                -- if q_type == 8 then
                -- end
            until not result.next(orderQuery)
            result.free(orderQuery)
            if not served then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders to process in-game.")
            end
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders.")
        end
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. player:getStorageValue(storage) - os.time())
    end
    return false
end

znoteShop:register()
 
Thanks for your reply !

I have founded 1 min ago like you the solution, changing like a dumb the lines and the result is:

finally working after delete line 81 ( gameclient ) because giving and error in console, and this line not needs on 12x only if you use lower version i think, correctly working, just the cooldown is not showing, but is working

EDIT: the link script you give me show error on console: line 79. is the gameclientversion, like i said needed delete this line and works perfectly

Thanks @Evil Puncker

Lua:
-- <talkaction words="!shop" script="znoteshop.lua"/>
-- Znote Shop v1.1 for Znote AAC on TFS 1.2+
local znoteShop = TalkAction ("!Shop")

function znoteShop.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.
    local player = Player(cid)

    if player:getStorageValue(storage) <= os.time() then
        player:setStorageValue(storage, os.time() + cooldown)

        local type_desc = {
            "itemids",
            "pending premium (skip)",
            "pending gender change (skip)",
            "pending character name change (skip)",
            "Outfit and addons",
            "Mounts",
            "Instant house purchase"
        }
        print("Player: " .. player:getName() .. " triggered !shop talkaction.")
        -- Create the query
        local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. player:getAccountId() .. ";")
        local served = false

        -- Detect if we got any results
        if orderQuery ~= false then
            repeat
                -- Fetch order values
                local q_id = result.getNumber(orderQuery, "id")
                local q_type = result.getNumber(orderQuery, "type")
                local q_itemid = result.getNumber(orderQuery, "itemid")
                local q_count = result.getNumber(orderQuery, "count")

                local description = "Unknown or custom type"
                if type_desc[q_type] ~= nil then
                    description = type_desc[q_type]
                end
                print("Processing type "..q_type..": ".. description)

                -- ORDER TYPE 1 (Regular item shop products)
                if q_type == 1 then
                    served = true
                    -- Get weight
                    if player:getFreeCapacity() >= ItemType(q_itemid):getWeight(q_count) then
                        db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                        player:addItem(q_itemid, q_count)
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received " .. q_count .. " x " .. ItemType(q_itemid):getName() .. "!")
                    else
                        player:sendTextMessage(MESSAGE_STATUS_WARNING, "Need more CAP!")
                    end
                end

                -- ORDER TYPE 5 (Outfit and addon)
                if q_type == 5 then
                    served = true

                    local itemid = q_itemid
                    local outfits = {}

                    if itemid > 1000 then
                        local first = math.floor(itemid/1000)
                        table.insert(outfits, first)
                        itemid = itemid - (first * 1000)
                    end
                    table.insert(outfits, itemid)

                    for _, outfitId in pairs(outfits) do
                        -- Make sure player don't already have this outfit and addon
                        if not player:hasOutfit(outfitId, q_count) then
                            db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                            player:addOutfit(outfitId)
                            player:addOutfitAddon(outfitId, q_count)
                            player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
                        else
                            player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
                        end
                    end
                end
                    -- ORDER TYPE 6 (Mounts)
                if q_type == 6 then
                    served = true
                        -- Make sure player don't already have this outfit and addon
                    if not player:hasMount(q_itemid) then
                        db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                        player:addMount(q_itemid)
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
                    else
                        player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this mount!")
                    end
                end

                -- ORDER TYPE 7 (Direct house purchase)
                if orderType == 7 then
                    served = true
                    local house = House(orderItemId)
                    -- Logged in player is not necessarily the player that bough the house. So we need to load player from db.
                    local buyerQuery = db.storeQuery("SELECT `name` FROM `players` WHERE `id` = "..orderCount.." LIMIT 1")
                    if buyerQuery ~= false then
                        local buyerName = result.getString(buyerQuery, "name")
                        result.free(buyerQuery)
                        if house then
                            db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
                            house:setOwnerGuid(orderCount)
                            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought the house "..house:getName().." on "..buyerName..", be sure to have the money for the rent in the bank.")
                            print("Process complete. [".. buyerName .."] has received house: ["..house:getName().."]")
                        end
                    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)
                -- Type 7 is for Instant house purchase (Already coded here)
                -- So use type 8+ for custom stuff, like etc packages.
                -- if q_type == 8 then
                -- end
            until not result.next(orderQuery)
            result.free(orderQuery)
            if not served then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders to process in-game.")
            end
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders.")
        end
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. player:getStorageValue(storage) - os.time())
    end
    return false
end

znoteShop:separator(" ")
znoteShop:register()
 
Back
Top