• 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 Castle system. Tfs 1.1

nevix

Tunzodus.net
Joined
Mar 31, 2010
Messages
356
Reaction score
62
Location
Lithuanian
Hello guys I need a donation castle for myself so I did it for everyone. Working no bugs and simple code.

Actions (put storage)

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)

local castle = 16001
local itemid = 2108

if player:getItemCount(itemid) == 0 then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have required item.")
elseif player:getStorageValue(castle) == 1 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You allready have castle.")
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You got spawn castle (you can find in dimension portal).")
player:setStorageValue(castle, 1)
doRemoveItem(item.uid, 1)

end
return true
end

Ok thats it. You did storage value. now we have to put spawn places.

Movements:

<movevent event="StepIn" actionid="13000" script="my scripts/castle_tile_1.lua"/>
<movevent event="StepIn" actionid="13001" script="my scripts/castle_tile_2.lua"/>


castle_tile_1

Code:
local t = {
    sec = 10,
    where = {x = 20000, y = 20000, z = 7},
    portalwhere = {x = 32243, y = 32166, z = 7},
    itemid = 11798,
    active = 1,
    cooldown = 10,
    storage = 13050,
    storage2 = 13051
}

function onStepIn(cid, item, position, lastPosition)


local castle = 16001
local player = Player(cid)
count = 0
        local spectators = getSpectators(t.where, 100, 100, false)
        if spectators ~= nil then
                for _, spectator in ipairs(spectators) do
                        if isPlayer(spectator) then 
                         count = count + 1
                    
                        end
                end
        end


if count >= 4 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Somebody is allready in castle!")
elseif getGlobalStorageValue(t.storage2) >= os.time() then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have to wait ".. getGlobalStorageValue(t.storage2) - os.time().." seconds before walking here again.")
elseif player:getStorageValue(castle) <= 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have permission to enter here.")
else


local portal = doCreateItem(t.itemid,1,t.portalwhere)
doSetItemActionId(portal, 13001)
addEvent(function() doRemoveItem(getTileItemById(t.portalwhere, t.itemid).uid) end,t.cooldown * 1000)
doSendMagicEffect(t.portalwhere, CONST_ME_TELEPORT)


doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Teleport created for 10 seconds.")
setGlobalStorageValue(t.storage2, os.time() + t.cooldown)

end

return true
end

sec = 10, -- cooldown reduction
where = {x = 20000, y = 20000, z = 7}, -- CHECK PLACE (DID SOMEBODY IS HERE) IMPORTANT
portalwhere = {x = 32243, y = 32166, z = 7}, -- WHERE PORTAL GONNA BE CREATED
itemid = 11798,
active = 1,
cooldown = 10,
storage = 13050, -- STORAGE
storage2 = 13051 -- STORAGE of cooldown

//////////////////////////////////////
castle_tile_2
Code:
function onStepIn(cid, item, position, lastPosition)

local t = {
where = {x = 20000, y = 20000, z = 7}
}

count = 0
        local spectators = getSpectators(t.where, 100, 100, false)
        if spectators ~= nil then
                for _, spectator in ipairs(spectators) do
                        if isPlayer(spectator) then 
                         count = count + 1
                    
                        end
                end
        end

local castle = 16001
local player = Player(cid)


if player:getStorageValue(castle) <= 0 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have permission enter here.")
elseif count >= 4 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "No free castles at the moment!")
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "Welcome to private castle!")
doTeleportThing(cid, t.where)
doSendMagicEffect(t.where, CONST_ME_TELEPORT)
end

end

where = {x = 20000, y = 20000, z = 7} --- Center spot of the castle, it checks players inside.

local spectators = getSpectators(t.where, 100, 100, false)
this 100,100 means how many squares check it means 100 squares in every side.

My english is bad, I know that sorry for it.
Anyway maybe someone needs that so I'm sharing it
 
Last edited:
a donation castle*
myself*
The code is simple and it works without bugs.
Code:
"You don't have required item."
already*, a castle*
Code:
"You have to wait ".. getGlobalStorageValue(t.storage2) - os.time().." seconds before walking here again."
"You don't have permission to enter here."
IMPORTANT*
"There are no free castles at the moment!"
"Welcome to the private castle!"
where = {x = 20000, y = 20000, z = 7} --- Center spot of the castle, it checks players inside.

I hope it helps you in improving your language skills.
If you're not sure about spelling, you may use search bar to see suggestions.

Don't get mad at me for those corrections, I only want to help.
Nice script. I'll add it to my list if you don't mind(see link in my signature).
 
This works for 1.0 to? Nicejob btw repp ++
 
How does it work? Can the owner and his friends deco the house? Or this is only for 1 person?
 
Hello guys I need a donation castle for myself so I did it for everyone. Working no bugs and simple code.

Actions (put storage)

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)

local castle = 16001
local itemid = 2108

if player:getItemCount(itemid) == 0 then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You don't have required item.")
elseif player:getStorageValue(castle) == 1 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You allready have castle.")
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You got spawn castle (you can find in dimension portal).")
player:setStorageValue(castle, 1)
doRemoveItem(item.uid, 1)

end
return true
end

Ok thats it. You did storage value. now we have to put spawn places.

Movements:

<movevent event="StepIn" actionid="13000" script="my scripts/castle_tile_1.lua"/>
<movevent event="StepIn" actionid="13001" script="my scripts/castle_tile_2.lua"/>


castle_tile_1

Code:
local t = {
    sec = 10,
    where = {x = 20000, y = 20000, z = 7},
    portalwhere = {x = 32243, y = 32166, z = 7},
    itemid = 11798,
    active = 1,
    cooldown = 10,
    storage = 13050,
    storage2 = 13051
}

function onStepIn(cid, item, position, lastPosition)


local castle = 16001
local player = Player(cid)
count = 0
        local spectators = getSpectators(t.where, 100, 100, false)
        if spectators ~= nil then
                for _, spectator in ipairs(spectators) do
                        if isPlayer(spectator) then
                         count = count + 1
                   
                        end
                end
        end


if count >= 4 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Somebody is allready in castle!")
elseif getGlobalStorageValue(t.storage2) >= os.time() then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have to wait ".. getGlobalStorageValue(t.storage2) - os.time().." seconds before walking here again.")
elseif player:getStorageValue(castle) <= 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have permission to enter here.")
else


local portal = doCreateItem(t.itemid,1,t.portalwhere)
doSetItemActionId(portal, 13001)
addEvent(function() doRemoveItem(getTileItemById(t.portalwhere, t.itemid).uid) end,t.cooldown * 1000)
doSendMagicEffect(t.portalwhere, CONST_ME_TELEPORT)


doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Teleport created for 10 seconds.")
setGlobalStorageValue(t.storage2, os.time() + t.cooldown)

end

return true
end

sec = 10, -- cooldown reduction
where = {x = 20000, y = 20000, z = 7}, -- CHECK PLACE (DID SOMEBODY IS HERE) IMPORTANT
portalwhere = {x = 32243, y = 32166, z = 7}, -- WHERE PORTAL GONNA BE CREATED
itemid = 11798,
active = 1,
cooldown = 10,
storage = 13050, -- STORAGE
storage2 = 13051 -- STORAGE of cooldown

//////////////////////////////////////
castle_tile_2
Code:
function onStepIn(cid, item, position, lastPosition)

local t = {
where = {x = 20000, y = 20000, z = 7}
}

count = 0
        local spectators = getSpectators(t.where, 100, 100, false)
        if spectators ~= nil then
                for _, spectator in ipairs(spectators) do
                        if isPlayer(spectator) then
                         count = count + 1
                   
                        end
                end
        end

local castle = 16001
local player = Player(cid)


if player:getStorageValue(castle) <= 0 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have permission enter here.")
elseif count >= 4 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "No free castles at the moment!")
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "Welcome to private castle!")
doTeleportThing(cid, t.where)
doSendMagicEffect(t.where, CONST_ME_TELEPORT)
end

end

where = {x = 20000, y = 20000, z = 7} --- Center spot of the castle, it checks players inside.

local spectators = getSpectators(t.where, 100, 100, false)
this 100,100 means how many squares check it means 100 squares in every side.

My english is bad, I know that sorry for it.
Anyway maybe someone needs that so I'm sharing it


What do I put in actions.xml for the first code? You said make a Storage.Lua correct? "Actions(put storage)"
 
I keep getting errors "19:55 You don't have permission enter here."

Any one knows what the issue might be? I dont have any errors in console, running a TFS 1.3 tried to change item id and the teleport id: 11798, get same error, followed every step ofc by, tried to double check if any errors regarding the script but seems fine since its obviously working since i get the error msg. tried with a GOD char and a regular char.
 
I keep getting errors "19:55 You don't have permission enter here."

Any one knows what the issue might be? I dont have any errors in console, running a TFS 1.3 tried to change item id and the teleport id: 11798, get same error, followed every step ofc by, tried to double check if any errors regarding the script but seems fine since its obviously working since i get the error msg. tried with a GOD char and a regular char.

Here you got for tfs 1.3
Code:
    <action itemid="2091" script="castlekey.lua" />
Lua:
local config = {
    default_castle_GUID = 2, -- important, this is Player ID in MYSQL database ( OWNER OF CASTLES )
    start_castle_id = 460, -- MAKE CASTLE START ID
    end_castle_id = 493 -- END CASTLE ID
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local castle_index = config.start_castle_id
    local houseOwnerGUID = 0
    local avaliable = 0
   
    while castle_index ~= config.end_castle_id do
        houseOwnerGUID = getHouseOwner(castle_index)
        if houseOwnerGUID == false or houseOwnerGUID == nil then
        goto continue
        end
        if houseOwnerGUID == config.default_castle_GUID then
            avaliable = castle_index
            break
        end
        ::continue::
        castle_index = castle_index + 1
    end
   
        if avaliable ~= 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Castle ID: " .. (avaliable - config.start_castle_id) + 1 .. " is now yours.")
        setHouseOwner(avaliable, player:getGuid())
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        item:remove(1)
        else
                player:sendTextMessage(MESSAGE_INFO_DESCR, "There are no castles left, please contact the Budex Staff")
        end
    return true
end
 
Back
Top