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

Teleport that checks if one player is left

Tarielle

New Member
Joined
Nov 4, 2007
Messages
214
Reaction score
0
Location
Sweden
Is it possible to make a teleport to check if there is only one player left in a area?
I mean like a arena, that you cant walk in the teleport until the other player is defeated..
 
i think maybe if u make a portal with no coordinates and then have a stepin script that checks for players in side an area and if the amount of players is less then 1 then you tp the player otherwise you get message you are still in a duel
 
global.lua
PHP:
-- Area iterator by Colandus @ ******.net
function mapArea(fromPos, toPos, stack)
	local pos = {x=fromPos.x, y=fromPos.y-1, z=fromPos.z}
	return function()
		if (pos.y < toPos.y) then
			pos.y = pos.y+1
		elseif (pos.x <= toPos.x) then
			pos.y = fromPos.y
			pos.x = pos.x+1
		else
			pos.x = fromPos.x
			pos.y = fromPos.y
			pos.z = pos.z+1
		end
		if (pos.x <= toPos.x and pos.y <= toPos.y or pos.z < toPos.z) then
			if (stack == nil) then
				return pos
			else
				pos.stackpos = stack
				return pos, getThingfromPos(pos).uid
			end
		end
	end
end

PHP:
local fromPos = {x=x, y=y, z=z}
local toPos = {x=x, y=y, z=z}

for _, thing in mapArea(fromPos, toPos, 253) do
    if isPlayer(thing.uid) == TRUE then
        -- player found, now what?
        return TRUE
    end
end
-- no player was found, continue?
return TRUE

add the onStepIn or w/e you want yourself :p
 
@Colandus:
Do that really check if there is only one? I mean it shall not possible to walk inside the teleport if there is two persons in the area, but it shall be possible if there is only one.

@Elf:
How?
-short-
 
How do I use the:
Code:
for _, thing in mapArea(fromPos, toPos, 253) do
How should I edit the 'for _,'. Example please :p Because it dosn't workt if you execute the script with 'for_,'.
 
Back
Top