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

TalkAction ~ Market System by www ~ Tibia 8.6!!!

Szmugross

Member
Joined
Nov 25, 2012
Messages
5
Reaction score
6
Auction system script was written by VDK but I edit it under the market system. Tested on tfs 0.4 for tibia 8.6.​

Database​

PHP:
ALTER TABLE `players` ADD `auction_balance` INT( 11 ) NOT NULL DEFAULT '0';

CREATE TABLE `auction_system` (
  `id` int(11) NOT NULL auto_increment,
  `player` int(11),
  `item_id` int(11),
  `item_name` varchar(255),
  `count` int(11),
  `cost` int(11),
  `date` int(11),
  `playername` int(11),
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


CREATE TABLE `auction_systembuy` (
  `id` int(11) NOT NULL auto_increment,
  `player` int(11),
  `item_id` int(11),
  `item_name` varchar(255),
  `count` int(11),
  `cost` int(11),
  `date` int(11),
  `playername` int(11),
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

talkactions.xml​

PHP:
<talkaction words="!offer" event="script" value="marketsystem.lua"/>

marketsystem.lua​

PHP:
local config = {
        levelRequiredToAdd = 20,
        maxOffersPerPlayer = 20,
        SendOffersOnlyInPZ = true,
        blocked_items = {2165, 2152, 2148, 2160, 2166, 8918, 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, 11138, 7735, 10518, 10521, 2471, 8982, 9778, 9777, 9776 }
        }

        -- CREATED AUCTION SYSTEM BY vDK EDITED FOR MARKET SYSTEM BY SZMUGROSS
function onSay(cid, words, param, channel)
        if(param == '') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                return true
        end
 
        local t = string.explode(param, ",")
        if(t[1] == "add") then
                if((not t[2]) or (not t[3]) or (not t[4])) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                        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) >= config.maxOffersPerPlayer) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.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(t[5] == "yes") then
				local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
				local any = 0
					doPlayerRemoveItem(cid, item, itemcount)
					db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`, `playername`) VALUES (" .. any .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ", " ..getPlayerGUID(cid).. ")")
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." x " .. t[2] .." for " .. costgp * itemcount .. " gps to offerts database.")
				else
					local itemcount7, costgp2 = math.floor(t[4]), math.floor(t[3])
					doPlayerRemoveItem(cid, item, itemcount7)
					db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`, `playername`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount7 .. ", " .. costgp2 ..", " .. os.time() .. ", " ..getPlayerGUID(cid).. ")")
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount7 .." x " .. t[2] .." for " .. costgp2 * itemcount7 .. " gps to offerts database.")
					return true
				end
        end
 
        if(t[1] == "buy") then
		
				if((not t[2]) or (not t[3])) then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                return true
				end
				
                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(getPlayerMoney(cid) < (buy:getDataInt("cost") * tonumber(t[3]))) then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                                buy:free()
                                return true
                        end
						
						if(tonumber(t[3]) < 1) then
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must write count.")
						return true
						end
						
						if(tonumber(t[3]) > buy:getDataInt("count")) then
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can buy only "..buy:getDataInt("count").." this item!")
							buy:free()
						return true
						end
 
                        if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("playername"))) 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"), tonumber(t[3])))then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a "..tonumber(t[3]).." " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), tonumber(t[3])) .. " 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(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(isItemStackable((buy:getDataString("item_id")))) then
                                doPlayerAddItem(cid, buy:getDataString("item_id"), t[3])
                        else
                                for i = 1, tonumber(t[3]) do
                                        doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
                                end
                        end
							if(tonumber(t[3]) == buy:getDataInt("count")) then
								doPlayerRemoveMoney(cid, (buy:getDataInt("cost") * buy:getDataInt("count")))
								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") * tonumber(t[3]) .. " gps!")
								db.executeQuery("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("playername") .. ";")
								buy:free()
							else
								doPlayerRemoveMoney(cid, (buy:getDataInt("cost") * tonumber(t[3])))
								db.executeQuery("UPDATE `auction_system` SET `count` = `count` - " .. t[3] .. " WHERE `id` = " .. t[2] .. ";")
								doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. t[3] .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") * tonumber(t[3]) .. " gps!")
								db.executeQuery("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getDataInt("cost") * tonumber(t[3]) .. " WHERE `id` = " .. buy:getDataInt("playername") .. ";")
								buy:free()
							end
                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("playername")) 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
 
        if(t[1] == "withdraw") then
                local balance = db.getResult("SELECT `auction_balance` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. ";")
                if(balance:getDataInt("auction_balance") < 1) then
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
                        balance:free()
                        return true
                end
 
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got " .. balance:getDataInt("auction_balance") .. " gps from auction system!")
                doPlayerAddMoney(cid, balance:getDataInt("auction_balance"))
                db.executeQuery("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. getPlayerGUID(cid) .. ";")
                balance:free()
        end
		
		if (t[1] == "buyitem") then
		                if((not t[2]) or (not t[3]) or (not t[4])) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                        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
 
 
                local check = db.getResult("SELECT `id` FROM `auction_systembuy` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
                if(check:getID() == -1) then
                elseif(check:getRows(true) >= config.maxOffersPerPlayer) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
                        return true
                end
				
                if(getPlayerMoney(cid) < (tonumber(t[4]) * tonumber(t[3]))) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                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(t[5] == "yes") then
				local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
				local any = 0
					doPlayerRemoveMoney(cid, (itemcount * costgp))
					db.executeQuery("INSERT INTO `auction_systembuy` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`, `playername`) VALUES (" .. any .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ", " ..getPlayerGUID(cid).. ")")
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp * itemcount .. " gps to offerts database.")
				else
					local itemcount7, costgp2 = math.floor(t[4]), math.floor(t[3])
					doPlayerRemoveMoney(cid, (itemcount7 * costgp2))
					db.executeQuery("INSERT INTO `auction_systembuy` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`, `playername`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount7 .. ", " .. costgp2 ..", " .. os.time() .. ", " ..getPlayerGUID(cid).. ")")
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount7 .." " .. t[2] .." for " .. costgp2 * itemcount7 .. " gps to offerts database.")
				return true
				end
        end
		
		if(t[1] == "sell") then
		
			if((not t[2]) or (not t[3])) then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                return true
				end
							
                if(not tonumber(t[2])) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
                        return true
                end			
 
                local buy = db.getResult("SELECT * FROM `auction_systembuy` WHERE `id` = " .. (tonumber(t[2])) .. ";")
                if(buy:getID() ~= -1) then
				
						if(not isItemStackable((buy:getDataString("item_id")))) and (tonumber(t[3]) > 1 ) then
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can sell max 1 per once time.")
						return true
						end			
						
						if(tonumber(t[3]) < 1 or tonumber(t[3]) > 100 ) then
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must write count 1-100.")
						return true
						end
						
						
						if(tonumber(t[3]) > buy:getDataInt("count")) then
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can sell only "..buy:getDataInt("count").." this item!")
							buy:free()
						return true
						end
 
                        if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("playername"))) then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't sell item to your auction.")
                                buy:free()
                                return true
                        end
						local item = buy:getDataString("item_id")
						
						if(getPlayerItemCount(cid, item) < (tonumber(t[3]))) then
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
                        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
						
						if(tonumber(t[3]) > buy:getDataInt("count")) then
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can sell only "..buy:getDataInt("count").." this item!")
							buy:free()
						return true
						end
 
						local idplayer = buy:getDataString("playername")
                        if(isItemStackable((buy:getDataString("item_id")))) then
							local ls = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..idplayer.." ORDER BY `sid` DESC LIMIT 1")
							db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ("..idplayer..", "..(ls:getDataInt("sid")+1)..", 102, "..item..", "..tonumber(t[3])..", '"..(tonumber(t[3]) > 1 and string.format("%x",tonumber(t[3])) or '').."')")
                        else
								local ls2 = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..idplayer.." ORDER BY `sid` DESC LIMIT 1")
                                for i = 1, tonumber(t[3]) do
                                        db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ("..idplayer..", "..(ls2:getDataInt("sid")+1)..", 102, "..item..", "..tonumber(t[3])..", '"..(tonumber(t[3]) > 1 and string.format("%x", tonumber(t[3])) or '').."')")
                                end
                        end
							if(tonumber(t[3]) == buy:getDataInt("count")) then
								doPlayerRemoveItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
								db.executeQuery("DELETE FROM `auction_systembuy` WHERE `id` = " .. t[2] .. ";")
								doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You sell " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") * buy:getDataInt("count") .. " gps!")
								db.executeQuery("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. getPlayerGUID(cid) ..";")
								buy:free()
							else
								doPlayerRemoveItem(cid, buy:getDataString("item_id"), tonumber(t[3]))
								db.executeQuery("UPDATE `auction_systembuy` SET `count` = `count` - " .. t[3] .. " WHERE `id` = " .. t[2] .. ";")
								doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You sell " .. t[3] .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") * tonumber(t[3]) .. " gps!")
								db.executeQuery("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getDataInt("cost") * tonumber(t[3]) .. " WHERE `id` = " .. getPlayerGUID(cid).. ";")
								buy:free()
							end
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
                end
        end
		
        if(t[1] == "canceladd") 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_systembuy` WHERE `id` = " .. (tonumber(t[2])) .. ";")        
                if(delete:getID() ~= -1) then
                        if(getPlayerGUID(cid) == delete:getDataInt("playername")) then
                                db.executeQuery("DELETE FROM `auction_systembuy` WHERE `id` = " .. t[2] .. ";")
                                if(isItemStackable(delete:getDataString("item_id"))) then
                                        db.executeQuery("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. delete:getDataInt("cost") * delete:getDataInt("count") .. " WHERE `id` = " .. delete:getDataInt("playername") .. ";")
                                else
                                        for i = 1, delete:getDataInt("count") do
                                                db.executeQuery("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. delete:getDataInt("cost") * delete:getDataInt("count") .. " WHERE `id` = " .. delete:getDataInt("playername") .. ";")
                                        end
                                end
								local itemids = delete:getDataInt("item_id")
                                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your offert "..delete:getDataInt("count").. "x " ..getItemNameById(itemids).. " 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

WWW(POLISH)​

PHP:
<?PHP
$page = $_REQUEST['page'];
$offset = $page * 25;
//$auctions = $SQL->query('SELECT `auction_system`.`player`, `auction_system`.`id`, `auction_system`.`item_name`, `auction_system`.`item_id`, `auction_system`.`count`, `auction_system`.`cost`, `auction_system`.`date`, `players`.`name` FROM `auction_system`, `players` WHERE `players`.`id` = `auction_system`.`player` ORDER BY `auction_system`.`id` DESC')->fetchAll();
$auctionsbuy = $SQL->query('SELECT `sab`.`playername` AS `player`, `sab`.`player` AS `any`, `p`.`name` AS `name`, `sab`.`id` AS `id`, `sab`.`item_name` AS `item_name`, `sab`.`item_id` AS `item_id`, `sab`.`count` AS `count`, `sab`.`cost` AS `cost`, `sab`.`date` AS `date`
FROM `auction_systembuy` sab
	LEFT JOIN `players` p ON `p`.`id` = `sab`.`playername`
	ORDER BY `sab`.`id` ASC
	LIMIT 25 OFFSET '.$offset)->fetchAll();
$auctions = $SQL->query('SELECT `sa`.`player` AS `player`, `p`.`name` AS `name`, `sa`.`id` AS `id`, `sa`.`item_name` AS `item_name`, `sa`.`item_id` AS `item_id`, `sa`.`count` AS `count`, `sa`.`cost` AS `cost`, `sa`.`date` AS `date`
FROM `auction_system` sa
	LEFT JOIN `players` p ON `p`.`id` = `sa`.`player`
	ORDER BY `sa`.`id` ASC
	LIMIT 25 OFFSET '.$offset)->fetchAll();
$players = 0;
$main_content .= $main_content .= '
						<script type="text/javascript">function pokazdiv(el)
						{
							for(var i=1; i<=3; i++){
								old = document.getElementById(el).style.olddisplay
								if(el == i){
									document.getElementById(el).style.display = "block";}
								else{
									document.getElementById(i).style.display = "none";}
							}
						}</script>';

	$main_content .= '<div id="1"><button onclick="$(\'#desc1\').toggle();" >Pokaż/Uktyj Opis</button><TABLE id="desc1" BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><b>Instrukcja<b></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD><center><h2>Komendy</h2><b>!offer add, nazwaRzeczy, Cena, ilość, yes jeżeli anonimowy</b><br /><small>example: !offer add, plate armor, 500, 1, yes or empty</small><br /><br /><B>!offer buy, id_Oferty, ilośc</b><br /><small>example: !offer buy, 1943, 1</small><br /><br /><b>!offer remove, id_Oferty</b><br /><small>example: !offer remove, 1943</small><br /><br /><b>!offer withdraw</b><br /><small>Użyj tej opcji, aby wybrać pieniądze za sprzedane rzeczy.</small></center></TR></TD></TABLE><br />';
    if(empty($auctions))
    {
        $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><b>Oferty</b></td></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD>Aktualnie nie ma żadnej aktywnej oferty.</TD></TR></TABLE>';
	$main_content .= '<TABLE id="gradient-styles" BORDER=0 CELLSPACING=1 CELLPADDING=4 width=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD onclick="pokazdiv(\'1\');" COLSPAN=1 CLASS=white><B>Oferty Sprzedaży</B></TD><TD onclick="pokazdiv(\'2\');" COLSPAN=1 CLASS=white><B>Oferty Kupna</B></TD></TR></table><br><br>';

		}
    else
    {
    foreach($auctions as $auction) {
        $players++;
            if(is_int($players / 2))
                $bgcolor = $config['site']['lightborder'];
            else
                $bgcolor = $config['site']['darkborder'];
        $cost = round($auction['cost']/1000, 2);

		$content .= '<TR BGCOLOR='.$bgcolor.'><TD><center>'.$auction['id'].'</center></TD><TD><center><img src="./images/items/'.$auction['item_id'].'.gif"/></center></TD><TD><center>'.$auction['item_name'].'</center></TD><TD><center>';
		if ($auction['player'] != '0')
			$content .= '<a href="?subtopic=characters&name='.urlencode($auction['name']).'">'.$auction['name'].'</a>';
		else
			$content .= '<b>Anonimowy</b>';
		$content .= '</center></TD><TD><center>'.$auction['count'].'</center></TD><TD><center>'.$cost.'k<br /><small>'.$auction['cost'].'gp</small></center></TD><TD><center>!offer buy, '.$auction['id'].'</center></TR>';
    }
    $main_content .= '<TABLE id="gradient-styles" BORDER=0 CELLSPACING=1 CELLPADDING=4 width=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD onclick="pokazdiv(\'1\');" COLSPAN=1 CLASS=white><B>Oferty Sprzedaży</B></TD><TD onclick="pokazdiv(\'2\');" COLSPAN=1 CLASS=white><B>Oferty Kupna</B></TD></TR></table><br><br>';

    $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><b><center>ID</center></b></TD><TD class="white"><b><center>#</center></b></TD><TD class="white"><b><center>Nazwa Rzeczy</center></b></TD><TD class="white"><b><center>Gracz</center></b></TD><TD class="white"><b><center>Ilość</center></b></TD><TD class="white"><b><center>Cena</center></b></td><TD class="white"><b><center>Kup</center></b></td></TR>'.$content.'</TABLE>';
	$main_content .= '<br><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%><tr>';
	if($page >= 1)
		$main_content .= '<TD WIDTH=50% ALIGN=left VALIGN=bottom><A HREF="?subtopic='.$subtopic.'&page='.($page - 1).'" CLASS="size_xxs"><< Poprzednia Strona</A></TD>';
	$main_content .= '<TD WIDTH=50% ALIGN=right VALIGN=bottom><A HREF="?subtopic='.$subtopic.'&page='.($page + 1).'" CLASS="size_xxs">Nastepna Strona >> </A></TD></TR>';
	$main_content .= '</TABLE>';
		$main_content .= '<TABLE id="gradient-styles" BORDER=0 CELLSPACING=1 CELLPADDING=4 width=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD onclick="pokazdiv(\'1\');" COLSPAN=1 CLASS=white><B>Oferty Sprzedaży</B></TD><TD onclick="pokazdiv(\'2\');" COLSPAN=1 CLASS=white><B>Oferty Kupna</B></TD></TR></table><br><br>';
	$main_content .= '</div>';
	
	$main_content .= '<div id="2" style="display:none"><button onclick="$(\'#desc2\').toggle();" >Pokaż/Uktyj Opis</button><TABLE id="desc2" BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><b>Instrukcja<b></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD><center><h2>Komendy</h2><b>!offer buyitem, nazwaRzeczy, Cena, ilość, yes jeżeli anonimowy</b><br /><small>example: !offer add, plate armor, 500, 1, yes or empty</small><br /><br /><B>!offer sell, id_Oferty, ilośc</b><br /><small>example: !offer sell, 1943, 1</small><br /><br /><b>!offer canceladd, id_Oferty</b><br /><small>example: !offer canceladd, 1943</small><br /><br /><b>!offer withdraw</b><br /><small>Użyj tej opcji, aby wybrać pieniądze za sprzedane rzeczy.</small></center></TR></TD></TABLE><br />';
    if(empty($auctionsbuy))
    {
			$main_content .= '<TABLE id="gradient-styles" BORDER=0 CELLSPACING=1 CELLPADDING=4 width=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD onclick="pokazdiv(\'1\');" COLSPAN=1 CLASS=white><B>Oferty Sprzedaży</B></TD><TD onclick="pokazdiv(\'2\');" COLSPAN=1 CLASS=white><B>Oferty Kupna</B></TD></TR></table><br><br>';
        $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><b>Oferty</b></td></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD>Aktualnie nie ma żadnej aktywnej oferty.</TD></TR></TABLE>';
    }
    else
    {
    foreach($auctionsbuy as $auctionb) {
        $playersb++;
            if(is_int($players / 2))
                $bgcolor = $config['site']['lightborder'];
            else
                $bgcolor = $config['site']['darkborder'];
        $costb = round($auctionb['cost']/1000, 2);

		$contentb .= '<TR BGCOLOR='.$bgcolor.'><TD><center>'.$auctionb['id'].'</center></TD><TD><center><img src="./images/items/'.$auctionb['item_id'].'.gif"/></center></TD><TD><center>'.$auctionb['item_name'].'</center></TD><TD><center>';
		if ($auctionb['any'] != '0')
			$contentb .= '<a href="?subtopic=characters&name='.urlencode($auctionb['name']).'">'.$auctionb['name'].'</a>';
		else
			$contentb .= '<b>Anonimowy</b>';
		$contentb .= '</center></TD><TD><center>'.$auctionb['count'].'</center></TD><TD><center>'.$costb.'k<br /><small>'.$auctionb['cost'].'gp</small></center></TD><TD><center>!offer sell, '.$auctionb['id'].'</center></TR>';
    }
    	$main_content .= '<TABLE id="gradient-styles" BORDER=0 CELLSPACING=1 CELLPADDING=4 width=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD onclick="pokazdiv(\'1\');" COLSPAN=1 CLASS=white><B>Oferty Sprzedaży</B></TD><TD onclick="pokazdiv(\'2\');" COLSPAN=1 CLASS=white><B>Oferty Kupna</B></TD></TR></table><br><br>';

    $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><b><center>ID</center></b></TD><TD class="white"><b><center>#</center></b></TD><TD class="white"><b><center>Nazwa Rzeczy</center></b></TD><TD class="white"><b><center>Gracz</center></b></TD><TD class="white"><b><center>Ilość</center></b></TD><TD class="white"><b><center>Cena</center></b></td><TD class="white"><b><center>Sprzedaj</center></b></td></TR>'.$contentb.'</TABLE>';
	$main_content .= '<br><TABle BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%><tr>';
	if($page >= 1)
		$main_content .= '<TD WIDTH=50% ALIGN=left VALIGN=bottom><A HREF="?subtopic='.$subtopic.'&page='.($page - 1).'" CLASS="size_xxs"><< Poprzednia Strona</A></TD>';
	$main_content .= '<TD WIDTH=50% ALIGN=right VALIGN=bottom><A HREF="?subtopic='.$subtopic.'&page='.($page + 1).'" CLASS="size_xxs">Nastepna Strona >> </A></TD></TR>';
	$main_content .= '</TABLE>';
		$main_content .= '<TABLE id="gradient-styles" BORDER=0 CELLSPACING=1 CELLPADDING=4 width=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD onclick="pokazdiv(\'1\');" COLSPAN=1 CLASS=white><B>Oferty Sprzedaży</B></TD><TD onclick="pokazdiv(\'2\');" COLSPAN=1 CLASS=white><B>Oferty Kupna</B></TD></TR></table><br><br>';
	$main_content .= '</div>';
	}

	}
    ?>

Commands:​

!offer buy, itemName, Price, Count, yes or empty -- !offer buy, Dragon Scale Mail, 6000, 1, yes [YES == anonymous if you do not want to be anonymous put anything] (Exposing item's for sale)
!offer buy, id offer, count -- !offer buy, 5, 1 (To buy x number of item's deal)
!offer remove, id offer -- !offer remove, 5 (Removing offers)
!offer buyitem, itemName, Price, Count, yes or empty -- !offer buyitem, Dragon Scale Mail, 7000, 3 , yes [YES == anonymous if you do not want to be anonymous put anything]
!offer sell, id offer, count -- !offer sell, 7, 3 (Selling x amount of the item's purchase offer)
!offer canceladd, id offer -- !offer canceladd, 10 (Removal of an offer to buy item)
!offer withdraw (Use this option to select the money for sold items.)​
 
Last edited:
I'm only ask,works on TFS 0.6.3 pl?

Ok,tested working!
 
Last edited:
I Can't execute the query i get ""near "auto_increment": syntax error""
 
query not miss?
because the script marketsystem.lua
has a line asking:
Lua:
db.executeQuery("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("playername") .. ";")
and not have to query the table to change players!

would be this:
PHP:
ALTER TABLE `players` ADD `auction_balance` INT(15) NOT NULL
 
the one for sqlite
Code:
ALTER TABLE `players` ADD `auction_balance` INT( 11 ) NOT NULL DEFAULT '0';

CREATE TABLE `auction_system` (
  `id` int(11) NOT NULL,
  `player` int(11),
  `item_id` int(11),
  `item_name` varchar(255),
  `count` int(11),
  `cost` int(11),
  `date` int(11),
  `playername` int(11),
  PRIMARY KEY  (`id`)
)
Code:
CREATE TABLE `auction_systembuy` (
  `id` int(11) NOT NULL,
  `player` int(11),
  `item_id` int(11),
  `item_name` varchar(255),
  `count` int(11),
  `cost` int(11),
  `date` int(11),
  `playername` int(11),
  PRIMARY KEY  (`id`)
)
 
I have this problem when i add an item...
03:25 !offer add, golden legs, 20000, 1, yes
03:25 Item wich such name does not exists.

No errores in console.
 
Back
Top