• 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!

Lua Advanced doubt

viniciusturko

New Member
Joined
Jun 23, 2009
Messages
94
Reaction score
2
Location
Brasil
Hello guys, I'm trying to make a system that when an action is actived (like the use of a rune), it checks an area near the user and if it finds someone (player), it makes something with this one. This thing is any function like (doPlayerAddMoney(PID[player forund], params).

I've already created the function that checks the place near the player. And with that, I could get some infos using the function, its like:

Code:
function onUse(cid, item)
   for i,y in pairs(getSpectators(getCreaturePosition(cid), 7, 5)) do
         doSendAnimatedText(getCreaturePosition(y), 'Here one!', 123)
   end
end

As you can see, in that function, the system will found the players in range and on each one, it will send the text : "Here one!".

But my doubt is, If I try to make this system uses a directly function (normally needes cid as param) in the other players found in range, It doesn't work.
Here is the example of my doubt :

(If I use the same function before, but change just doSendAnimatedText to doPlayerRemoveMoney It doesn't work)

Code:
function onUse(cid, item)
   for i,y in pairs(getSpectators(getCreaturePosition(cid), 7, 5)) do
         doPlayerRemoveMoney(y, 100)
   end
end
The fucntion just remove money of the player that used the item, and not with other ones in the range too. So, I want someone to help me how to make this system injects a function like doPlayerRemoveMoney in all the players found in the range.
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

	local s = getSpectators(getCreaturePosition(cid), 7, 5)
	if s and #s > 0 then
		for k, it in pairs(s) do
			if isPlayer(it) and it ~= cid then
				doPlayerRemoveMoney(it, 100)
			end
		end
	end
	return true
end
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

	local s = getSpectators(getCreaturePosition(cid), 7, 5)
	if s and #s > 0 then
		for k, it in pairs(s) do
			if isPlayer(it) and it ~= cid then
				doPlayerRemoveMoney(it, 100)
			end
		end
	end
	return true
end

Thank you dark, I'll test it and reply
 
Back
Top