• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Check players in area

Sherice

Sky&Wind
Joined
Jan 20, 2012
Messages
183
Reaction score
7
Location
Sweden
Hi guys, is it able to make a script to check if there are players in an area?
Like change an item to another item if you use it, but if there are players in the area, you can't change the item.


Thanx for helps =)
 
Last edited:
Not tested but should work. If it doesn't, send me a private message and I will fix it for you.

LUA:
local from, to = {x = 100, y = 100, z = 7}, {x = 100, y = 100, z = 7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	for _, cid in ipairs(getPlayersOnline()) do
		if not isInRange(getThingPosition(cid), from, to) then
			local id = getThingFromPos({x = 100, y = 100, z = 7, stackpos = 255}, false).uid
			if id > 0 then
				doRemoveItem(id, 1)
			end
		end
	end
	return true
end
 
Last edited:
Back
Top