local roomCentre = {x=33271, y=32409, z=12}
local onePerQuest = true
function getCreaturesInRange(position, radiusx, radiusy, showMonsters, showPlayers, showSummons)
local creaturesList = {}
for x = -radiusx, radiusx do
for y = -radiusy, radiusy do
if not (x == 0 and y == 0) then
creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z, stackpos = 253})
if (creature.type == 1 and showPlayers == 1) or (creature.type == 2 and showMonsters == 1 and (showSummons ~= 1 or (showSummons == 1 and getCreatureMaster(creature.uid) == (creature.uid)))) then
table.insert(creaturesList, creature.uid)
end
end
end
end
local creature = getTopCreature(position)
if (creature.type == 1 and showPlayers == 1) or (creature.type == 2 and showMonsters == 1 and (showSummons ~= 1 or (showSummons == 1 and getCreatureMaster(creature.uid) == (creature.uid)))) then
if not(table.find(creaturesList, creature.uid)) then
table.insert(creaturesList, creature.uid)
end
end
return creaturesList
end
function onStepIn(cid, item, position, fromPosition)
if(getPlayerItemCount(cid, 8266) > 0) then
local players = getCreaturesInRange(roomCentre, 8, 8, 0, 1, 0)
if((onePerQuest and #players == 0) or not onePerQuest) then
if(#players == 0) then
local monsters = getCreaturesInRange(roomCentre, 8, 8, 1, 0, 1)
for i = 1, #monsters do
doRemoveCreature(monsters[i])
end
doCreatureSay(doSummonCreature("Koshei The Deathless", {x=position.x, y=position.y-13, z=position.z}), "VERY KIND OF YOU BRINGING ME MY AMULET BACK AFTER ALL THESE YEARS !!!", TALKTYPE_ORANGE_2)
end
else
doTeleportThing(cid, {x=position.x, y=position.y+2, z=position.z})
doSendMagicEffect({x=position.x, y=position.y+2, z=position.z}, CONST_ME_TELEPORT)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Wait out, another player is in the room.")
end
end
return true
end
I know, but that should be handled with function onStepOut.ehmmm cyko, if I try to exit, the koeshi dont dissapear =/ can u fix it?, i want that if some1 are fighting with him and try to exit he dissapear.
local roomCentre = {x=33271, y=32409, z=12}
local onePerQuest = true
function getCreaturesInRange(position, radiusx, radiusy, showMonsters, showPlayers, showSummons)
local creaturesList = {}
for x = -radiusx, radiusx do
for y = -radiusy, radiusy do
if not (x == 0 and y == 0) then
creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z, stackpos = 253})
if (creature.type == 1 and showPlayers == 1) or (creature.type == 2 and showMonsters == 1 and (showSummons ~= 1 or (showSummons == 1 and getCreatureMaster(creature.uid) == (creature.uid)))) then
table.insert(creaturesList, creature.uid)
end
end
end
end
local creature = getTopCreature(position)
if (creature.type == 1 and showPlayers == 1) or (creature.type == 2 and showMonsters == 1 and (showSummons ~= 1 or (showSummons == 1 and getCreatureMaster(creature.uid) == (creature.uid)))) then
if not(table.find(creaturesList, creature.uid)) then
table.insert(creaturesList, creature.uid)
end
end
return creaturesList
end
function onStepIn(cid, item, position, fromPosition)
if(getPlayerItemCount(cid, 8266) > 0) then
local players = getCreaturesInRange(roomCentre, 8, 8, 0, 1, 0)
if((onePerQuest and #players == 0) or not onePerQuest) then
if(#players == 0) then
local monsters = getCreaturesInRange(roomCentre, 8, 8, 1, 0, 1)
for i = 1, #monsters do
doRemoveCreature(monsters[i])
end
doCreatureSay(doSummonCreature("Koshei The Deathless", {x=position.x, y=position.y-13, z=position.z}), "VERY KIND OF YOU BRINGING ME MY AMULET BACK AFTER ALL THESE YEARS !!!", TALKTYPE_ORANGE_2)
end
else
doTeleportThing(cid, {x=position.x, y=position.y+2, z=position.z})
doSendMagicEffect({x=position.x, y=position.y+2, z=position.z}, CONST_ME_TELEPORT)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Wait out, another player is in the room.")
end
end
return true
end
function onStepIn(cid, item, position, fromPosition)
ItemCheck = getPlayerItemCount(cid,8266)
out = {x=position.x, y=position.y-1, z=position.z}
Spawn = {x=position.x, y=position.y-10, z=position.z}
--Check Begin
--Area Check
starting={x=33264, y=32402, z=12, stackpos=253} --Top left corner
checking={x=starting.x, y=starting.y, z=starting.z, stackpos=starting.stackpos}
ending= {x=33278, y=32417, z=12, stackpos=253} --Bottom right corner
--Area Check
players=0
totalmonsters=0
monster = {}
repeat
creature= getThingfromPos(checking)
if creature.itemid > 0 then
if isPlayer(creature.uid) == 1 then
players=players+1
end
if isCreature(creature.uid) then
totalmonsters=totalmonsters+1
monster[totalmonsters]=creature.uid
end
end
checking.x=checking.x+1
if checking.x>ending.x then
checking.x=starting.x
checking.y=checking.y+1
end
until checking.y>ending.y
--Check Ending
if players == 0 and totalmonsters == 0 and ItemCheck > 0 then
doSummonCreature("Koshei The Deathless", Spawn)
elseif players==0 then
current=0
repeat
current=current+1
until current>=totalmonsters
end
end