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

check stuff on area

Doggynub

LUA / C++
Joined
Sep 28, 2008
Messages
2,541
Reaction score
186
1- i want a lua command to define a certain area
ex: i determine 4 tiles and area between is my desired to check staff in it so i want to point to it

like i want to say if player in between this area then i
can do somthng
 
Last edited:
now i want to say if players in area(xyz) to area (xyz)
if they have storage 1 and dont have storage 2 then execute the action
 
like this?
Code:
local fromPos = {x = 100, y = 200, z = 7}
local toPos = {x = 100, y = 200, z = 7}
function example()
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			for z = fromPos.z, toPos.z do
				local pos = {x = x, y = y, z = z}
				local c = getTopCreature(pos).uid
				if isCreature(c) then
					if getPlayerStorageValue(c, 34123) == 1 then
						dosomething()
					end
				end
			end
		end
	end
	return true
end
 
Code:
local fromPos = {x = 100, y = 100, z = 7}
local toPos = {x = 200, y = 200, z = 7}
local storage = 1991

for x = fromPos.x, toPos.x do
	for y = fromPos.y, toPos.y do
		for z = fromPos.z, toPos.z do
			local p = getTopCreature({x=x, y=y, z=z}).uid
			if isPlayer(p) then
				local s = getPlayerStorageValue(cid, storage)
				if s > 0 and s < 1 then
					--
				end
			end
		end
	end
end
 
does this means if like
players that have storage (1991) == 1 are like 2 players
players that have storage (1991) == 3 are zero then
execute??
 
so it be like this works?
LUA:
local fromPos = {x = 100, y = 100, z = 7}
local toPos = {x = 200, y = 200, z = 7}
local storage = 1991



function onStepIn(cid, item, position, fromPosition)
        for x = fromPos.x, toPos.x do
	  for y = fromPos.y, toPos.y do
		for z = fromPos.z, toPos.z do
	      local t, p = 0, 0
	          for _, pid in ipairs(isPlayer(getTopCreature({x=x, y=y, z=z}).uid)) do
		         local v = getPlayerStorageValue(pid, 1991)
		          if v == 1 then
			       t = t + 1
		          elseif v == 2 then
			        p = p + 1
		          end
	          end
	          if t >= 1 and p < 1 then
                ----------
               end
          end
        end
end

this works???
 
Back
Top