Good morning people. I have a script on my server that is an item to summon monsters.
When the player uses the item, it will summon 3 monsters around the player for him to kill those monsters.
The problem is that the item can be summed up on the DP side and the monsters stay there and attack everyone. I would like to know if there is a way for me to make sure that this item can only be used away from cities, or in some specific area.
I can create a room and make sure that the item can only be used inside it. That way no novice player would die if someone uses that item close to him.
Does anyone know how I can make this item be used only in a specific area?
I'll leave the script here
When the player uses the item, it will summon 3 monsters around the player for him to kill those monsters.
The problem is that the item can be summed up on the DP side and the monsters stay there and attack everyone. I would like to know if there is a way for me to make sure that this item can only be used away from cities, or in some specific area.
I can create a room and make sure that the item can only be used inside it. That way no novice player would die if someone uses that item close to him.
Does anyone know how I can make this item be used only in a specific area?
I'll leave the script here
Lua:
local KEY = {
[1] = "Card Yokomon",
[2] = "Card Koromon",
[3] = "Card Sunmon",
}
local config = {
exaust_sto = 5555, -- Storage que contabiliza o exaust
exaust_time = 60 -- Segundos de Exaust
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local NUMBER = math.random(1,3) -- Alterar o numero maximo pelo numero final da tabela.
local NUMBER2 = math.random(1,3) -- Alterar o numero maximo pelo numero final da tabela.
local NUMBER3 = math.random(1,3) -- Alterar o numero maximo pelo numero final da tabela.
local pos = getCreaturePosition(cid)
local VALUE = KEY[NUMBER]
local VALUE2 = KEY[NUMBER2]
local VALUE3 = KEY[NUMBER3]
local MONSTER_1 = VALUE
local MONSTER_2 = VALUE2
local MONSTER_3 = VALUE3
if getTileInfo(getThingPos(cid)).protection then
return doPlayerSendCancel(cid, "This item cannot be used in secure areas.") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) and false
else if not exhaustion.check(cid, config.exaust_sto) then
doRemoveItem(item.uid, 1)
exhaustion.set(cid, config.exaust_sto, config.exaust_time)
doCreateMonster(MONSTER_1, pos)
doCreateMonster(MONSTER_2, pos)
doCreateMonster(MONSTER_3, pos)
doSendMagicEffect(pos, CONST_ME_TELEPORT)
return true
else
doPlayerSendTextMessage(cid, 27, "Exhaustion!! Wait ".. exhaustion.get(cid, config.exaust_sto) .." seconds.")
doSendMagicEffect(pos, POFF)
return false
end
end
return true
end