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

Cooldown for monster levers

God Mythera

Veteran OT User
Joined
Aug 11, 2012
Messages
2,051
Solutions
2
Reaction score
260
Location
United States
Hello and im wondering if its possible to add a cooldown for my private spawn levers? id like to get a 30 second cooldown before someone can use the lever again, these are the scripts

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z} 
local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}

local amount = 0
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
for z = fromPos.z, toPos.z do
local monster = getTopCreature({x=x,y=y,z=z}).uid
if(isCreature(monster) == TRUE) then
if getCreatureName(monster) == "Diablo" then
amount = amount+1
end
end 
end
end
end

if amount >= 1 then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
doPlayerSendCancel(cid, "You need to kill the Diablo first before you can summon one again.")
return true
else
doSummonCreature("Diablo", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summoned the Diablo.")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
return true
end

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z} 
local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}

local amount = 0
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
for z = fromPos.z, toPos.z do
local monster = getTopCreature({x=x,y=y,z=z}).uid
if(isCreature(monster) == TRUE) then
if getCreatureName(monster) == "Three Headed Beast" then
amount = amount+1
end
end 
end
end
end

if amount >= 1 then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
doPlayerSendCancel(cid, "You need to kill the Three Headed Beast first before you can summon one again.")
return true
else
doSummonCreature("Three Headed Beast", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summoned the Three Headed Beast.")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
return true
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z} 
local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}
local storage,time = 185489, 30
local amount = 0
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
local pos = {x=x, y=y, z=fromPos.z}
local m = getTopCreature(pos).uid
if m ~= 0 and isMonster(m) and getCreatureName(m) == "Diablo" then 
amount = amount+1
end
end
end
if getPlayerStorageValue(cid, storage) >= os.time() then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
doPlayerSendCancel(cid, "wait "..getPlayerStorageValue(cid, storage) - os.time().." seconds to use lever again .") return true
elseif amount >= 1 then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
doPlayerSendCancel(cid, "You need to kill the Diablo first before you can summon one again.") return true
else
doSummonCreature("Diablo", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summoned the Diablo.")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
setPlayerStorageValue(cid, storage, os.time()+time) 
end
return true
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z}
local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}
local storage,time = 185489, 30
local amount = 0
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
local pos = {x=x, y=y, z=fromPos.z}
local m = getTopCreature(pos).uid
if m ~= 0 and isMonster(m) and getCreatureName(m) == "Diablo" then
amount = amount+1
end
end
end
if getPlayerStorageValue(cid, storage) >= os.time() then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "wait "..getPlayerStorageValue(cid, storage) - os.time().." seconds to use lever again .") return true
elseif amount >= 1 then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You need to kill the Diablo first before you can summon one again.") return true
else
doSummonCreature("Diablo", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summoned the Diablo.")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
setPlayerStorageValue(cid, storage, os.time()+time)
end
return true
end
ty so much ;d
 
Back
Top