local creatures = getSpectators(pos, rangex, rangey[, changeFloors = false])
for i = 1, #creatures do
if getCreatureName(creatures[i]) == "Rat" then
doCreatureSay(cid, "There is a Rat near me!", TALKTYPE_SAY)
end
end
local player = Player(cid)
local specs = Game.getSpectators(player:getPosition(), multifloor, onlyPlayer, minRangeX, maxRangeX, minRangeY, maxRangeY)
for i = 1, #specs do
if Monster(specs[i]) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "There is an "..specs[i]:getName().." near you.")
end
end
Well, you have to use mine from now. Since the other one, is only checking for Rat and it doesn't check if its a monster or not.thanks printer - your idea could be very useful for this script![]()
local player = Player(cid)
local specs = Game.getSpectators(player:getPosition(), multifloor, onlyPlayer, minRangeX, maxRangeX, minRangeY, maxRangeY)
for i = 1, #specs do
if Monster(specs[i]:getId()) and specs[i]:getName() == "Rat" then
player:sendTextMessage(MESSAGE_INFO_DESCR, "There is an Rat near you.")
end
end
Well, it can be easily made in TFS 1.0, but the problem is that it will spam, same creature name over and over again and also it doensn't stack the same creature into the text, Ex. 2x Rats and etc...
You have to find a way to store, specs:getId(), then return it false if that monster has been already "seen"(stored).
Code:local player = Player(cid) local specs = Game.getSpectators(player:getPosition(), multifloor, onlyPlayer, minRangeX, maxRangeX, minRangeY, maxRangeY) for i = 1, #specs do if Monster(specs[i]) then player:sendTextMessage(MESSAGE_INFO_DESCR, "There is an "..specs[i]:getName().." near you.") end end