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

Lua [MOD] Sell Character InGame!

WiLDTuRTLE

Member
Joined
Feb 26, 2011
Messages
478
Reaction score
5
Im getting a huge a$$ error only when !character list, sell/buy works, could anyone help me fixing that error?

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Characters Retail System" version="1.0" author="LuckOake" contact="none" enabled="yes">
 
<config name="Retail"><![CDATA[
price = 27112
owner = 27113
level = 50 -- Min level to sell
min_price = 10000 -- Min price
max_price = 500000 -- Max price
 
function doTransferCharacter(cid, accId)
        return db.executeQuery("UPDATE `players` SET `account_id` = "..accId.." WHERE `id` = "..getPlayerGUIDByName(cid).."")
end
 
function doOfflinePlayerAddMoney(guid, money)
        return db.executeQuery("UPDATE `players` SET `balance` = `balance` + '"..money.."' WHERE `id` = '"..getPlayerGUIDByName(guid).."';")
end
 
function setOfflinePlayerStorageValue(name, key, value)
        local result = db.getResult("SELECT * FROM `player_storage` WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
        if result:getID() == -1 then
                return db.executeQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES (".. getPlayerGUIDByName(name) ..", ".. key ..", ".. value ..");")
        else
                result:free()
                return db.executeQuery("UPDATE `player_storage` SET `value` = ".. value .." WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
        end
end
 
function getOfflinePlayerStorageValue(name, key)
        local result, ret = db.getResult("SELECT `value` FROM `player_storage` WHERE `player_id` = '".. getPlayerGUIDByName(name) .."' AND `key` = ".. key ..";")
        if result:getID() == -1 then
                return nil
        end
        ret = result:getDataInt("value")
        result:free()
        return ret
end
 
function getOfflinePlayerValue(name, value)
        local result, ret = db.getResult("SELECT `"..value.."` FROM `players` WHERE `id` = "..getPlayerGUIDByName(name)..";")
        ret = result:getDataInt(value)
        result:free()
        return ret
end
 
function isCharacterForSale(name)
        if not getOfflinePlayerStorageValue(name, price) or getOfflinePlayerStorageValue(name, price) < 1 then
        return false
        else
        return true
        end
end
]]></config>
 
<talkaction words="!character" event="buffer"><![CDATA[
domodlib('Retail')
        local t = string.explode(param, ",")
 
        if t[1] == "sell" then
                if not t[3] or not tonumber(t[3]) or t[4] or tonumber(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name and the price.") return true
                elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
                elseif isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is already for sale.") return true
                elseif getPlayerGUIDByName(t[2]) == getPlayerGUID(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot sell yourself.") return true
                elseif getPlayerByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The character must be offline to be sold.") return true
                elseif getOfflinePlayerValue(t[2], "level") < level then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your character can't be sold until it has level "..level..".") return true
                elseif tonumber(t[3]) < min_price then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the minimum price for selling a character is "..min_price..".") return true
                elseif tonumber(t[3]) > max_price then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the maximum price for selling a character is "..max_price..".") return true
                end
 
                        setOfflinePlayerStorageValue(t[2], price, t[3])
                        setOfflinePlayerStorageValue(t[2], owner, getPlayerGUID(cid))
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" is now for sale for the price of "'..t[3]..'" gold coins.')
        elseif t[1] == "buy" then
                if not t[2] then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
                elseif not playerExists(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character doesn't exist.") return true
                elseif getPlayerAccountId(cid) == getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't buy your own character.") return true
                elseif not isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
                elseif not doPlayerRemoveMoney(cid, getOfflinePlayerStorageValue(t[2], price)) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Not enough money. This character's price is "..getOfflinePlayerStorageValue(t[2], price).." gold coins.") return true
                end
 
                if not getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)) then
                        doOfflinePlayerAddMoney(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
                        setOfflinePlayerStorageValue(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), 41792, getPlayerGUIDByName(t[2]))
                else
                        doPlayerAddMoney(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
                        doPlayerSendTextMessage(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" has been sold for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
                end
                        doTransferCharacter(t[2], getPlayerAccountId(cid))
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You bought the character "'..t[2]..'" for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
                        setOfflinePlayerStorageValue(t[2], owner, -1)
                        setOfflinePlayerStorageValue(t[2], price, -1) return true
        elseif t[1] == "remove" then
                if not t[2] then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
                elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
                elseif not isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
                end
 
                        setOfflinePlayerStorageValue(t[2], price, -1)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You removed the character "'..t[2]..'" from the Characters Retail.') return true
        elseif t[1] == "list" then
                local result = db.getResult("SELECT `name` FROM `players`")
                if result:getID() == -1 then
                        return true
                end
                local msg = "Characters for Sale:\n\n"
                while true do
                        local name = result:getDataString("name")
                        if isCharacterForSale(name) then
                        local sex = getOfflinePlayerValue(name, "sex") == 1 and "Male" or "Female"
                                msg = ""..msg.." - ".. name .." (Level: "..getOfflinePlayerValue(name, "level").." / Vocation: "..getVocationInfo(getOfflinePlayerValue(name, "vocation")).name.." / Sex: "..sex.." / Owner: "..getPlayerNameByGUID(getOfflinePlayerStorageValue(name, owner))..") [Price: "..getOfflinePlayerStorageValue(name, price).."] \n"
                        end
                        if not result:next() then
                                break
                        end
                end
                        doPlayerPopupFYI(cid, msg) return true
        elseif not t[1] or t[1] ~= "buy" or t[1] ~= "sell" or t[1] ~= "remove" or t[1] ~= "list" then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Incorrect params. You can only 'buy' or 'sell' a character, 'remove' it from the Characters Retail or see the 'list' of characters for sale.") return true
        end
return true
]]></talkaction>
 
<event type="login" name="RetailLogin" event="script"><![CDATA[
function onLogin(cid)
domodlib('Retail')
        if getPlayerStorageValue(cid, price) > 0 then return false
        elseif getPlayerStorageValue(cid, 41792) ~= -1 then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You sold the character "..getPlayerNameByGUID(getPlayerStorageValue(cid, 41792))..". The money is in your bank account.")
                setPlayerStorageValue(cid, 41792, -1)
        end
return true
end
]]></event>
 
</mod>

the error is so big lol, idk how to copy from console/gui idk what im using, but i can't copy anything so ill provide with pics if you guys need them to fix it .[!character list] the list part of the script seem to not work fine.
It doesnt PopupFIY ingame, and send a huge ass error
 
Im getting a huge a$$ error only when !character list, sell/buy works, could anyone help me fixing that error?

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Characters Retail System" version="1.0" author="LuckOake" contact="none" enabled="yes">
 
<config name="Retail"><=!=[=C=D=A=T=A=[
price = 27112
owner = 27113
level = 50 -- Min level to sell
min_price = 10000 -- Min price
max_price = 500000 -- Max price
 
function doTransferCharacter(cid, accId)
        return db.executeQuery("UPDATE `players` SET `account_id` = "..accId.." WHERE `id` = "..getPlayerGUIDByName(cid).."")
end
 
function doOfflinePlayerAddMoney(guid, money)
        return db.executeQuery("UPDATE `players` SET `balance` = `balance` + '"..money.."' WHERE `id` = '"..getPlayerGUIDByName(guid).."';")
end
 
function setOfflinePlayerStorageValue(name, key, value)
        local result = db.getResult("SELECT * FROM `player_storage` WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
        if result:getID() == -1 then
                return db.executeQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES (".. getPlayerGUIDByName(name) ..", ".. key ..", ".. value ..");")
        else
                result:free()
                return db.executeQuery("UPDATE `player_storage` SET `value` = ".. value .." WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
        end
end
 
function getOfflinePlayerStorageValue(name, key)
        local result, ret = db.getResult("SELECT `value` FROM `player_storage` WHERE `player_id` = '".. getPlayerGUIDByName(name) .."' AND `key` = ".. key ..";")
        if result:getID() == -1 then
                return nil
        end
        ret = result:getDataInt("value")
        result:free()
        return ret
end
 
function getOfflinePlayerValue(name, value)
        local result, ret = db.getResult("SELECT `"..value.."` FROM `players` WHERE `id` = "..getPlayerGUIDByName(name)..";")
        ret = result:getDataInt(value)
        result:free()
        return ret
end
 
function isCharacterForSale(name)
        if not getOfflinePlayerStorageValue(name, price) or getOfflinePlayerStorageValue(name, price) < 1 then
        return false
        else
        return true
        end
end
]=]=></config>
 
<talkaction words="!character" event="buffer"><=!=[=C=D=A=T=A=[
domodlib('Retail')
        local t = string.explode(param, ",")
 
        if t[1] == "sell" then
                if not t[3] or not tonumber(t[3]) or t[4] or tonumber(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name and the price.") return true
                elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
                elseif isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is already for sale.") return true
                elseif getPlayerGUIDByName(t[2]) == getPlayerGUID(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot sell yourself.") return true
                elseif getPlayerByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The character must be offline to be sold.") return true
                elseif getOfflinePlayerValue(t[2], "level") < level then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your character can't be sold until it has level "..level..".") return true
                elseif tonumber(t[3]) < min_price then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the minimum price for selling a character is "..min_price..".") return true
                elseif tonumber(t[3]) > max_price then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the maximum price for selling a character is "..max_price..".") return true
                end
 
                        setOfflinePlayerStorageValue(t[2], price, t[3])
                        setOfflinePlayerStorageValue(t[2], owner, getPlayerGUID(cid))
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" is now for sale for the price of "'..t[3]..'" gold coins.')
        elseif t[1] == "buy" then
                if not t[2] then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
                elseif not playerExists(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character doesn't exist.") return true
                elseif getPlayerAccountId(cid) == getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't buy your own character.") return true
                elseif not isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
                elseif not doPlayerRemoveMoney(cid, getOfflinePlayerStorageValue(t[2], price)) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Not enough money. This character's price is "..getOfflinePlayerStorageValue(t[2], price).." gold coins.") return true
                end
 
                if not getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)) then
                        doOfflinePlayerAddMoney(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
                        setOfflinePlayerStorageValue(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), 41792, getPlayerGUIDByName(t[2]))
                else
                        doPlayerAddMoney(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
                        doPlayerSendTextMessage(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" has been sold for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
                end
                        doTransferCharacter(t[2], getPlayerAccountId(cid))
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You bought the character "'..t[2]..'" for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
                        setOfflinePlayerStorageValue(t[2], owner, -1)
                        setOfflinePlayerStorageValue(t[2], price, -1) return true
        elseif t[1] == "remove" then
                if not t[2] then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
                elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
                elseif not isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
                end
 
                        setOfflinePlayerStorageValue(t[2], price, -1)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You removed the character "'..t[2]..'" from the Characters Retail.') return true
        elseif t[1] == "list" then
                local result = db.getResult("SELECT `name` FROM `players`")
                if result:getID() == -1 then
                        return true
                end
                local msg = "Characters for Sale:\n\n"
                while true do
                        local name = result:getDataString("name")
                        if isCharacterForSale(name) then
                        local sex = getOfflinePlayerValue(name, "sex") == 1 and "Male" or "Female"
                                msg = ""..msg.." - ".. name .." (Level: "..getOfflinePlayerValue(name, "level").." / Vocation: "..getVocationInfo(getOfflinePlayerValue(name, "vocation")).name.." / Sex: "..sex.." / Owner: "..getPlayerNameByGUID(getOfflinePlayerStorageValue(name, owner))..") [Price: "..getOfflinePlayerStorageValue(name, price).."] \n"
                        end
                        if not result:next() then
                                break
                        end
                end
                        doPlayerPopupFYI(cid, msg) return true
        elseif not t[1] or t[1] ~= "buy" or t[1] ~= "sell" or t[1] ~= "remove" or t[1] ~= "list" then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Incorrect params. You can only 'buy' or 'sell' a character, 'remove' it from the Characters Retail or see the 'list' of characters for sale.") return true
        end
return true
]=]=></talkaction>
 
<event type="login" name="RetailLogin" event="script"><=!=[=C=D=A=T=A=[
function onLogin(cid)
domodlib('Retail')
        if getPlayerStorageValue(cid, price) > 0 then return false
        elseif getPlayerStorageValue(cid, 41792) ~= -1 then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You sold the character "..getPlayerNameByGUID(getPlayerStorageValue(cid, 41792))..". The money is in your bank account.")
                setPlayerStorageValue(cid, 41792, -1)
        end
return true
end
]=]=></event>
 
</mod>

the error is so big lol, idk how to copy from console/gui idk what im using, but i can't copy anything so ill provide with pics if you guys need them to fix it .[!character list] the list part of the script seem to not work fine.
It doesnt PopupFIY ingame, and send a huge ass error

If you could show us the error that would be awesome ;>
 
part1
nd8k5d.png


^&v [same line so u dont get lost]
part2
2whj89k.png
 
Lua:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Characters Retail System" version="1.0" author="LuckOake" contact="none" enabled="yes">
 
<config name="Retail"><![CDATA[[
price = 27112
owner = 27113
level = 50 -- Min level to sell
min_price = 10000 -- Min price
max_price = 500000 -- Max price
 
function doTransferCharacter(cid, accId)
        return db.executeQuery("UPDATE `players` SET `account_id` = "..accId.." WHERE `id` = "..getPlayerGUIDByName(cid).."")
end
 
function doOfflinePlayerAddMoney(guid, money)
        return db.executeQuery("UPDATE `players` SET `balance` = `balance` + '"..money.."' WHERE `id` = '"..getPlayerGUIDByName(guid).."';")
end
 
function setOfflinePlayerStorageValue(name, key, value)
        local result = db.getResult("SELECT * FROM `player_storage` WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
        if result:getID() == -1 then
                return db.executeQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES (".. getPlayerGUIDByName(name) ..", ".. key ..", ".. value ..");")
        else
                result:free()
                return db.executeQuery("UPDATE `player_storage` SET `value` = ".. value .." WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
        end
end
 
function getOfflinePlayerStorageValue(name, key)
        local result, ret = db.getResult("SELECT `value` FROM `player_storage` WHERE `player_id` = '".. getPlayerGUIDByName(name) .."' AND `key` = ".. key ..";")
        if result:getID() == -1 then
                return nil
        end
        ret = result:getDataInt("value")
        result:free()
        return ret
end
 
function getOfflinePlayerValue(name, value)
        local result, ret = db.getResult("SELECT `"..value.."` FROM `players` WHERE `id` = "..getPlayerGUIDByName(name)..";")
        ret = result:getDataInt(value)
        result:free()
        return ret
end
 
function isCharacterForSale(name)
        if not getOfflinePlayerStorageValue(name, price) or getOfflinePlayerStorageValue(name, price) < 1 then
        return false
        else
        return true
        end
end
]]></config>
 
<talkaction words="!character" event="buffer"><![CDATA[[
domodlib('Retail')
        local t = string.explode(param, ",")
 
        if t[1] == "sell" then
                if not t[3] or not tonumber(t[3]) or t[4] or tonumber(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name and the price.") return true
                elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
                elseif isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is already for sale.") return true
                elseif getPlayerGUIDByName(t[2]) == getPlayerGUID(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot sell yourself.") return true
                elseif getPlayerByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The character must be offline to be sold.") return true
                elseif getOfflinePlayerValue(t[2], "level") < level then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your character can't be sold until it has level "..level..".") return true
                elseif tonumber(t[3]) < min_price then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the minimum price for selling a character is "..min_price..".") return true
                elseif tonumber(t[3]) > max_price then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the maximum price for selling a character is "..max_price..".") return true
                end
 
                        setOfflinePlayerStorageValue(t[2], price, t[3])
                        setOfflinePlayerStorageValue(t[2], owner, getPlayerGUID(cid))
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" is now for sale for the price of "'..t[3]..'" gold coins.')
        elseif t[1] == "buy" then
                if not t[2] then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
                elseif not playerExists(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character doesn't exist.") return true
                elseif getPlayerAccountId(cid) == getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't buy your own character.") return true
                elseif not isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
                elseif not doPlayerRemoveMoney(cid, getOfflinePlayerStorageValue(t[2], price)) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Not enough money. This character's price is "..getOfflinePlayerStorageValue(t[2], price).." gold coins.") return true
                end
 
                if not getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)) then
                        doOfflinePlayerAddMoney(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
                        setOfflinePlayerStorageValue(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), 41792, getPlayerGUIDByName(t[2]))
                else
                        doPlayerAddMoney(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
                        doPlayerSendTextMessage(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" has been sold for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
                end
                        doTransferCharacter(t[2], getPlayerAccountId(cid))
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You bought the character "'..t[2]..'" for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
                        setOfflinePlayerStorageValue(t[2], owner, -1)
                        setOfflinePlayerStorageValue(t[2], price, -1) return true
        elseif t[1] == "remove" then
                if not t[2] then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
                elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
                elseif not isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
                end
 
                        setOfflinePlayerStorageValue(t[2], price, -1)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You removed the character "'..t[2]..'" from the Characters Retail.') return true
        elseif t[1] == "list" then
                local result = db.getResult("SELECT `name` FROM `players`")
                if result:getID() == -1 then
                        return true
                end
                local msg = "Characters for Sale:\n\n"
                while true do
                        local name = result:getDataString("name")
                        if isCharacterForSale(name) then
                        local sex = getOfflinePlayerValue(name, "sex") == 1 and "Male" or "Female"
                                msg = ""..msg.." - ".. name .." (Level: "..getOfflinePlayerValue(name, "level").." / Vocation: "..getVocationInfo(getOfflinePlayerValue(name, "vocation")).name.." / Sex: "..sex.." / Owner: "..getPlayerNameByGUID(getOfflinePlayerStorageValue(name, owner))..") [Price: "..getOfflinePlayerStorageValue(name, price).."] \n"
                        end
                        if not result:next() then
                                break
                        end
                end
                        doPlayerPopupFYI(cid, msg) return true
        elseif not t[1] or t[1] ~= "buy" or t[1] ~= "sell" or t[1] ~= "remove" or t[1] ~= "list" then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Incorrect params. You can only 'buy' or 'sell' a character, 'remove' it from the Characters Retail or see the 'list' of characters for sale.") return true
        end
return true
]]></talkaction>
 
<event type="login" name="RetailLogin" event="script"><![CDATA[[
function onLogin(cid)
domodlib('Retail')
        if getPlayerStorageValue(cid, price) > 0 then return false
        elseif getPlayerStorageValue(cid, 41792) ~= -1 then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You sold the character "..getPlayerNameByGUID(getPlayerStorageValue(cid, 41792))..". The money is in your bank account.")
                setPlayerStorageValue(cid, 41792, -1)
        end
return true
end
]]></event>
 
</mod>

Idk if it works, give it a try
 
Lua:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Characters Retail System" version="1.0" author="LuckOake" contact="none" enabled="yes">
 
<config name="Retail"><=!=[=C=D=A=T=A=[[
price = 27112
owner = 27113
level = 50 -- Min level to sell
min_price = 10000 -- Min price
max_price = 500000 -- Max price
 
function doTransferCharacter(cid, accId)
        return db.executeQuery("UPDATE `players` SET `account_id` = "..accId.." WHERE `id` = "..getPlayerGUIDByName(cid).."")
end
 
function doOfflinePlayerAddMoney(guid, money)
        return db.executeQuery("UPDATE `players` SET `balance` = `balance` + '"..money.."' WHERE `id` = '"..getPlayerGUIDByName(guid).."';")
end
 
function setOfflinePlayerStorageValue(name, key, value)
        local result = db.getResult("SELECT * FROM `player_storage` WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
        if result:getID() == -1 then
                return db.executeQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES (".. getPlayerGUIDByName(name) ..", ".. key ..", ".. value ..");")
        else
                result:free()
                return db.executeQuery("UPDATE `player_storage` SET `value` = ".. value .." WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
        end
end
 
function getOfflinePlayerStorageValue(name, key)
        local result, ret = db.getResult("SELECT `value` FROM `player_storage` WHERE `player_id` = '".. getPlayerGUIDByName(name) .."' AND `key` = ".. key ..";")
        if result:getID() == -1 then
                return nil
        end
        ret = result:getDataInt("value")
        result:free()
        return ret
end
 
function getOfflinePlayerValue(name, value)
        local result, ret = db.getResult("SELECT `"..value.."` FROM `players` WHERE `id` = "..getPlayerGUIDByName(name)..";")
        ret = result:getDataInt(value)
        result:free()
        return ret
end
 
function isCharacterForSale(name)
        if not getOfflinePlayerStorageValue(name, price) or getOfflinePlayerStorageValue(name, price) < 1 then
        return false
        else
        return true
        end
end
]=]=></config>
 
<talkaction words="!character" event="buffer"><=!=[=C=D=A=T=A=[[
domodlib('Retail')
        local t = string.explode(param, ",")
 
        if t[1] == "sell" then
                if not t[3] or not tonumber(t[3]) or t[4] or tonumber(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name and the price.") return true
                elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
                elseif isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is already for sale.") return true
                elseif getPlayerGUIDByName(t[2]) == getPlayerGUID(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot sell yourself.") return true
                elseif getPlayerByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The character must be offline to be sold.") return true
                elseif getOfflinePlayerValue(t[2], "level") < level then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your character can't be sold until it has level "..level..".") return true
                elseif tonumber(t[3]) < min_price then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the minimum price for selling a character is "..min_price..".") return true
                elseif tonumber(t[3]) > max_price then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the maximum price for selling a character is "..max_price..".") return true
                end
 
                        setOfflinePlayerStorageValue(t[2], price, t[3])
                        setOfflinePlayerStorageValue(t[2], owner, getPlayerGUID(cid))
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" is now for sale for the price of "'..t[3]..'" gold coins.')
        elseif t[1] == "buy" then
                if not t[2] then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
                elseif not playerExists(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character doesn't exist.") return true
                elseif getPlayerAccountId(cid) == getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't buy your own character.") return true
                elseif not isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
                elseif not doPlayerRemoveMoney(cid, getOfflinePlayerStorageValue(t[2], price)) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Not enough money. This character's price is "..getOfflinePlayerStorageValue(t[2], price).." gold coins.") return true
                end
 
                if not getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)) then
                        doOfflinePlayerAddMoney(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
                        setOfflinePlayerStorageValue(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), 41792, getPlayerGUIDByName(t[2]))
                else
                        doPlayerAddMoney(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
                        doPlayerSendTextMessage(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" has been sold for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
                end
                        doTransferCharacter(t[2], getPlayerAccountId(cid))
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You bought the character "'..t[2]..'" for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
                        setOfflinePlayerStorageValue(t[2], owner, -1)
                        setOfflinePlayerStorageValue(t[2], price, -1) return true
        elseif t[1] == "remove" then
                if not t[2] then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
                elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
                elseif not isCharacterForSale(t[2]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
                end
 
                        setOfflinePlayerStorageValue(t[2], price, -1)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You removed the character "'..t[2]..'" from the Characters Retail.') return true
        elseif t[1] == "list" then
                local result = db.getResult("SELECT `name` FROM `players`")
                if result:getID() == -1 then
                        return true
                end
                local msg = "Characters for Sale:\n\n"
                while true do
                        local name = result:getDataString("name")
                        if isCharacterForSale(name) then
                        local sex = getOfflinePlayerValue(name, "sex") == 1 and "Male" or "Female"
                                msg = ""..msg.." - ".. name .." (Level: "..getOfflinePlayerValue(name, "level").." / Vocation: "..getVocationInfo(getOfflinePlayerValue(name, "vocation")).name.." / Sex: "..sex.." / Owner: "..getPlayerNameByGUID(getOfflinePlayerStorageValue(name, owner))..") [Price: "..getOfflinePlayerStorageValue(name, price).."] \n"
                        end
                        if not result:next() then
                                break
                        end
                end
                        doPlayerPopupFYI(cid, msg) return true
        elseif not t[1] or t[1] ~= "buy" or t[1] ~= "sell" or t[1] ~= "remove" or t[1] ~= "list" then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Incorrect params. You can only 'buy' or 'sell' a character, 'remove' it from the Characters Retail or see the 'list' of characters for sale.") return true
        end
return true
]=]=></talkaction>
 
<event type="login" name="RetailLogin" event="script"><=!=[=C=D=A=T=A=[[
function onLogin(cid)
domodlib('Retail')
        if getPlayerStorageValue(cid, price) > 0 then return false
        elseif getPlayerStorageValue(cid, 41792) ~= -1 then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You sold the character "..getPlayerNameByGUID(getPlayerStorageValue(cid, 41792))..". The money is in your bank account.")
                setPlayerStorageValue(cid, 41792, -1)
        end
return true
end
]=]=></event>
 
</mod>

Idk if it works, give it a try
While server is opening (main post error is when i write !character list, sell/buy works fine
6tius2.png

2wgacye.png

2h6g1uu.png
 
Dont get this, Works fine for me (9.70 crying damson)

damn it! it works fine for me until i try to see what character is being sold , lol :|
using TFS ..idk whats wrong,
!character buy [WORKS]
!character sell [WORKS]
!character list [CONSOLE ERROR/NOTHING HAPPEN INGAME]

- - - Updated - - -

bumpy :[
 
Back
Top