• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[Player event][TFS 1.0] Prevent picking house items on edges

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,323
Solutions
26
Reaction score
2,695
Location
Poland
Got inspired by viewing one server based on 0.4 so I decided to write something like this for my ot.
What does it do?

If player is outside the house and is neither god nor its owner, he can't move item placed on edge of house(in door spaces or shop tables). This way you may show off containers (players can still use those items, they just can't move them).

If you have my house market system installed already you already use that.

Do not post that script on other forums without my permission

events.xml(just set enabled to 1)
<event class="Player" method="onMoveItem" enabled="1"/>

player.lua replace this:
Code:
function Player:OnMoveItem(item, count, fromPosition, toPosition)
   return true
end
to this:
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

Prevent stealing using trade with... (newest tfs only):
creaturescripts.xml:
Code:
<event type="traderequest" name="HouseTrade" script="house_tr.lua"/>
house_tr.lua:
Code:
function onTradeRequest(cid,target,item)
local self = Player(cid)
if isHousetile(Item(item.uid):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(item.uid):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

login.lua:
Code:
player:registerEvent("HouseTrade")
 
Last edited:
By this, I could basicly make an open backyard/frontyard or shop (like you mentioned) and put items exactly on the edge of at the house line (where I still own it) and people can't move the items even if they stand exactly beside it?

If thats the case and I understood it right... Awesome.
More event scripts! :) Haven't got the hold of event types yet, nice to get some examples.

Kind Regards,
Eldin.
 
Yes, only god and house owner may take those items from edge, without being inside a house.
If you stand on house tile, you are free to do with items whatever you want.
However, players may still add something to container or use items(eat food, drink potions, etc.).
Nice idea with this shop, though. I'll write shop system with trade window for this later.
 
Last edited:
What happends if you get pked you can take items from the house by range?
house owner only
I can rewrite this script if you tell me what function returns table of invited players.
 
Code:
house:getAccessList(listId)

Where listId can be:
  • GUEST_LIST (0x100)
  • SUBOWNER_LIST (0x101)
  • DOOR_ID

But it returns a string that you'll have to parse.
 
Back
Top