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

[Request] Door script which allows 1 player only in room

YugiNao

Banned User
Joined
Nov 22, 2008
Messages
211
Reaction score
3
Need a door script when a player is already in the room another player cant in max is 1 when second player try to enter Door pop-up's a message and say in a Orange text You cant enter here, There is already another player in the room!. :thumbup:
 
LUA:
function onUse(cid, item, frompos, item2, topos)
local door = {x=frompos.x, y=frompos.y-1, z=7}
	for areax = 1585, 1655 do
		for areay = 1202, 1278 do
		local areaPosition = {x=areax, y=areay, z=7, stackpos=253}
		local areaCreature = getThingFromPos(areaPosition)
			if(isPlayer(arenaCreature.uid) == TRUE) then
				doCreatureSay(cid, "You cant enter here, There is already another player in the room!", TALKTYPE_ORANGE_1)
				return 0
			else
				doTeleportThing(cid, door)
			end
		end
	end

Just manage this lines
Code:
for areax = 1585, 1655 do
for areay = 1202, 1278 do
and
Code:
local door = {x=frompos.x, y=frompos.y-1, z=7}
 
this script doesn't work.

LUA:
local posit= {{x=3,y=4},{x=65,y=54},7}; -- {{Topx, Topy},{Bottomx,Bottomy},zFloor};
local isPla = false;
function onUse(cid, item, fromPosition, itemEx, toPosition)
        for areax = posit[1].x, posit[2].y do --Don't remember if in Lua Table starts at 1;
                for areay = posit[1].y,  posit[2].y do
					local areaCreature = getThingFromPos({x=areax,y=areay,z=posit[3]});
					if(isPlayer(areaCreature.uid)) then
						isPla=true;
						break;
					end
                end
		end 
		if(not isPla)
			doTeleportThing(cid, toPosition);
		else
			doCreatureSay(cid, "You cant enter here, There is already another player in the room!", TALKTYPE_ORANGE_1);
		end
	return true;
end
 
Code:
local cfg = {
    fromPos = {1234, 1234, 7}, -- X, Y, Z - top left cornor
    toPos = {1234, 1234, 7}, -- X, Y, Z - bottom right cornor
    doorPos = {x = 1234, y = 1234, z = 7}, -- Door position
    door_open = 1234 -- Id of the door opened. Should be a quest- or experience door.
    }

function onUse(cid, item, fromPosition, itemEx, toPosition)
    for x = cfg.fromPos[1], cfg.toPos[1] do
        for y = cfg.fromPos[2], cfg.toPos[2] do
            for z = cfg.fromPos[3], cfg.toPos[3] do
                pos = {x = x, y = y, z = z, stackpos = 253}
                get = getThingPos(pos)
                if isPlayer(get) then
                    doCreatureSay(cid, "You cant enter here, There is already another player in the room!", TALKTYPE_ORANGE_1)
                else
                    doTransformItem(item.uid, cfg.door_open)
                    doTeleportThing(cid, cfg.doorPos, FALSE)
                end
            end
        end
    end
return true
end
test this one
 
tab it :S;
Code:
local config = {
	fromPos = {x = 100, y = 200, z = 7},
	toPos = {x = 100, y = 200, z = 7},
	newPos = {x = 100, y = 200, z = 7}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	for x = config.fromPos.x, config.toPos.x do
		for y = config.fromPos.y, config.toPos.y do
			for z = config.fromPos.z, config.toPos.z do
				local pos = {x = x, y = y, z = z}
				local player = getTopCreature(pos).uid
				if player > 0 and isPlayer(player) then
					doPlayerSendTextMessage(cid, 27, "This door seems to be sealed against unwanted intruders.")
					break
				else
					doTeleportThing(cid, config.newPos, true)
				end
			end
		end
	end
	return true
end
 
Not really, i thought you didn't know what tabbing is. cuz when i said "tab it" you said its tabbed already..... and its not even what i meant.
 
Lol, my script is the easiest...
LUA:
function onUse(cid, item, frompos, item2, topos)
local cfg = {
door = {x=frompos.x, y=frompos.y+2, z=8}, -- Where your door will tp when room is free(If don't want frompos change it to normal coordinates)
topright = {x=999, y=1000, z=8}, -- top right corner tile
downleft = {x=1001, y=1001, z=8} -- down left corner tile
}
        for areax = cfg.topright.x, cfg.downleft.x do
                for areay = cfg.topright.y, cfg.downleft.y do
                local areaPosition = {x=areax, y=areay, z=frompos.z, stackpos=253}
                local areaCreature = getThingFromPos(areaPosition)
                        if(isPlayer(areaCreature.uid) == TRUE) then
                                doCreatureSay(cid, "You cant enter here, There is already another player in the room!", TALKTYPE_ORANGE_1)
                                return 0
                        else
                                doTeleportThing(cid, cfg.door)
                        end
                end
        end 
        end
Just manage the cfg...
 
Last edited:
1. I didn't change anything, it is my script a little edited(look I wrote as first in this thread).
2. I tested it and it works fine so what's ur problem ??
 
Back
Top