nevix
Tunzodus.net
Hello guys I need a donation castle for myself so I did it for everyone. Working no bugs and simple code.
Actions (put storage)
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
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
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
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: