mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-05-01 18:19:20 +02:00
introduce talkaction to query house tile items by id
This commit is contained in:
parent
693a9120ee
commit
a53e79d628
@ -25,3 +25,25 @@ end
|
|||||||
function Container.isTile(self)
|
function Container.isTile(self)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Container.getItemsById(self, itemId)
|
||||||
|
local list = {}
|
||||||
|
for index = 0, (self:getSize() - 1) do
|
||||||
|
local item = self:getItem(index)
|
||||||
|
if item then
|
||||||
|
if item:isContainer() then
|
||||||
|
local rlist = item:getItemsById(itemId)
|
||||||
|
if type(rlist) == 'table' then
|
||||||
|
for _, v in pairs(rlist) do
|
||||||
|
table.insert(list, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if item:getId() == itemId then
|
||||||
|
table.insert(list, item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return list
|
||||||
|
end
|
34
data/talkactions/scripts/query_houses.lua
Normal file
34
data/talkactions/scripts/query_houses.lua
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
function onSay(player, words, param)
|
||||||
|
if not player:getGroup():getAccess() then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if player:getAccountType() < ACCOUNT_TYPE_GOD then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local searchItemId = tonumber(param)
|
||||||
|
|
||||||
|
for _, house in pairs(Game.getHouses()) do
|
||||||
|
for _, tile in pairs(house:getTiles()) do
|
||||||
|
for _, item in pairs(tile:getItems()) do
|
||||||
|
if item ~= nil then
|
||||||
|
local isFound = false
|
||||||
|
if item:isContainer() then
|
||||||
|
local items = item:getItemsById(searchItemId)
|
||||||
|
isFound = #items > 0
|
||||||
|
else
|
||||||
|
isFound = item:getId() == searchItemId
|
||||||
|
end
|
||||||
|
|
||||||
|
if isFound then
|
||||||
|
local position = item:getPosition()
|
||||||
|
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Your current position is: " .. position.x .. ", " .. position.y .. ", " .. position.z .. ".")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
@ -41,6 +41,7 @@
|
|||||||
<talkaction words="/globalboost" separator=" " script="global_rate_boost.lua" />
|
<talkaction words="/globalboost" separator=" " script="global_rate_boost.lua" />
|
||||||
<talkaction words="/loottest" script="loot_test.lua" />
|
<talkaction words="/loottest" script="loot_test.lua" />
|
||||||
<talkaction words="/event" script="serpentine_tower_event.lua" />
|
<talkaction words="/event" script="serpentine_tower_event.lua" />
|
||||||
|
<talkaction words="/queryhouses" separator=" " script="query_houses.lua" />
|
||||||
|
|
||||||
<!-- player talkactions -->
|
<!-- player talkactions -->
|
||||||
<talkaction words="!buypremium" script="buyprem.lua"/>
|
<talkaction words="!buypremium" script="buyprem.lua"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user