• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Get house with itemid depending on owner

bury

Active Member
Joined
Jul 27, 2008
Messages
421
Solutions
7
Reaction score
25
Hey!

I want a simple script thats allows a player to get a house with an item but only if the owner of the house is called X.

For example:

With the item 9999 and the owner called "Administrator" you become the owner of the house.

Also with the item 8888 and the owner called "Manager" you become the owner of the house.

Item 7777 and the owner called "assistant" you become the owner of the house.

It could be an action, or with 3 different talkaction like !buyone; !buytwo; !buythree

Thanks for your help!
 
What happens if for example the manager has more than one house?

The manager will have much houses since he will be a game master, community manager or god. These will be a special houses I don't want people to buy them with money (using the normal command !buyhouse). Thats why I need this system.
 
I think the best way is standing in front of the house.

@Karain As Jestem pro says, standing on front yeah. I explained wrong, I meaned an action clicking in door, or a talkaction in front of door.

The door is with an owner yet to avoid people buy it with !buyhouse.

Thanks!
 
I could not help you because you are using 0.4, also seems that you are trolling.

What? It's a request... Why do you think I'm trolling? I didn't remember the rule of double posting, I assume my error.

I need something like

Code:
If getHouseOwner(houseId) == Administrator and itemid ==  xxxx then [allow player to buy house]
else
if........

Something like that, I know scripting if I find some similar scripts, but I think there is nothing similar to this so thats why I'm doing a request....

bumpp
 
Last edited by a moderator:
This is the function you need to edit; global860/talkaction.cpp at 571183a2858e638d49778cca914c8126bd6f17ce · otservme/global860 · GitHub
If you had been using 1.2 / 1.3 you could have just updated the Lua script.

global860/talkaction.cpp at 571183a2858e638d49778cca914c8126bd6f17ce · otservme/global860 · GitHub
C++:
uint32_t owner = house->getOwner();

Player* player = g_game.getPlayerByGuid(owner);
if (player && player->getName() == 'House Owner') {
    // can buy the house

    return true;
}
// continue the code, since it has no owner and is a "normal" house

If you wanna use an item I guess these functions should work;
LUA:
setHouseOwner(houseId, owner[, clean = true])
getHouseInfo(houseId[, full = true]).owner

global860/luascript.cpp at 571183a2858e638d49778cca914c8126bd6f17ce · otservme/global860 · GitHub
 
This is the function you need to edit; global860/talkaction.cpp at 571183a2858e638d49778cca914c8126bd6f17ce · otservme/global860 · GitHub
If you had been using 1.2 / 1.3 you could have just updated the Lua script.

global860/talkaction.cpp at 571183a2858e638d49778cca914c8126bd6f17ce · otservme/global860 · GitHub
C++:
uint32_t owner = house->getOwner();

Player* player = g_game.getPlayerByGuid(owner);
if (player && player->getName() == 'House Owner') {
    // can buy the house

    return true;
}
// continue the code, since it has no owner and is a "normal" house

If you wanna use an item I guess these functions should work;
LUA:
setHouseOwner(houseId, owner[, clean = true])
getHouseInfo(houseId[, full = true]).owner

global860/luascript.cpp at 571183a2858e638d49778cca914c8126bd6f17ce · otservme/global860 · GitHub

Thanks! But is not possible to add it without changing the sources? Just with a lua script?

If owner is X and you have Y item then, you can !buycastle and item dissapear. I think it could be without changing anything of the binaries?
 
Code:
local tile = Tile(Position(x, y , z))
if tile then
    local house = tile and tile:getHouse()
    if house and house:getOwnerGuid() == 999 then -- << house owner guid, find it in your database
        if player:removeItem(123, 1) then
            house:setOwnerGuid(player:getGuid())
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have bought this house.")
        end
    end
end
 
Code:
local tile = Tile(Position(x, y , z))
if tile then
    local house = tile and tile:getHouse()
    if house and house:getOwnerGuid() == 999 then -- << house owner guid, find it in your database
        if player:removeItem(123, 1) then
            house:setOwnerGuid(player:getGuid())
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have bought this house.")
        end
    end
end
The Forgotten Server Version: 0.4.3777.19

btw, the item has to dissapear after using the talkaction
 
Thanks! But is not possible to add it without changing the sources? Just with a lua script?

If owner is X and you have Y item then, you can !buycastle and item dissapear. I think it could be without changing anything of the binaries?

No you need 1.2 or maybe 1.3 to be able to do it via Lua.
If you wanna do it via Lua but still use 0.4 I guess you can move the house functions to Lua.
 
Code:
local tile = Tile(Position(x, y , z))
if tile then
    local house = tile and tile:getHouse()
    if house and house:getOwnerGuid() == 999 then -- << house owner guid, find it in your database
        if player:removeItem(123, 1) then
            house:setOwnerGuid(player:getGuid())
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have bought this house.")
        end
    end
end

This script is an action? Will it work?
 
It won't work with 0.4 (or any 0.x server)
That code requires 1.1 / 1.2? Might work on 1.0

Thanks you! I've left the manual system to give castles. I want to upgrade it but idk how. The system that uses everybody is useless in my server because I've 3 kind of castles and they are in the same city (castleland) ^^
 
Back
Top