• 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!

donation castles.

alectrona94

Member
Joined
Aug 10, 2019
Messages
143
Reaction score
7
Location
Egypt
so actually i have 2 issue's, the first one is the donation castles, ive got scripts with a doll that makes you buy the castle if u stood in front of the door and then the doll disappears, what im facing here is that the castle can be bough with !buyhouse command and the doll can buy any house in town also, so thats the first query.
the second one is that whenever i press look on a player from my god account it seems fine, but when i do that from a player on "Female" player it says "He", however it says "she" when i look from my god account. and players can see the gods level, voc also so what im supposed to do?
 
Solution
You'll need to update towns in your phpmyadmin with the new added towns if it doesn't work with the new town "Castles".
I have just tested it on TFS 0.4 and it works properly so if it doesn't work for you that means you need to update your database.
I'm hoping to be able to get house types into TFS 1.3, where regular houses would be type 0, guildhalls type 1. In theory it would be easy to make house type 2 = donation castles. But this feature is not implemented yet.

For now it might be best to keep track of house ids, configure which belongs to donators, and script the doll and buyhouse command accordingly. I think you can extract the house id of the tile in front of you through lua.
 
here is the actions script
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- Shortcuts
local item = 11144 -- id of castle doll
local look = "You have to be looking at door of the castle." -- cancel msg of looking to door to buy the castle
local other = "You already rent another house." -- cancel msg of already have other house
local already = "This castle is already owned by someone else " -- cancel msg of castle already owned by someone
local done = "You have successfully bought this donation castle " -- successfully msg for buy the house.
-- Shortcuts
--codes
local house = getHouseFromPos(getCreatureLookPosition(cid))
--codes
if not house then
doPlayerSendCancel(cid, look)
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
return true
end
if not getHouseInfo(house).guildHall then
if getHouseByPlayerGUID(getPlayerGUID(cid)) then
doPlayerSendCancel(cid, other)
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
return true
end
end
if getHouseOwner(house) > 3 then
doPlayerSendCancel(cid, already)
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
return true
end
setHouseOwner(house, getPlayerGUID(cid))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, done)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doPlayerRemoveItem(cid, 11144, 1)
return true
end

and the doll script
Code:
local items = 11144
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
local tpos,v = {x=1,y=1,z=1},getCreaturePosition(cid)
if(getPlayerItemCount(cid, items) > 0) then
doTeleportThing(cid,tpos)
else
doTeleportThing(cid,fromPosition)
                doSendMagicEffect(v,2)
doPlayerSendTextMessage(cid, 25, "You need Castle Doll to enter on this sqm.")
end
return true
end
 
This script is too old and doesn't have any difference between normal houses/castles Also you have to stand in front of Castle/House door to buy it which isn't used anymore.
Try this one and post here if you don't understand any part and I will help you.
 
Houses not found, You added your Town ID to script? and all castles are inside this town when you check with map editor?
And also added your admin ID?
 
Code:
local lvl = getConfigInfo('levelToBuyHouse')

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerLevel(cid) < lvl then
        return doPlayerSendCancel(cid, 'You have to be at least Level ' .. lvl .. ' to purchase a house.')
    elseif isPlayerPzLocked(cid) then
        return doPlayerSendCancel(cid, 'You cannot use this while PZlocked.')
    end

    local castles = db.getResult('SELECT id FROM houses WHERE town=9')
    if castles:getID() == -1 then
        return true
    end

    local owners, id, castle = {}, getPlayerGUID(cid), nil
    repeat
        local hid = castles:getDataInt('id')
        local owner = getHouseInfo(hid).owner
        if owner == id then
            return doPlayerSendCancel(cid, 'Your character already owns a castle.')
        elseif owner == 0 or owner == 22 then
            if castle == nil then
                castle = hid
            end
        else
            table.insert(owners, owner)
        end
    until not castles:next()
    castles:free()

    if not castle then
        return doPlayerSendCancel(cid, 'There are no castles available at this moment.')
    end

    local acc = db.getResult('SELECT id FROM players WHERE account_id = '.. getPlayerAccountId(cid) .. ' AND id != ' .. id)
    if acc:getID() ~= -1 then
        repeat
            if table.find(owners, acc:getDataInt('id')) then
                return doPlayerSendCancel(cid, 'Your account already owns a castle.')
            end
        until not acc:next()
        acc:free()
    end

    doRemoveItem(item.uid)

    local k = getHouseInfo(castle)
    setHouseOwner(castle, id)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Welcome to your new home, ' .. k.name .. '! You can now step into the teleport. To get here again, enter the teleport in Temple +1')
    doBroadcastMessage(getCreatureName(cid) .. ' has bought ' .. k.name .. ' using a Castle Doll.', MESSAGE_EVENT_ADVANCE)

    local old = getThingPos(cid)
    doTeleportThing(cid, k.entry)
    doSendMagicEffect(old, CONST_ME_TELEPORT)
    doSendMagicEffect(k.entry, CONST_ME_TELEPORT)
    return true
end


Code:
function onThink()
    local castles = db.getResult('SELECT id FROM houses WHERE town=9')
    if castles:getID() == -1 then
        return true
    end

    local p = getPlayersOnline()[1]
    repeat
        local hid = castles:getDataInt('id')
        local h = getHouseInfo(hid)
        if h.owner == 0 then
            setHouseOwner(hid, 22)
        elseif p then
            local n = tonumber(h.name:sub(-2)) or 0
            h.entry.x = h.entry.x + (n % 2 == 0 and 3 or -3)
            doCreatureSay(p, getPlayerNameByGUID(h.owner), TALKTYPE_ORANGE_1, false, 0, h.entry)
        end
    until not castles:next()
    castles:free()

    return true
end

yeah added all
 
so on this script when i change the town=9') which is the right town id i get the error, the other script which is in action has town 9 and its fine, the thing is in the globalevents town id when i set 4 the server runs with no errors
Code:
function onThink()
    local castles = db.getResult('SELECT id FROM houses WHERE town=4')
    if castles:getID() == -1 then
        return true
    end

    local p = getPlayersOnline()[1]
    repeat
        local hid = castles:getDataInt('id')
        local h = getHouseInfo(hid)
        if h.owner == 0 then
            setHouseOwner(hid, 22)
        elseif p then
            local n = tonumber(h.name:sub(-2)) or 0
            h.entry.x = h.entry.x + (n % 2 == 0 and 3 or -3)
            doCreatureSay(p, getPlayerNameByGUID(h.owner), TALKTYPE_ORANGE_1, false, 0, h.entry)
        end
    until not castles:next()
    castles:free()

    return true
end
 
You'll need to update towns in your phpmyadmin with the new added towns if it doesn't work with the new town "Castles".
I have just tested it on TFS 0.4 and it works properly so if it doesn't work for you that means you need to update your database.
 
Solution
Back
Top