• 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 Check if Player A is in a certain area, Possible?

MUTANO

New Member
Joined
Jan 10, 2009
Messages
39
Reaction score
2
Location
Brazil - Santa Catarina
Hello;

I made this script:

function onStepIn(cid,item,pos)

if item.actionid == 4105 then
queststatus = getPlayerStorageValue(cid,4105)
if queststatus == -1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Kill the boss Hide!!")
doSummonCreature("Hide", {x=1232,y=662,z=8})
doTeleportThing(cid, {x=1239,y=659,z=8})
setPlayerStorageValue(cid,4105,1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Has nothing.")
doTeleportThing(cid, {x=504,y=325,z=7})
end
end
return TRUE
end

It is being used in a teleport, when the player enters it is played in a place where a boss is also summoned, as it is in the script is the Hide ... So far so good.
But if someone comes in, and then someone else comes, will be summoned 2 Hides and 2 players will be there.
What I needed was that something had been added in this script that checks if there is already someone killing her boss, I believe that would be something like getplayer the upper left to lower right of the area where the boss is.
Finally, if possible help, my sincere thanks:)

Thank you.
 
Lua:
local afrompos = {x=1221, y=651, z=8}
local atopos = {x=1246, y=668 z=8}
for xa = afrompos.x,atopos.x do
	for ya = afrompos.y,atopos.y do
		for za = afrompos.z,atopos.z do
			local npos = {x = xa,y = ya,z = za}	
                        if isPlayer(getTopCreature(npos)) then

		        end
		end
	end
end

With this you can also remove monsters etc if a player would die in the area before the boss is dead
 
try this its complete script any error post it here i did't tested.

Lua:
function onStepIn(cid, item, frompos, item2, topos)
        local room = {     -- room with Hide
        fromX = 1221,
        fromY = 651,
        fromZ = 8,
        toX = 1246,
        toY = 668,
        toZ = 8}
		local monster_pos = {        
        [1] = {pos = {1232,662,8}}
        }
		local player_pos = {x=1239, y=659, z=8}
		local cansel_pos = {x=504, y=325,, z=7}
        local monster = "Hide"
	if item.actionid == 4105 then
		killedhide = getPlayerStorageValue(cid,4105)
           if killedhide == -1 then
				for _, area in pairs(monster_pos) do
                doSummonCreature(monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
				doTeleportThing(cid, player_pos)
				end
			 local player_room = 0
                for x = room.fromX, room.toX do
                        for y = room.fromY, room.toY do
                                for z = room.fromZ, room.toZ do
                                        local pos = {x=x, y=y, z=z,stackpos = 253}
                                        local thing = getThingfromPos(pos)
                                        if thing.itemid > 0 then
                                                if isPlayer(thing.uid) == TRUE then
                                                        player_room = player_room+1
                                                end
                                        end
                                end
                        end
                end
                if player_room >= 1 then
                        doPlayerSendTextMessage(cid,19,"There is already some one in the quest room.")           
                elseif player_room == 0 then
                        for x = room.fromX, room.toX do
                                for y = room.fromY, room.toY do
                                        for z = room.fromZ, room.toZ do
                                                local pos = {x=x, y=y, z=z,stackpos = 253}
                                                local thing = getThingfromPos(pos)
                                                if thing.itemid > 0 then
                                                        doRemoveCreature(thing.uid)
                                                end
                                        end
                                end
                        end
                        player_room = 0
						end
						end
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have already done this quest.")
		doTeleportThing(cid, cansel_pos)
	end
        return TRUE
end
 
belthazor I rewrote some of your script, no need to check the area twice
Lua:
function onStepIn(cid, item, frompos, item2, topos)
    local room = { -- room with Hide
    fromX = 1221,
    fromY = 651,
    fromZ = 8,
    toX = 1246,
    toY = 668,
    toZ = 8}
	local monster_pos = {        
    [1] = {pos = {1232,662,8}}
    }
	local player_pos = {x=1239, y=659, z=8}
	local cansel_pos = {x=504, y=325,, z=7}
    local monster = "Hide"
	if item.actionid == 4105 then
	killedhide = getPlayerStorageValue(cid,4105)
        if killedhide == -1 then
			for _, area in pairs(monster_pos) do
				doSummonCreature(monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
			end
		local monster_room = false
		local monsters = {}
		local i = 1
			for x = room.fromX, room.toX do
                for y = room.fromY, room.toY do
                    for z = room.fromZ, room.toZ do
                        local pos = {x=x, y=y, z=z,stackpos = 253}
                        local thing = getThingfromPos(pos)
                        if isPlayer(thing.uid) then
							doPlayerSendTextMessage(cid,19,"There is already some one in the quest room.")  
							return true
						elseif isMonster(thing.uid) then
							monsters[i] = getThingfromPos({x=x,y=y,z=areaposrightdown.z,stackpos=253})
							i = i+1
							monster_room = true								
                        end
                    end
                end
            end        
            if monster_room then
				for r = 1, #monsters do
					doRemoveCreature(monsters[r].uid)
				end
			end
		doTeleportThing(cid, player_pos)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have already done this quest.")
			doTeleportThing(cid, cansel_pos)
		end
	end
        return true
end
 
He accused an error

[Error - LuaScriptInterface::loadFile] data/movements/scripts/level70.lua:4: une
xpected symbol near '='
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/level70
.lua)
data/movements/scripts/level70.lua:4: unexpected symbol near '='

Nor is it right that needed to be placed in "room with Hide"
I put the tile center of the room, correct? :huh:

function onStepIn(cid, item, frompos, item2, topos)
local room = {x=1232, y=661, z=8}
fromX = 1221,
fromY = 651,
fromZ = 8,
toX = 1246,
toY = 668,
toZ = 8}
local monster_pos = {
[1] = {pos = {1232,662,8}}
}
local player_pos = {x=1239, y=659, z=8}
local cansel_pos = {x=504, y=325, z=7}
local monster = "Hide"
if item.actionid == 4105 then
killedhide = getPlayerStorageValue(cid,4105)
if killedhide == -1 then
for _, area in pairs(monster_pos) do
doSummonCreature(monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
end
local monster_room = false
local monsters = {}
local i = 1
for x = room.fromX, room.toX do
for y = room.fromY, room.toY do
for z = room.fromZ, room.toZ do
local pos = {x=x, y=y, z=z,stackpos = 253}
local thing = getThingfromPos(pos)
if isPlayer(thing.uid) then
doPlayerSendTextMessage(cid,19,"There is already some one in the quest room.")
return true
elseif isMonster(thing.uid) then
monsters = getThingfromPos({x=x,y=y,z=areaposrightdown.z,stackpos=253})
i = i+1
monster_room = true
end
end
end
end
if monster_room then
for r = 1, #monsters do
doRemoveCreature(monsters[r].uid)
end
end
doTeleportThing(cid, player_pos)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have already done this quest.")
doTeleportThing(cid, cansel_pos)
end
end
return true
end
 
He accused an error

Nor is it right that needed to be placed in "room with Hide"
I put the tile center of the room, correct? :huh:
where did you get that script that you posted /\
look at this

local room = {x=1232, y=661, z=8}
fromX = 1221,
fromY = 651,
fromZ = 8,
toX = 1246,
toY = 668,
toZ = 8}
 
/\ All right, I had not paid attention to the script.
The script worked in parts, what happens is the following:

• Not sure that the player contains the storage 4105 to prevent him from doing the quest more than once.

• The grant is part of the room and prevent anyone from entering one second player works, but when you go to the teleporter and someone is already there it keeps you going but eventually summoning the boss in the room. However, when you enter it and no one sends you to a room and not the boss summons.

Script:

HTML:
function onStepIn(cid, item, frompos, item2, topos)
    local room = { -- room with Hide
    fromX = 1221,
    fromY = 651,
    fromZ = 8,
    toX = 1246,
    toY = 668,
    toZ = 8}
	local monster_pos = {        
    [1] = {pos = {1232,662,8}}
    }
	local player_pos = {x=1239, y=659, z=8}
	local cansel_pos = {x=504, y=325, z=7}
    local monster = "Hide"
	if item.actionid == 4105 then
	killedhide = getPlayerStorageValue(cid,4105)
        if killedhide == -1 then
			for _, area in pairs(monster_pos) do
				doSummonCreature(monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
			end
		local monster_room = false
		local monsters = {}
		local i = 1
			for x = room.fromX, room.toX do
                for y = room.fromY, room.toY do
                    for z = room.fromZ, room.toZ do
                        local pos = {x=x, y=y, z=z,stackpos = 253}
                        local thing = getThingfromPos(pos)
                        if isPlayer(thing.uid) then
							doPlayerSendTextMessage(cid,19,"There is already some one in the quest room.")  
							return true
						elseif isMonster(thing.uid) then
							monsters[i] = getThingfromPos({x=x,y=y,z=z,stackpos=253})
							i = i+1
							monster_room = true								
                        end
                    end
                end
            end        
            if monster_room then
				for r = 1, #monsters do
					doRemoveCreature(monsters[r].uid)
				end
			end
		doTeleportThing(cid, player_pos)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have already done this quest.")
			doTeleportThing(cid, cansel_pos)
		end
	end
        return true
end

The idea of ​​deleting the Huli boss in the room if someone dies, the script is working well.

I do not want me to take the good will you two, but I hope very much to help me finish this script :)

For the good help they are already doing to me since receiving my REP +

Thank you
 
Last edited:
Lua:
function onStepIn(cid, item, frompos, item2, topos)
	local room = { -- room with Hide
	fromX = 1221,
	fromY = 651,
	fromZ = 8,
	toX = 1246,
	toY = 668,
	toZ = 8}
	local monster_pos = {        
	[1] = {pos = {1232,662,8}}
	}
	local player_pos = {x=1239, y=659, z=8}
	local cansel_pos = {x=504, y=325,, z=7}
	local monster = "Hide"
	if item.actionid == 4105 then
	killedhide = getPlayerStorageValue(cid,4105)
		if killedhide == -1 then
		local monster_room = false
		local monsters = {}
		local i = 1
			for x = room.fromX, room.toX do
				for y = room.fromY, room.toY do
					for z = room.fromZ, room.toZ do
						local pos = {x=x, y=y, z=z,stackpos = 253}
						local thing = getThingfromPos(pos)
						if isPlayer(thing.uid) then
							doPlayerSendTextMessage(cid,19,"There is already some one in the quest room.")  
							return true
						elseif isMonster(thing.uid) then
							monsters[i] = getThingfromPos({x=x,y=y,z=areaposrightdown.z,stackpos=253})
							i = i+1
							monster_room = true								
						end
					end
				end
			end        
			if monster_room then
				for r = 1, #monsters do
					doRemoveCreature(monsters[r].uid)
				end
			end
			for _, area in pairs(monster_pos) do
				doSummonCreature(monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
			end
		doTeleportThing(cid, player_pos)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have already done this quest.")
			doTeleportThing(cid, cansel_pos)
		end
	end
	return true
end

now it won't spawn a boss if there is someone else there.

about the storage id you need to make another script, an onkill script or ondeath that sets the storageid to 0 or higher. or make a script for a questchest that changes the storage
 
In reality, the question to which I refer is the boss, because I wanted to he could kill the boss only once, as in my original script.
----

I tested this last script, but now someone has died there and have a boss no one else enters the room.

It has also generated an error in the console ...

[Error - MoveEvents Interface]
data/movements/scripts/level70.lua: onStepIn
Description:
data/movements/scripts/level70.lua:30: attempt to index global 'areaposrightdown' (a nil value)
stack traceback:
data/movements/scripts/level70.lua:30: in function <data/movements/scripts/level70.lua:1>


-------------------- EDIT

I was working on the script for a while here and could make it work :w00t:
I'm not sure the right way, but now is working 100%

I really appreciate the help you both.

Thank you very much.

end script:

Lua:
function onStepIn(cid, item, frompos, item2, topos)
	local room = {
	fromX = 1221,
	fromY = 651,
	fromZ = 8,
	toX = 1246,
	toY = 668,
	toZ = 8}
	local monster_pos = {        
	[1] = {pos = {x=1232,y=662,z=8}}
	}
	local player_pos = {x=1239, y=659, z=8}
	local cansel_pos = {x=504, y=325, z=7}
	local monster = "Hide"
	local storageid = 4105
	if item.actionid == storageid then
	killedhide = getPlayerStorageValue(cid,storageid)
		if killedhide == -1 then
		local monster_room = false
		local monsters = {}
		local i = 1
			for x = room.fromX, room.toX do
				for y = room.fromY, room.toY do
					for z = room.fromZ, room.toZ do
						local pos = {x=x, y=y, z=z,stackpos = 253}
						local thing = getThingfromPos(pos)
						if isPlayer(thing.uid) then
							doPlayerSendTextMessage(cid,19,"There is already some one in the quest room.")  
							return true
						elseif isMonster(thing.uid) then
							monsters[i] = getThingfromPos({x=x,y=y,z=z,stackpos=253})
							i = i+1
							monster_room = true								
						end
					end
				end
			end        
			if monster_room then
				for r = 1, #monsters do
					doRemoveCreature(monsters[r].uid)
				end
			end
			for _, area in pairs(monster_pos) do
				doSummonCreature(monster,{x=1232,y=662,z=8})
				setPlayerStorageValue(cid,storageid,1)
			end
		doTeleportThing(cid, player_pos)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have already done this quest.")
			doTeleportThing(cid, cansel_pos)
		end
	end
	return true
end
 
Last edited:
Back
Top