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

TFS 0.X cut/get a part of item name

samandriel

Active Member
Joined
Oct 19, 2016
Messages
242
Solutions
1
Reaction score
46
A old member @Xikini (don't enter here anymore) one time made a script to get a part of an description
TFS 0.X - Imbuements System to 0.4 (8.60) (https://otland.net/threads/imbuements-system-to-0-4-8-60.262623/)

i would like to know if it is possible to do on item name
is anyone know how to?

i have this script:
Code:
--[[
Offline player to player item trader (Auction System) by vDk
Script version: 1.2a [ -- FIXED CLONE ITEMS BUG -- ]
]]--
local config = {
    levelRequiredToAdd = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933, 6093, 2123}
}

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end
 
function onSay(cid, words, param, channel)
    if(param == '') then
        local msg = "Market:\n\n/market buy, ID\n/market remove, ID\n/market add, ItemName, ItemPrice, ItemCount\n\nMore information look in us website!"
        doPlayerPopupFYI(cid, msg)
        return true
    end

    local maxOffersPerPlayer = math.floor(getPlayerLevel(cid) / 5)
    local pricePerOffer = 500
 
    local t = string.explode(param, ",")
    if(t[1] == "add") then
        if((not t[2]) or (not t[3]) or (not t[4])) then
            local msg = "/market add, ItemName, ItemPrice, ItemCount"
            doPlayerPopupFYI(cid, msg)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, msg)
            return true
        end
 
        if(not tonumber(t[3]) or (not tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end
 
        if(string.len(t[3]) > 7 or (string.len(t[4]) > 3)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end
 
        local item = getItemIdByName(t[2], false)
        if(not item) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end
 
        if(getPlayerLevel(cid) < config.levelRequiredToAdd) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end
 
        if(isInArray(config.blocked_items, item)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end
 
        if(getPlayerItemCount(cid, item) < (tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end
 
        local check = db.getResult("SELECT `id` FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
        if(check:getID() == -1) then
        elseif(check:getRows(true) >= maxOffersPerPlayer) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max for your level: " .. maxOffersPerPlayer .. ")")
                return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end
 
        if(tonumber(t[4]) < 1 or (tonumber(t[3]) < 1)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        if(getPlayerBalance(cid) < 500) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to have 500GPs in your bank balance to make a offer.")
            return true
        end

        -- check if it is enchanted
        -- check if before name there is:
        -- [RARE] itemname
        -- [EPIC] itemname
        -- [LEGENDARY] itemname
        local ib_UID = getPlayerSlotItem(cid, CONST_SLOT_FEET).uid
        local itemString = getItemSpecialDescription(ib_UID)
        local one, two = itemString:match("([^,]+),([^,]+)")
        two = tonumber(two)
        print(one)
        print(two)

        doPlayerSetBalance(cid, getPlayerBalance(cid) - 500)
        updatePlayerBalance(getCreatureByName(cid), getPlayerBalance(cid))
 
        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        doPlayerRemoveItem(cid, item, itemcount)
        db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end
 
    if(t[1] == "buy") then
        if(not tonumber(t[2])) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        local buy = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(buy:getID() ~= -1) then
            if (getPlayerBalance(cid) < buy:getDataInt("cost")) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh Bank Balance.")
                buy:free()
                return true
            end
 
            if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("player"))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end
 
            if(getPlayerFreeCap(cid) < getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")))then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end
 
            if(isItemStackable((buy:getDataString("item_id")))) then
                doPlayerAddItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
            else
                for i = 1, buy:getDataInt("count") do
                    doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
                end
            end
            doPlayerSetBalance(cid, getPlayerBalance(cid) - buy:getDataInt("cost"))
            updatePlayerBalance(getCreatureName(cid), getPlayerBalance(cid))
            
            db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") .. " gps!")
           
            local tid = getPlayerByGUID(buy:getDataInt("player"))
            if(isPlayer(tid)) then
                doPlayerSetBalance(tid, getPlayerBalance(tid) + buy:getDataInt("cost"))
            else
                db.executeQuery("UPDATE `players` SET `balance` = `balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("player") .. ";")
            end
 
            buy:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
 
    if(t[1] == "remove") then
        if((not tonumber(t[2]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end
 
        local delete = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(delete:getID() ~= -1) then
            if(getPlayerGUID(cid) == delete:getDataInt("player")) then
                db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                if(isItemStackable(delete:getDataString("item_id"))) then
                    doPlayerAddItem(cid, delete:getDataString("item_id"), delete:getDataInt("count"))
                else
                    for i = 1, delete:getDataInt("count") do
                        doPlayerAddItem(cid, delete:getDataString("item_id"), 1)
                    end
                end
 
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
           
            delete:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
    return true
end

And i would like to know if it is possible to get this [RARE], [EPIC], [LEGENDARY] before item name

Just like he did
Code:
        -- check if it is enchanted
        -- check if before name there is:
        -- [RARE] itemname
        -- [EPIC] itemname
        -- [LEGENDARY] itemname
        local ib_UID = getPlayerSlotItem(cid, CONST_SLOT_FEET).uid
        local itemString = getItemSpecialDescription(ib_UID)
        local one, two = itemString:match("([^,]+),([^,]+)")
        two = tonumber(two)
        print(one)
        print(two)

i would like to detect if before item name there is a 1 [RARE], 2 [EPIC], 3 [LEGENDARY] or 4 else, if there isn't
and print this 4 options
 
local n = split(itemname, " ")
if n[1] == "[rare]" then
blabla
elseif n[1] == "[epic]" then
blablabla2

i tried:
Code:
        local itemname = t[2]
        print(itemname)
        local n = split(itemname, " ")
        if n[1] == "[RARE]" then
            print("RARE")
        elseif n[1] == "[EPIC]" then
            print("EPIC")
        elseif n[1] == "[LEGENDARY]" then
            print("LEGENDARY")
        else
            print("NO UPGRADES")
        end

prints
Code:
steel boots

[20:1:01.681] [Error - TalkAction Interface] 
[20:1:01.681] data/talkactions/scripts/auctionsystem.lua:onSay
[20:1:01.681] Description: 
[20:1:01.681] data/talkactions/scripts/auctionsystem.lua:97: attempt to call global 'split' (a nil value)
[20:1:01.681] stack traceback:
[20:1:01.681]     data/talkactions/scripts/auctionsystem.lua:97: in function <data/talkactions/scripts/auctionsystem.lua:15>

line 97 is:
Code:
local n = split(itemname, " ")
 
I looked to talkactions' additem.lua where params have to be splitted
Looks like tfs devs added some crazy thing called splitTrimmed

1575414623181.png

Normally you can use lua's split function. Take a peek here: lua-users wiki: Split Join (http://lua-users.org/wiki/SplitJoin)

Code:
local n = itemname:splitTrimmed(" ")

You can also add this function to your libs to make you able to use my split from past post
Lua:
function split(string, seperator)
     if seperator == nil then
            seperator = "%s"
     end
     local table = {}
     for string in string.gmatch(string, "([^"..seperator.."]+)") do
            table.insert(t, string)
     end
     return table
end
 
Last edited:
I looked to talkactions' additem.lua where params have to be splitted
Looks like tfs devs added some crazy thing called splitTrimmed

View attachment 40696

Normally you can use lua's split function. Take a peek here: lua-users wiki: Split Join (http://lua-users.org/wiki/SplitJoin)

Code:
local n = itemname:splitTrimmed(" ")

You can also add this function to your libs to make you able to use my split from past post
Lua:
function split(string, seperator)
     if seperator == nil then
            seperator = "%s"
     end
     local table = {}
     for string in string.gmatch(string, "([^"..seperator.."]+)") do
            table.insert(t, string)
     end
     return table
end

where u found it? XD

not work
Code:
steel boots

[21:19:09.291] [Error - TalkAction Interface]
[21:19:09.291] data/talkactions/scripts/auctionsystem.lua:onSay
[21:19:09.291] Description:
[21:19:09.291] data/talkactions/scripts/auctionsystem.lua:97: attempt to call method 'splitTrimmed' (a nil value)
[21:19:09.291] stack traceback:
[21:19:09.291]     data/talkactions/scripts/auctionsystem.lua:97: in function <data/talkactions/scripts/auctionsystem.lua:15>
 
function getRarity(str) return str:match('%[(%a+)%]') end print(getRarity(getItemName(ib_UID)))

how to put a condition in this function to return
0 when there is [STUFF]
1 when there is a [RARE]
2 when there is a [EPIC]
3 when there is a [LEGENDARY]
 
@Delusion i tried in your way
Code:
[0:14:48.945] [Error - TalkAction Interface] 
[0:14:48.945] data/talkactions/scripts/auctionsystem.lua:onSay
[0:14:48.945] Description: 
[0:14:48.945] data/talkactions/scripts/auctionsystem.lua:16: attempt to index local 'str' (a nil value)
[0:14:48.946] stack traceback:
[0:14:48.946]     data/talkactions/scripts/auctionsystem.lua:16: in function 'getRarity'
[0:14:48.946]     data/talkactions/scripts/auctionsystem.lua:99: in function <data/talkactions/scripts/auctionsystem.lua:20>

Code:
local test = getRarity(itemname)

Code:
function getRarity(str)
    local rname = str:match('%[(%a+)%]')
    print(rname)
end

full code

Code:
--[[
Offline player to player item trader (Auction System) by vDk
Script version: 1.2a [ -- FIXED CLONE ITEMS BUG -- ]
]]--
local config = {
    levelRequiredToAdd = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933, 6093, 2123}
}

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function getRarity(str)
    local rname = str:match('%[(%a+)%]')
    print(rname)
end
 
function onSay(cid, words, param, channel)
    if(param == '') then
        local msg = "Market:\n\n/market buy, ID\n/market remove, ID\n/market add, ItemName, ItemPrice, ItemCount\n\nMore information look in us website!"
        doPlayerPopupFYI(cid, msg)
        return true
    end

    local maxOffersPerPlayer = math.floor(getPlayerLevel(cid) / 5)
    local pricePerOffer = 500
 
    local t = string.explode(param, ",")
    if(t[1] == "add") then
        if((not t[2]) or (not t[3]) or (not t[4])) then
            local msg = "/market add, ItemName, ItemPrice, ItemCount"
            doPlayerPopupFYI(cid, msg)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, msg)
            return true
        end
 
        if(not tonumber(t[3]) or (not tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end
 
        if(string.len(t[3]) > 7 or (string.len(t[4]) > 3)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end
 
        local item = getItemIdByName(t[2], false)
        if(not item) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end
 
        if(getPlayerLevel(cid) < config.levelRequiredToAdd) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end
 
        if(isInArray(config.blocked_items, item)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end
 
        if(getPlayerItemCount(cid, item) < (tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end
 
        local check = db.getResult("SELECT `id` FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
        if(check:getID() == -1) then
        elseif(check:getRows(true) >= maxOffersPerPlayer) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max for your level: " .. maxOffersPerPlayer .. ")")
                return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end
 
        if(tonumber(t[4]) < 1 or (tonumber(t[3]) < 1)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        if(getPlayerBalance(cid) < 500) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to have 500GPs in your bank balance to make a offer.")
            return true
        end

        -- check if it is enchanted
        -- check if before name there is:
        -- [RARE] itemname
        -- [EPIC] itemname
        -- [LEGENDARY] itemname
        local test = getRarity(itemname)



        doPlayerSetBalance(cid, getPlayerBalance(cid) - 500)
        updatePlayerBalance(getCreatureByName(cid), getPlayerBalance(cid))
 
        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        doPlayerRemoveItem(cid, item, itemcount)
        db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end
 
    if(t[1] == "buy") then
        if(not tonumber(t[2])) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        local buy = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(buy:getID() ~= -1) then
            if (getPlayerBalance(cid) < buy:getDataInt("cost")) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh Bank Balance.")
                buy:free()
                return true
            end
 
            if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("player"))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end
 
            if(getPlayerFreeCap(cid) < getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")))then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end
 
            if(isItemStackable((buy:getDataString("item_id")))) then
                doPlayerAddItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
            else
                for i = 1, buy:getDataInt("count") do
                    doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
                end
            end
            doPlayerSetBalance(cid, getPlayerBalance(cid) - buy:getDataInt("cost"))
            updatePlayerBalance(getCreatureName(cid), getPlayerBalance(cid))
            
            db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") .. " gps!")
           
            local tid = getPlayerByGUID(buy:getDataInt("player"))
            if(isPlayer(tid)) then
                doPlayerSetBalance(tid, getPlayerBalance(tid) + buy:getDataInt("cost"))
            else
                db.executeQuery("UPDATE `players` SET `balance` = `balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("player") .. ";")
            end
 
            buy:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
 
    if(t[1] == "remove") then
        if((not tonumber(t[2]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end
 
        local delete = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(delete:getID() ~= -1) then
            if(getPlayerGUID(cid) == delete:getDataInt("player")) then
                db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                if(isItemStackable(delete:getDataString("item_id"))) then
                    doPlayerAddItem(cid, delete:getDataString("item_id"), delete:getDataInt("count"))
                else
                    for i = 1, delete:getDataInt("count") do
                        doPlayerAddItem(cid, delete:getDataString("item_id"), 1)
                    end
                end
 
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
           
            delete:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
    return true
end
 
Is it possible to do?
I'll not even use like that i just put the [] to make more easier
Just need with [] as base, if it is possible to do on lua ofc
 
I also tried your split @andu , but not work

Code:
function getRarity(str)
    local value = 0
    local n = split(itemname, " ")
    if n[1] == "[RARE]" then
       value = 1
    elseif n[1] == "[EPIC]" then
       value = 2
    elseif n[1] == "[EPIC]" then
       value = 3
    end 
    print(value)
    return value
end


Code:
--[[
Offline player to player item trader (Auction System) by vDk
Script version: 1.2a [ -- FIXED CLONE ITEMS BUG -- ]
]]--
local config = {
    levelRequiredToAdd = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933, 6093, 2123}
}

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function getRarity(str)
    local value = 0
    local n = split(itemname, " ")
    if n[1] == "[RARE]" then
       value = 1
    elseif n[1] == "[EPIC]" then
       value = 2
    elseif n[1] == "[EPIC]" then
       value = 3
    end 
    print(value)
    return value
end
 
function onSay(cid, words, param, channel)
    if(param == '') then
        local msg = "Market:\n\n/market buy, ID\n/market remove, ID\n/market add, ItemName, ItemPrice, ItemCount\n\nMore information look in us website!"
        doPlayerPopupFYI(cid, msg)
        return true
    end

    local maxOffersPerPlayer = math.floor(getPlayerLevel(cid) / 5)
    local pricePerOffer = 500
 
    local t = string.explode(param, ",")
    if(t[1] == "add") then
        if((not t[2]) or (not t[3]) or (not t[4])) then
            local msg = "/market add, ItemName, ItemPrice, ItemCount"
            doPlayerPopupFYI(cid, msg)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, msg)
            return true
        end
 
        if(not tonumber(t[3]) or (not tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end
 
        if(string.len(t[3]) > 7 or (string.len(t[4]) > 3)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end
 
        local item = getItemIdByName(t[2], false)
        if(not item) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end
 
        if(getPlayerLevel(cid) < config.levelRequiredToAdd) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end
 
        if(isInArray(config.blocked_items, item)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end
 
        if(getPlayerItemCount(cid, item) < (tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end
 
        local check = db.getResult("SELECT `id` FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
        if(check:getID() == -1) then
        elseif(check:getRows(true) >= maxOffersPerPlayer) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max for your level: " .. maxOffersPerPlayer .. ")")
                return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end
 
        if(tonumber(t[4]) < 1 or (tonumber(t[3]) < 1)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        if(getPlayerBalance(cid) < 500) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to have 500GPs in your bank balance to make a offer.")
            return true
        end

        -- check if it is enchanted
        -- check if before name there is:
        -- [RARE] itemname
        -- [EPIC] itemname
        -- [LEGENDARY] itemname
        local test = getRarity(itemname)



        doPlayerSetBalance(cid, getPlayerBalance(cid) - 500)
        updatePlayerBalance(getCreatureByName(cid), getPlayerBalance(cid))
 
        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        doPlayerRemoveItem(cid, item, itemcount)
        db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end
 
    if(t[1] == "buy") then
        if(not tonumber(t[2])) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        local buy = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(buy:getID() ~= -1) then
            if (getPlayerBalance(cid) < buy:getDataInt("cost")) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh Bank Balance.")
                buy:free()
                return true
            end
 
            if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("player"))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end
 
            if(getPlayerFreeCap(cid) < getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")))then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end
 
            if(isItemStackable((buy:getDataString("item_id")))) then
                doPlayerAddItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
            else
                for i = 1, buy:getDataInt("count") do
                    doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
                end
            end
            doPlayerSetBalance(cid, getPlayerBalance(cid) - buy:getDataInt("cost"))
            updatePlayerBalance(getCreatureName(cid), getPlayerBalance(cid))
            
            db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") .. " gps!")
           
            local tid = getPlayerByGUID(buy:getDataInt("player"))
            if(isPlayer(tid)) then
                doPlayerSetBalance(tid, getPlayerBalance(tid) + buy:getDataInt("cost"))
            else
                db.executeQuery("UPDATE `players` SET `balance` = `balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("player") .. ";")
            end
 
            buy:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
 
    if(t[1] == "remove") then
        if((not tonumber(t[2]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end
 
        local delete = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(delete:getID() ~= -1) then
            if(getPlayerGUID(cid) == delete:getDataInt("player")) then
                db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                if(isItemStackable(delete:getDataString("item_id"))) then
                    doPlayerAddItem(cid, delete:getDataString("item_id"), delete:getDataInt("count"))
                else
                    for i = 1, delete:getDataInt("count") do
                        doPlayerAddItem(cid, delete:getDataString("item_id"), 1)
                    end
                end
 
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
           
            delete:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
    return true
end

Code:
[14:54:50.138] [Error - TalkAction Interface] 
[14:54:50.138] data/talkactions/scripts/auctionsystem.lua:onSay
[14:54:50.138] Description: 
[14:54:50.138] data/lib/spellconfig.lua:24: attempt to index local 'string' (a nil value)
[14:54:50.138] stack traceback:
[14:54:50.138]     data/lib/spellconfig.lua:24: in function 'split'
[14:54:50.138]     data/talkactions/scripts/auctionsystem.lua:17: in function 'getRarity'
[14:54:50.138]     data/talkactions/scripts/auctionsystem.lua:108: in function <data/talkactions/scripts/auctionsystem.lua:29>
 
@Delusion i tried in your way
Code:
[0:14:48.945] [Error - TalkAction Interface]
[0:14:48.945] data/talkactions/scripts/auctionsystem.lua:onSay
[0:14:48.945] Description:
[0:14:48.945] data/talkactions/scripts/auctionsystem.lua:16: attempt to index local 'str' (a nil value)
[0:14:48.946] stack traceback:
[0:14:48.946]     data/talkactions/scripts/auctionsystem.lua:16: in function 'getRarity'
[0:14:48.946]     data/talkactions/scripts/auctionsystem.lua:99: in function <data/talkactions/scripts/auctionsystem.lua:20>

Code:
local test = getRarity(itemname)

Code:
function getRarity(str)
    local rname = str:match('%[(%a+)%]')
    print(rname)
end

full code

Code:
--[[
Offline player to player item trader (Auction System) by vDk
Script version: 1.2a [ -- FIXED CLONE ITEMS BUG -- ]
]]--
local config = {
    levelRequiredToAdd = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933, 6093, 2123}
}

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function getRarity(str)
    local rname = str:match('%[(%a+)%]')
    print(rname)
end

function onSay(cid, words, param, channel)
    if(param == '') then
        local msg = "Market:\n\n/market buy, ID\n/market remove, ID\n/market add, ItemName, ItemPrice, ItemCount\n\nMore information look in us website!"
        doPlayerPopupFYI(cid, msg)
        return true
    end

    local maxOffersPerPlayer = math.floor(getPlayerLevel(cid) / 5)
    local pricePerOffer = 500

    local t = string.explode(param, ",")
    if(t[1] == "add") then
        if((not t[2]) or (not t[3]) or (not t[4])) then
            local msg = "/market add, ItemName, ItemPrice, ItemCount"
            doPlayerPopupFYI(cid, msg)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, msg)
            return true
        end

        if(not tonumber(t[3]) or (not tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end

        if(string.len(t[3]) > 7 or (string.len(t[4]) > 3)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end

        local item = getItemIdByName(t[2], false)
        if(not item) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end

        if(getPlayerLevel(cid) < config.levelRequiredToAdd) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end

        if(isInArray(config.blocked_items, item)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end

        if(getPlayerItemCount(cid, item) < (tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end

        local check = db.getResult("SELECT `id` FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
        if(check:getID() == -1) then
        elseif(check:getRows(true) >= maxOffersPerPlayer) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max for your level: " .. maxOffersPerPlayer .. ")")
                return true
        end

        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end

        if(tonumber(t[4]) < 1 or (tonumber(t[3]) < 1)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        if(getPlayerBalance(cid) < 500) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to have 500GPs in your bank balance to make a offer.")
            return true
        end

        -- check if it is enchanted
        -- check if before name there is:
        -- [RARE] itemname
        -- [EPIC] itemname
        -- [LEGENDARY] itemname
        local test = getRarity(itemname)



        doPlayerSetBalance(cid, getPlayerBalance(cid) - 500)
        updatePlayerBalance(getCreatureByName(cid), getPlayerBalance(cid))

        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        doPlayerRemoveItem(cid, item, itemcount)
        db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end

    if(t[1] == "buy") then
        if(not tonumber(t[2])) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        local buy = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(buy:getID() ~= -1) then
            if (getPlayerBalance(cid) < buy:getDataInt("cost")) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh Bank Balance.")
                buy:free()
                return true
            end

            if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("player"))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end

            if(getPlayerFreeCap(cid) < getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")))then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end

            if(isItemStackable((buy:getDataString("item_id")))) then
                doPlayerAddItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
            else
                for i = 1, buy:getDataInt("count") do
                    doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
                end
            end
            doPlayerSetBalance(cid, getPlayerBalance(cid) - buy:getDataInt("cost"))
            updatePlayerBalance(getCreatureName(cid), getPlayerBalance(cid))
          
            db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") .. " gps!")
         
            local tid = getPlayerByGUID(buy:getDataInt("player"))
            if(isPlayer(tid)) then
                doPlayerSetBalance(tid, getPlayerBalance(tid) + buy:getDataInt("cost"))
            else
                db.executeQuery("UPDATE `players` SET `balance` = `balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("player") .. ";")
            end

            buy:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if(t[1] == "remove") then
        if((not tonumber(t[2]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end

        local delete = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(delete:getID() ~= -1) then
            if(getPlayerGUID(cid) == delete:getDataInt("player")) then
                db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                if(isItemStackable(delete:getDataString("item_id"))) then
                    doPlayerAddItem(cid, delete:getDataString("item_id"), delete:getDataInt("count"))
                else
                    for i = 1, delete:getDataInt("count") do
                        doPlayerAddItem(cid, delete:getDataString("item_id"), 1)
                    end
                end

                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
         
            delete:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
    return true
end
He has not declared anything in the itemname variable, is a null value, you must use the one @Delusion mentions you:
Lua:
local rarity = getRarity(getItemName(ib_UID))
 
Lua:
function getRarity(str) --[['str' param(not used!)]]
    local value = 0
    local n = split(itemname, " ") --[[itemname change to str]]
    if n[1] == "[RARE]" then
       value = 1
    elseif n[1] == "[EPIC]" then
       value = 2
    elseif n[1] == "[EPIC]" then --[[double, but this is not problem]]
       value = 3
    end
    print(value)
    return value
end
 
guys
i tried:
Code:
--[[
Offline player to player item trader (Auction System) by vDk
Script version: 1.2a [ -- FIXED CLONE ITEMS BUG -- ]
]]--
local config = {
    levelRequiredToAdd = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933, 6093, 2123}
}

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function getRarity(str)
    local value = 0
    local n = split(str, " ")
    if n[1] == "[RARE]" then
       value = 1
    elseif n[1] == "[EPIC]" then
       value = 2
    elseif n[1] == "[LEGENDARY]" then
       value = 3
    end
    return value
end
 
function onSay(cid, words, param, channel)
    if(param == '') then
        local msg = "Market:\n\n/market buy, ID\n/market remove, ID\n/market add, ItemName, ItemPrice, ItemCount\n\nMore information look in us website!"
        doPlayerPopupFYI(cid, msg)
        return true
    end

    local maxOffersPerPlayer = math.floor(getPlayerLevel(cid) / 5)
    local pricePerOffer = 500
 
    local t = string.explode(param, ",")
    if(t[1] == "add") then
        if((not t[2]) or (not t[3]) or (not t[4])) then
            local msg = "/market add, ItemName, ItemPrice, ItemCount"
            doPlayerPopupFYI(cid, msg)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, msg)
            return true
        end
 
        if(not tonumber(t[3]) or (not tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end
 
        if(string.len(t[3]) > 7 or (string.len(t[4]) > 3)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end
 
        local item = getItemIdByName(t[2], false)
        if(not item) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end
 
        if(getPlayerLevel(cid) < config.levelRequiredToAdd) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end
 
        if(isInArray(config.blocked_items, item)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end
 
        if(getPlayerItemCount(cid, item) < (tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end
 
        local check = db.getResult("SELECT `id` FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
        if(check:getID() == -1) then
        elseif(check:getRows(true) >= maxOffersPerPlayer) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max for your level: " .. maxOffersPerPlayer .. ")")
                return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end
 
        if(tonumber(t[4]) < 1 or (tonumber(t[3]) < 1)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        if(getPlayerBalance(cid) < 500) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to have 500GPs in your bank balance to make a offer.")
            return true
        end

        -- check if it is enchanted
        -- check if before name there is:
        -- [RARE] itemname
        -- [EPIC] itemname
        -- [LEGENDARY] itemname

        local itemname = t[2]
        print(itemname)
        local test = getRarity(itemname)
        print(test)

        doPlayerSetBalance(cid, getPlayerBalance(cid) - 500)
        updatePlayerBalance(getCreatureByName(cid), getPlayerBalance(cid))
 
        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        doPlayerRemoveItem(cid, item, itemcount)
        db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end
 
    if(t[1] == "buy") then
        if(not tonumber(t[2])) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        local buy = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(buy:getID() ~= -1) then
            if (getPlayerBalance(cid) < buy:getDataInt("cost")) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh Bank Balance.")
                buy:free()
                return true
            end
 
            if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("player"))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end
 
            if(getPlayerFreeCap(cid) < getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")))then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end
 
            if(isItemStackable((buy:getDataString("item_id")))) then
                doPlayerAddItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
            else
                for i = 1, buy:getDataInt("count") do
                    doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
                end
            end
            doPlayerSetBalance(cid, getPlayerBalance(cid) - buy:getDataInt("cost"))
            updatePlayerBalance(getCreatureName(cid), getPlayerBalance(cid))
            
            db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") .. " gps!")
           
            local tid = getPlayerByGUID(buy:getDataInt("player"))
            if(isPlayer(tid)) then
                doPlayerSetBalance(tid, getPlayerBalance(tid) + buy:getDataInt("cost"))
            else
                db.executeQuery("UPDATE `players` SET `balance` = `balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("player") .. ";")
            end
 
            buy:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
 
    if(t[1] == "remove") then
        if((not tonumber(t[2]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end
 
        local delete = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(delete:getID() ~= -1) then
            if(getPlayerGUID(cid) == delete:getDataInt("player")) then
                db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                if(isItemStackable(delete:getDataString("item_id"))) then
                    doPlayerAddItem(cid, delete:getDataString("item_id"), delete:getDataInt("count"))
                else
                    for i = 1, delete:getDataInt("count") do
                        doPlayerAddItem(cid, delete:getDataString("item_id"), 1)
                    end
                end
 
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
           
            delete:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
    return true
end

but got this error:
Code:
jagged sword

[23:30:45.379] [Error - TalkAction Interface] 
[23:30:45.379] data/talkactions/scripts/auctionsystem.lua:onSay
[23:30:45.379] Description: 
[23:30:45.379] data/lib/spellconfig.lua:27: attempt to call field 'insert' (a nil value)
[23:30:45.379] stack traceback:
[23:30:45.379]     data/lib/spellconfig.lua:27: in function 'split'
[23:30:45.379]     data/talkactions/scripts/auctionsystem.lua:17: in function 'getRarity'
[23:30:45.379]     data/talkactions/scripts/auctionsystem.lua:110: in function <data/talkactions/scripts/auctionsystem.lua:28>
 

did i make something wrong?

Code:
--[[
Offline player to player item trader (Auction System) by vDk
Script version: 1.2a [ -- FIXED CLONE ITEMS BUG -- ]
]]--
local config = {
    levelRequiredToAdd = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933, 6093, 2123}
}

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function getRarity(str)
    print("starts getRarity")
    local value = 0
    local n = str:match("%[(.-)%]")
    print(n)
    if n == "[RARE]" then
       value = 1
    elseif n == "[EPIC]" then
       value = 2
    elseif n == "[LEGENDARY]" then
       value = 3
    end
    print(value)
    print("ends getRarity")
    return value
end
 
function onSay(cid, words, param, channel)
    if(param == '') then
        local msg = "Market:\n\n/market buy, ID\n/market remove, ID\n/market add, ItemName, ItemPrice, ItemCount\n\nMore information look in us website!"
        doPlayerPopupFYI(cid, msg)
        return true
    end

    local maxOffersPerPlayer = math.floor(getPlayerLevel(cid) / 5)
    local pricePerOffer = 500
 
    local t = string.explode(param, ",")
    if(t[1] == "add") then
        if((not t[2]) or (not t[3]) or (not t[4])) then
            local msg = "/market add, ItemName, ItemPrice, ItemCount"
            doPlayerPopupFYI(cid, msg)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, msg)
            return true
        end
 
        if(not tonumber(t[3]) or (not tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end
 
        if(string.len(t[3]) > 7 or (string.len(t[4]) > 3)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end
 
        local item = getItemIdByName(t[2], false)
        if(not item) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end
 
        if(getPlayerLevel(cid) < config.levelRequiredToAdd) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end
 
        if(isInArray(config.blocked_items, item)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end
 
        if(getPlayerItemCount(cid, item) < (tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end
 
        local check = db.getResult("SELECT `id` FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
        if(check:getID() == -1) then
        elseif(check:getRows(true) >= maxOffersPerPlayer) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max for your level: " .. maxOffersPerPlayer .. ")")
                return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end
 
        if(tonumber(t[4]) < 1 or (tonumber(t[3]) < 1)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        if(getPlayerBalance(cid) < 500) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to have 500GPs in your bank balance to make a offer.")
            return true
        end

        -- check if it is enchanted
        -- check if before name there is:
        -- [RARE] itemname
        -- [EPIC] itemname
        -- [LEGENDARY] itemname

        local itemname = t[2]
        print(itemname)
        local test = getRarity(itemname)
        print(test)

        doPlayerSetBalance(cid, getPlayerBalance(cid) - 500)
        updatePlayerBalance(getCreatureByName(cid), getPlayerBalance(cid))
 
        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        doPlayerRemoveItem(cid, item, itemcount)
        db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end
 
    if(t[1] == "buy") then
        if(not tonumber(t[2])) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        local buy = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(buy:getID() ~= -1) then
            if (getPlayerBalance(cid) < buy:getDataInt("cost")) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh Bank Balance.")
                buy:free()
                return true
            end
 
            if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("player"))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end
 
            if(getPlayerFreeCap(cid) < getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")))then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end
 
            if(isItemStackable((buy:getDataString("item_id")))) then
                doPlayerAddItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
            else
                for i = 1, buy:getDataInt("count") do
                    doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
                end
            end
            doPlayerSetBalance(cid, getPlayerBalance(cid) - buy:getDataInt("cost"))
            updatePlayerBalance(getCreatureName(cid), getPlayerBalance(cid))
            
            db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") .. " gps!")
           
            local tid = getPlayerByGUID(buy:getDataInt("player"))
            if(isPlayer(tid)) then
                doPlayerSetBalance(tid, getPlayerBalance(tid) + buy:getDataInt("cost"))
            else
                db.executeQuery("UPDATE `players` SET `balance` = `balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("player") .. ";")
            end
 
            buy:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
 
    if(t[1] == "remove") then
        if((not tonumber(t[2]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end
 
        local delete = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(delete:getID() ~= -1) then
            if(getPlayerGUID(cid) == delete:getDataInt("player")) then
                db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                if(isItemStackable(delete:getDataString("item_id"))) then
                    doPlayerAddItem(cid, delete:getDataString("item_id"), delete:getDataInt("count"))
                else
                    for i = 1, delete:getDataInt("count") do
                        doPlayerAddItem(cid, delete:getDataString("item_id"), 1)
                    end
                end
 
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
           
            delete:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
    return true
end


Code:
00:39 You see a [RARE] jagged sword (Atk:24, Def:23).
It weighs 10.00 oz.

00:39 You successfully add 1 jagged sword for 1000 gps to offerts database.

Code:
jagged sword
starts getRarity

0
ends getRarity
0
 
If you use the function of my image, you will have to compare the result without the square brackets []
per example: if n == "RARE" then
-- NO --
if n == "[RARE]" then
 
script:
Code:
--[[
Offline player to player item trader (Auction System) by vDk
Script version: 1.2a [ -- FIXED CLONE ITEMS BUG -- ]
]]--
local config = {
    levelRequiredToAdd = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933, 6093, 2123}
}

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function getRarity(str)
    print("starts getRarity")
    local value = 0
    local n = str:match("%[(.-)%]")
    print("rarity:")
    print(n)
    if n == "RARE" then
       value = 1
    elseif n == "EPIC" then
       value = 2
    elseif n == "LEGENDARY" then
       value = 3
    end
    print("value:")
    print(value)
    print("ends getRarity")
    return value
end
 
function onSay(cid, words, param, channel)
    if(param == '') then
        local msg = "Market:\n\n/market buy, ID\n/market remove, ID\n/market add, ItemName, ItemPrice, ItemCount\n\nMore information look in us website!"
        doPlayerPopupFYI(cid, msg)
        return true
    end

    local maxOffersPerPlayer = math.floor(getPlayerLevel(cid) / 5)
    local pricePerOffer = 500
 
    local t = string.explode(param, ",")
    if(t[1] == "add") then
        if((not t[2]) or (not t[3]) or (not t[4])) then
            local msg = "/market add, ItemName, ItemPrice, ItemCount"
            doPlayerPopupFYI(cid, msg)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, msg)
            return true
        end
 
        if(not tonumber(t[3]) or (not tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end
 
        if(string.len(t[3]) > 7 or (string.len(t[4]) > 3)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end
 
        local item = getItemIdByName(t[2], false)
        if(not item) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end
 
        if(getPlayerLevel(cid) < config.levelRequiredToAdd) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end
 
        if(isInArray(config.blocked_items, item)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end
 
        if(getPlayerItemCount(cid, item) < (tonumber(t[4]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end
 
        local check = db.getResult("SELECT `id` FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
        if(check:getID() == -1) then
        elseif(check:getRows(true) >= maxOffersPerPlayer) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max for your level: " .. maxOffersPerPlayer .. ")")
                return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end
 
        if(tonumber(t[4]) < 1 or (tonumber(t[3]) < 1)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        if(getPlayerBalance(cid) < 500) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to have 500GPs in your bank balance to make a offer.")
            return true
        end

        -- check if it is enchanted
        -- check if before name there is:
        -- [RARE] itemname
        -- [EPIC] itemname
        -- [LEGENDARY] itemname

        local itemname = t[2]
        print(itemname)
        local test = getRarity(itemname)
        print(test)

        doPlayerSetBalance(cid, getPlayerBalance(cid) - 500)
        updatePlayerBalance(getCreatureByName(cid), getPlayerBalance(cid))
 
        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        doPlayerRemoveItem(cid, item, itemcount)
        db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end
 
    if(t[1] == "buy") then
        if(not tonumber(t[2])) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        local buy = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(buy:getID() ~= -1) then
            if (getPlayerBalance(cid) < buy:getDataInt("cost")) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh Bank Balance.")
                buy:free()
                return true
            end
 
            if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("player"))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end
 
            if(getPlayerFreeCap(cid) < getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")))then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end
 
            if(isItemStackable((buy:getDataString("item_id")))) then
                doPlayerAddItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
            else
                for i = 1, buy:getDataInt("count") do
                    doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
                end
            end
            doPlayerSetBalance(cid, getPlayerBalance(cid) - buy:getDataInt("cost"))
            updatePlayerBalance(getCreatureName(cid), getPlayerBalance(cid))
            
            db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") .. " gps!")
           
            local tid = getPlayerByGUID(buy:getDataInt("player"))
            if(isPlayer(tid)) then
                doPlayerSetBalance(tid, getPlayerBalance(tid) + buy:getDataInt("cost"))
            else
                db.executeQuery("UPDATE `players` SET `balance` = `balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("player") .. ";")
            end
 
            buy:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
 
    if(t[1] == "remove") then
        if((not tonumber(t[2]))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end
 
        if(config.SendOffersOnlyInPZ) then
            if(not getTilePzInfo(getPlayerPosition(cid))) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end
 
        local delete = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
        if(delete:getID() ~= -1) then
            if(getPlayerGUID(cid) == delete:getDataInt("player")) then
                db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                if(isItemStackable(delete:getDataString("item_id"))) then
                    doPlayerAddItem(cid, delete:getDataString("item_id"), delete:getDataInt("count"))
                else
                    for i = 1, delete:getDataInt("count") do
                        doPlayerAddItem(cid, delete:getDataString("item_id"), 1)
                    end
                end
 
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
           
            delete:free()
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end
    return true
end

prints:
Code:
jagged sword
starts getRarity
rarity:

value:
0
ends getRarity
0
 
@samandriel ym.. it is talkaction function.. so.. can you post how you use that?
i see that "/market add, ItemName, ItemPrice, ItemCount", but show exactly what you write.

Okay, i don't have more time, so...

Good options for check Item will be.. check from slot:
Right/left hand, ammo.
 
Last edited:
Back
Top