zbizu
Legendary OT User
Offline house market.
Lets you trade your items without losing their attributes.
Do not post that script on other forums without my permission
YOU NEED NEWEST TFS OR PLAYERS MAY STEAL YOUR MARKET
Screenshots:
To create your own market:
1. place a basket on house edge
2. put container with items you want to sell
3. put an item which handles textfields inside a basket and type something like that:
To do: limit of items player wants to buy, "child" containers support
Query to hold inbox items queue:
Script:
/data/actions/scripts/house_shop.lua: http://wklej.to/N3ntS
actions.xml:
/data/events/events.xml(just set enabled to 1)
to this:
/data/events/events.xml (just enable it)
/data/events/scripts/player.lua:
add to /data/creaturescripts/scripts/login.lua(above return true):
Lets you trade your items without losing their attributes.
Do not post that script on other forums without my permission
YOU NEED NEWEST TFS OR PLAYERS MAY STEAL YOUR MARKET
Screenshots:
To create your own market:
1. place a basket on house edge
2. put container with items you want to sell
3. put an item which handles textfields inside a basket and type something like that:
*Sell means item you SELL, Buy means item you want to BUYSell[demon shield, 40000; mace, 30; skull staff, 6000]
Buy[stuffed dragon, 5000; mace, 15;]
To do: limit of items player wants to buy, "child" containers support
Query to hold inbox items queue:
Code:
CREATE TABLE IF NOT EXISTS `onlogin_sendtoinbox` (
`player_id` int(11) NOT NULL DEFAULT '0',
`itemtype` smallint(6) NOT NULL DEFAULT '0',
`count` smallint(5) NOT NULL DEFAULT '0',
`price` bigint(20) unsigned NOT NULL DEFAULT '0',
`actionid` bigint(20) unsigned NOT NULL DEFAULT '0',
`description` varchar(255) NOT NULL DEFAULT '',
`text` varchar(1023) NOT NULL DEFAULT '',
`writer_guid` int(11) NOT NULL DEFAULT 0,
`written_at` bigint(20) NOT NULL,
FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB
Script:
/data/actions/scripts/house_shop.lua: http://wklej.to/N3ntS
actions.xml:
<action itemid="1989" script="house_shop.lua"/>
/data/events/events.xml(just set enabled to 1)
player.lua replace this:<event class="Player" method="onMoveItem" enabled="1"/>
Code:
function Player:OnMoveItem(item, count, fromPosition, toPosition)
return true
end
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
function isHousetile(position)
local t = Tile(position)
if t == nil then
return false
end
return t:hasFlag(TILESTATE_HOUSE)
end
if isHousetile(item:getPosition()) then -- yup, it's a housetile
if self:getAccountType() == ACCOUNT_TYPE_GOD and self:getGroup():getAccess() then -- is server admin
return true
end
if Tile(item:getPosition()):getHouse():getOwnerGuid() == self:getGuid() then -- is house owner
return true
end
if isHousetile(self:getPosition()) then -- is inside a house
return true
end
-- random player
self:sendCancelMessage("Sorry, not possible.")
return false
end
return true
end
/data/events/events.xml (just enable it)
<event class="Player" method="onTradeRequest" enabled="1"/>
/data/events/scripts/player.lua:
Code:
function Player:onTradeRequest(target, item)
if isHousetile(item:getPosition()) then -- is this a house
if self:getAccountType() == ACCOUNT_TYPE_GOD and self:getGroup():getAccess() then -- is server admin
return true
end
if Tile(item:getPosition()):getHouse():getOwnerGuid() == self:getGuid() then -- is house owner
return true
end
if isHousetile(self:getPosition()) then -- is inside a house
return true
end
-- random player
self:sendCancelMessage("This item doesn't belong to you.")
return false
end
return true
end
add to /data/creaturescripts/scripts/login.lua(above return true):
Code:
home_market_spend = 0
home_market_items = {}
home_market_items_msg = ""
for i = 1, 30 do
-- don't let them send milions of trash and then get it at once!
local a = db.storeQuery("SELECT * FROM `onlogin_sendtoinbox` WHERE `player_id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
if a then
local it_id = Player(cid):getInbox():addItem(result.getDataInt(a, "itemtype"), result.getDataInt(a, "count"), true, 1)
it_id:setAttribute(1, result.getDataInt(a, "actionid"))
it_id:setAttribute(4, result.getDataString(a, "description"))
it_id:setAttribute(8, result.getDataString(a, "text"))
it_id:setAttribute(32, getPlayerNameByGUID(result.getDataInt(a, "writer_guid")))
it_id:setAttribute(16, getPlayerNameByGUID(result.getDataInt(a, "written_at")))
home_market_spend = home_market_spend + result.getDataInt(a, "price")
table.insert(home_market_items, {getItemName(result.getDataInt(a, "itemtype")), result.getDataInt(a, "count")})
db.query("DELETE FROM `onlogin_sendtoinbox` WHERE `player_id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
else
break
end
end
if #home_market_items > 0 then
for i = 1, #home_market_items do
home_market_items_msg = home_market_items_msg .. i_ar(home_market_items[i][1], home_market_items[i][2]) .. " " .. i_n(home_market_items[i][1], home_market_items[i][2])
if #home_market_items ~= 1 and i ~= #home_market_items then
home_market_items_msg = home_market_items_msg .. ", "
end
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Store]: During your absence, players sold you " .. #home_market_items .. " item(s) for " .. home_market_spend .. " gold coins in total.")
if #home_market_items < 31 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Store]: Items you bought: " .. home_market_items_msg)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Store]: Check your inbox to see items you received.")
end
end
Last edited: