• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Help with function to send a global effect

Rayeko

Programmer
Joined
Apr 9, 2008
Messages
185
Reaction score
3
Hi.

Well, my problem is that I want to create a function that when casted it sends an area effect to all the players online.

But, this effect must be in all the player's screen(7x5) and it must be online visible to that players.. (So that, if two players are close, the effect don't screw up)

I think this kind of function must be done in the source code... But I don't know...
I use TFS 0.3.6 pl1

Hope someone could help me x)
 
Last edited:
TFS 0.3.6 pl1, and area effect x) Its kinda.. You know the /z command? Something like that but like for example: "/zz 10" and that will send the effect 10 to all online players and will display 5:7 effects (so it fills the player's screen).
 
very easy
Code:
function onSay(cid, words, param, channel)
	for _, pid in pairs(getPlayersOnline()) do
		local pos = getCreaturePosition(pid)
		for x = -7, 7 do
			for y = -5, 5 do
				doSendMagicEffect({x = pos.x + x, y = pos.y + y, z = pos.z}, CONST_ME_TELEPORT, pid)
			end
		end
	end
	return true
end
 
Thanks! It worked!

But, I have another question, How can I make it that for example players that are in X area get the effect, instead of all players Online? For example, from X = 1 and Y = 1 to X = 50 and Y = 100. So, players that are in that area will get the effect.

I ask for this other thing 'cause I had an idea, but I can't get the code to make it search from players in a range ;S I tried with this function " getSpectators(centerPos, rangex, rangey[, multifloor = false]) " but I couldn't get it to work :S
 
Code:
local z = 7
function onSay(cid, words, param, channel)
	for x1 = 1, 50 do
		for y1 = 1, 100 do
			local pid = getTopCreature({x = x1, y = y1, z = z})
			if(isPlayer(pid)) then
				for x2 = x1 - 7, x1 + 7 do
					for y2 = y1 - 5, y1 + 5 do
						doSendMagicEffect({x = x2, y = y2, z = z}, CONST_ME_TELEPORT, pid)
					end
				end
			end
		end
	end
	return true
end
Lots of loops, this will probably slow your server down quite a bit.
 
Back
Top