- Joined
- Feb 14, 2015
- Messages
- 5,643
- Solutions
- 559
- Reaction score
- 3,948
Usage: creature:sendSquare(color, sec [,canSee])
Example: creature:sendSquare(180, 5) -> Sends red colored square to creature for 5 seconds
Note: canSee should be a table argument such as: {'Playername', 'Playername2'}
Video
lib/core/creature.lua
Example: creature:sendSquare(180, 5) -> Sends red colored square to creature for 5 seconds
Note: canSee should be a table argument such as: {'Playername', 'Playername2'}
Video
lib/core/creature.lua
Code:
local function sendSquare(cid, color, sec, n, send)
local creature = Creature(cid)
if not creature then
return false
end
if n <= sec then
local pos = creature:getPosition()
local msg = NetworkMessage()
msg:addByte(0x93)
msg:addU32(cid)
msg:addByte(0x01)
msg:addByte(color)
for i = 1, #send do
if pos:getDistance(send[i]:getPosition()) <= 7 then
msg:sendToPlayer(send[i])
end
end
addEvent(sendSquare, 1000, cid, color, sec, n + 1, send)
end
end
function Creature:sendSquare(color, sec, canSee, n)
--// Creature:sendSquare(color, sec[, canSee])
local pos = self:getPosition()
--// Create a send table if canSee is an argument (otherwise uses spectators)
local specs = Game.getSpectators(pos, false, true, 0, 8, 0, 6)
local send = {}
if canSee then
if type(canSee) == 'table' then
for i = 1, #specs do
if isInArray(canSee, specs[i]:getName()) then
send[#send+1] = specs[i]
end
end
else
return print('Error [Creature:sendSquare] invalid argument type for canSee')
end
end
send = (next(send) and send) or specs
sendSquare(self:getId(), color, sec, (n and n+1) or 0, send)
return true
end
Last edited: