• 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 isUnderWater(cid)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
Can someone help me to create isUnderWater(cid)?
Floors: {5405, 5406, 5407, 5408, 5409, 5410, 5743, 5744, 5764, 9671, 9672, 9673}

Example:

LUA:
If isUnderWater(cid) then
...
end
 
Last edited:
LUA:
local floors = {5405, 5406, 5407, 5408, 5409, 5410, 5743, 5744, 5764, 9671, 9672, 9673}

function isUnderWater(cid)
	return isCreature(cid) and isInArray(floors, getTileInfo(getThingPos(cid)).itemid)
end
 
Last edited:
Im prolly failing at the tables or the for loop, not used to that in lua D:
LUA:
function isUnderWater(cid)
	local pos = getCreaturePosition(cid)
	local tileID = getTileThingByPos(pos)
	local status = false
	local ids = {5405, 5406, 5407, 5408, 5409, 5410, 5743, 5744, 5764, 9671, 9672, 9673}
	for id in pairs(ids) do 
		if tileID == id then
			status = true
		end
	end
	return status
end

Edit: Ok, Jetro seem to have nailed it, didn't see his post. :P
 
LUA:
local floors = {5405, 5406, 5407, 5408, 5409, 5410, 5743, 5744, 5764, 9671, 9672, 9673}

function isUnderWater(cid)
	return isCreature(cid) and isInArray(floors, getTileInfo(getThingPos(cid)).itemid)
end

Im prolly failing at the tables or the for loop, not used to that in lua D:
LUA:
function isUnderWater(cid)
	local pos = getCreaturePosition(cid)
	local tileID = getTileThingByPos(pos)
	local status = false
	local ids = {5405, 5406, 5407, 5408, 5409, 5410, 5743, 5744, 5764, 9671, 9672, 9673}
	for id in pairs(ids) do 
		if tileID == id then
			status = true
		end
	end
	return status
end

Edit: Ok, Jetro seem to have nailed it, didn't see his post. :P

Which is better? Jetro's or Znote's?
 

Similar threads

  • Question Question
Replies
4
Views
287
Back
Top