provide the script
silver = {x=33527, y=32419, z=12}
function onUse(cid, item, fromPosition, itemEx)
local player = Player(cid)
if not player then
return true
end
if(item.itemid == 22604) then
if(itemEx.itemid == 22638) then
if player:getStorageValue(1) and #Game.getSpectators(silver, false, true, 16, 16, 16, 16) == 0 then
doTeleportThing(cid, silver)
doSummonCreature("terofar", {x=33524, y=32418, z=12})
doRemoveItem(item.uid, 1)
end
end
end
return true
end
No have erros, i only need know how getSpectator return if have X monster on area for make what i want...what is wrong with it / what error are you getting?
map.hgetSpectators returns a table of creature ids for all creatures currently in the specified area (i think...)
void getSpectators(SpectatorVec& list, const Position& centerPos, bool multifloor = false, bool onlyPlayers = false,
int32_t minRangeX = 0, int32_t maxRangeX = 0,
int32_t minRangeY = 0, int32_t maxRangeY = 0);
Hmm, so if i need check if have monster in position X i onlye need set this #Game.getSpectators(silver, false, FALSE, 16, 16, 16, 16) to check player or monsters?map.h
Code:void getSpectators(SpectatorVec& list, const Position& centerPos, bool multifloor = false, bool onlyPlayers = false, int32_t minRangeX = 0, int32_t maxRangeX = 0, int32_t minRangeY = 0, int32_t maxRangeY = 0);
if #Game.getSpectators(silver, false, true, 16, 16, 16, 16) == 0 and #Game.getSpectators(silver, false, false, 16, 16, 16, 16) == 1 then
doTeleportThing(cid, silver)
doRemoveItem(item.uid, 1)
else if #Game.getSpectators(silver, false, true, 16, 16, 16, 16) == 0 and #Game.getSpectators(silver, false, false, 16, 16, 16, 16) == 0
doTeleportThing(cid, silver)
doSummonCreature("terofar", {x=33524, y=32418, z=12})
doRemoveItem(item.uid, 1)
else if #Game.getSpectators(silver, false, true, 16, 16, 16, 16) == 1
return false
end
if #Game.getSpectators(silver, false, false, 16, 16, 16, 16)-#Game.getSpectators(silver, false, true, 16, 16, 16, 16) > 0 then
oh god D: but, my script i have posted here are correct??This if you don't want to specify the monster you want in the area.Code:if #Game.getSpectators(silver, false, false, 16, 16, 16, 16)-#Game.getSpectators(silver, false, true, 16, 16, 16, 16) > 0 then
If you want to check if X monster is in the area you have to iterate over the table and check every creature in it.
I'm in home now and i will test it today and edit hereTest it maybe?
local centralareaboss = {x = 33481, y = 32869, z = 11}
function onUse(cid, item, fromPosition, itemEx)
local player = Player(cid)
if not player then
return true
end
pos1 = {x = 33440, y = 32877, z = getCreaturePosition(cid).z}
--pos2 = {x = 33440, y = 32878, z = getCreaturePosition(cid).z}
--pos3 = {x = 33440, y = 32879, z = getCreaturePosition(cid).z}
--pos4 = {x = 33440, y = 32880, z = getCreaturePosition(cid).z}
--pos5 = {x = 33440, y = 32881, z = getCreaturePosition(cid).z}
if(isPlayer(getTopCreature(pos1).uid)) then --and (isPlayer(getTopCreature(pos2).uid) and (isPlayer(getTopCreature(pos3).uid) and (isPlayer(getTopCreature(pos4).uid) and (isPlayer(getTopCreature(pos5).uid) then
if #Game.getSpectators(centralareaboss, false, true, 16, 16, 16, 16) == 0 and #Game.getSpectators(centralareaboss, false, false, 16, 16, 16, 16) == 1 then
doTeleportThing(getTopCreature(pos1).uid, {x = 33481, y = 32869, z = 11})
--doTeleportThing(getTopCreature(pos2).uid, {x = 33481, y = 32869, z = 11})
--doTeleportThing(getTopCreature(pos3).uid, {x = 33481, y = 32869, z = 11})
--doTeleportThing(getTopCreature(pos4).uid, {x = 33481, y = 32869, z = 11})
--doTeleportThing(getTopCreature(pos5).uid, {x = 33481, y = 32869, z = 11})
end
if #Game.getSpectators(centralareaboss, false, true, 16, 16, 16, 16) == 0 and #Game.getSpectators(centralareaboss, false, false, 16, 16, 16, 16) == 0 then
doTeleportThing(getTopCreature(pos1).uid, {x = 33481, y = 32869, z = 11})
--doTeleportThing(getTopCreature(pos2).uid, {x = 33481, y = 32869, z = 11})
--doTeleportThing(getTopCreature(pos3).uid, {x = 33481, y = 32869, z = 11})
--doTeleportThing(getTopCreature(pos4).uid, {x = 33481, y = 32869, z = 11})
--doTeleportThing(getTopCreature(pos5).uid, {x = 33481, y = 32869, z = 11})
doSummonCreature("Rat", centralareaboss)
end
if #Game.getSpectators(centralareaboss, false, true, 16, 16, 16, 16) == 1 then
return false
end
end
return true
end
Someone have any idea?