What's new
  • logo_cipsoft
    Latest servers:
    New servers will open on: 19th Feb 2025:
    Noctalia (Open PvP) Ignitera (Open PvP) us_logo Xybra (Open PvP)

Talkactions ~ Market System przez www ~ Tibia 8.6!!!

Status
Not open for further replies.

boytano1

Active User
Joined
Jun 15, 2009
Messages
70
Reaction score
8
Skrypt Auction system zosta? napisany przez vDk lecz ja go edytowa?em pod market system. Testowany na tfs 0.4 pod tibie 8.6.​

Baza Danych​

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​

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>';
	}

	}
    ?>

Komendy:​

!offer buy, nazwaItemu, Cena, Ilo?c, yes lub puste -- !offer buy, Dragon Scale Mail, 6000, 1, yes [YES == anonimowy je?eli nie chcesz byc anonimowy nie wpisuj nic] (Wystawienie itemu na sprzeda?)
!offer buy, id oferty, ilo?c -- !offer buy, 5, 1 (Kupienie x ilo?ci itemu z oferty)
!offer remove, id oferty -- !offer remove, 5 (Usuni?cie oferty sprzeda?y)
!offer buyitem, nazwaItemu, Cena, Ilo?c, yes lub puste -- !offer buyitem, Dragon Scale Mail, 7000, 3 , yes [YES == anonimowy je?eli nie chcesz byc anonimowy nie wpisuj nic] (Wystawienie oferty kupna danego itemu)
!offer sell, id oferty, ilo?c -- !offer sell, 7, 3 (Sprzedanie x ilo?ci itemu z oferty kupna)
!offer canceladd, id oferty, -- !offer canceladd, 10 (Usuni?cie oferty kupna itemu)
!offer withdraw (U?yj tej opcji, aby wybra? pieni?dze za sprzedane rzeczy.)​
 

Dubler

Lua Factory =)
Joined
Apr 8, 2009
Messages
1,874
Reaction score
111
Odp: ~ Market System przez www ~ Tibia 8.6!!!

dobry skrypt. Za nied?ugo pewnie co drugi ots b?dzie mia? "UNIKALNY SKRYPT MARKETU NIE SPOTYKANY NA ?ADNYM INNYM OTS!" ehh... Polacy... w ka?dym razie GJ
 

DJ Mrozu

Senior User
Joined
May 19, 2009
Messages
1,003
Reaction score
19
Odp: ~ Market System przez www ~ Tibia 8.6!!!

czekaj bo nie ogarniam ;p
cena jest w czym punktach premium?
 

Kukurydza

OT Expert
Joined
Jun 30, 2010
Messages
358
Reaction score
36
Odp: ~ Market System przez www ~ Tibia 8.6!!!

dobry skrypt. Za nied?ugo pewnie co drugi ots b?dzie mia? "UNIKALNY SKRYPT MARKETU NIE SPOTYKANY NA ?ADNYM INNYM OTS!" ehh... Polacy... w ka?dym razie GJ

Mo?e i tak b?d? pisa?, ?e "unikalny". Jednak chyba po to go udost?pnia, ?eby z niego korzysta?... Polacy? A co? Ty nie jeste? Polakiem?
 

SanninStory

https://www.twitch.tv/sdrn
Joined
Oct 13, 2012
Messages
1,778
Reaction score
116
Odp: ~ Market System przez www ~ Tibia 8.6!!!

Bardzo fajny dodatek.
Sprawdza? kto? czy jest kompatybilny z 8.54?

Pozdrawiam.
 

Rikodek

Advanced User
Joined
Aug 21, 2012
Messages
300
Reaction score
14
Odp: ~ Market System przez www ~ Tibia 8.6!!!

Bardzo fajny dodatek.
Sprawdza? kto? czy jest kompatybilny z 8.54?

Pozdrawiam.
tak, dziala ;P na LoS jest dokladnie ten sam system (chyba ten skrypt jest zbugowany i mozna klonowac itemy, wiec poszukaj podobny bez buga chyba ze ten go nie ma)
 

boytano1

Active User
Joined
Jun 15, 2009
Messages
70
Reaction score
8
Odp: ~ Market System przez www ~ Tibia 8.6!!!

dobry skrypt. Za nied?ugo pewnie co drugi ots b?dzie mia? "UNIKALNY SKRYPT MARKETU NIE SPOTYKANY NA ?ADNYM INNYM OTS!" ehh... Polacy... w ka?dym razie GJ

Rozumiem ci? lecz pisa?em ten skrypt dla swojego ots ale nie mam czasu na stawianie teraz niczego wi?c udost?pni?em ten skrypt bo szkoda aby si? marnowa? a naprawd? jest przydatny na RL mapy i umili gr? wielu graczom.

@@ Rikodek

Skrypt testowa?em kilkana?cie razy pod wzgl?dem klonowania itd... wi?c moim zdaniem nie mo?na nic klonowac(item?w, kasy). A skrypt nie jest taki sam jak na LoS bo tam jest auction system a tutaj makret, a to naprawd? wielka r??nica.
 
Last edited:

Mag Egzorcysta

Advanced User
Joined
Apr 17, 2010
Messages
248
Reaction score
39
Odp: ~ Market System przez www ~ Tibia 8.6!!!

Popraw

PHP:
$page = $_REQUEST['page'];

na

PHP:
$page = (int) $_REQUEST['page'];
 

arthurluna

New User
Joined
Jan 25, 2013
Messages
6
Reaction score
0
Odp: ~ Market System przez www ~ Tibia 8.6!!!

jak zainstalowa? w nowoczesnym wg?
 
Status
Not open for further replies.
Top