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

Solved IsPlayer in area, wtf...

wesoly136

Member
Joined
Jul 30, 2009
Messages
562
Reaction score
8
Hi!
I've been using this code for many years, even when I was 13 years old, but now I just don't know how to make it working.

Code:
pos = getThingPosition(item.uid)
local fro = {x=pos.x-3, y=pos.y-7, z=pos.z}
local to =  {x=pos.x+3, y=pos.y-2, z=pos.z}
for xx = fro.x, to.x do
	for yy = fro.y, to.y do
		local area = {x=xx, y=yy, z=pos.z, stackpos = 253}
		local ar = getThingFromPos(area)
		if isPlayer(ar.uid) then
			doPlayerSendCancel(cid, "There is someone there.")
			doTeleportThing(cid, frompos, true)
			return true
		end
	end
end
I tried almost all combinations. Also tried a script from old Evo server(with pvp arena for two players) - doesn't work(?!).
Is that part of code correct? What's wrong happened to this "function"?
 
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if not(isPlayer(cid) == TRUE) then
return
end
pos = getThingPosition(item.uid)
local fro = {x=pos.x-3, y=pos.y-7, z=pos.z}
local to =  {x=pos.x+3, y=pos.y-2, z=pos.z}
for xx = fro.x, to.x do
	for yy = fro.y, to.y do
		local area = {x=xx, y=yy, z=pos.z, stackpos = 253}
		local ar = getThingFromPos(area)
		 for _, name in  ipairs(getPlayersOnlineEx()) do -- not sure of that line
			local pid = getPlayerByName(name)					-- not sure of that line
		if isInRange(getPlayerPosition(pid), fro, to)  then
			doPlayerSendCancel(cid, "There is someone there.")
			doTeleportThing(cid, frompos, true)
			return true
		end
		end
	end
end
return true
end
 
Back
Top