• 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 isPlayer(cid) not functioning correctly?

Micool777

New Member
Joined
Aug 25, 2012
Messages
14
Reaction score
0
LUA:
function onStepIn(cid, item, position, fromPosition)
	if item.actionid > 30020 and item.actionid < 30100 then
		doPlayerSetTown(cid, item.actionid - 30021)
elseif item.actionid == 1776 then
local toparea={x = 445, y = 59, z = 7}
local botarea={x = 445, y = 64, z = 7}
local fromPos={x=444,y=59,z=7}
local toPos={x=446,y=64,z=7}

if not isPlayer(cid) then
		return true
	end
 
--[1] 
local amount = 0
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			for z = fromPos.z, toPos.z do
			local pid = getThingfromPos({x=x,y=y,z=z})
				if (isPlayer(pid) and getPlayerLevel(pid) >= 100) then
					amount = amount+1
					--doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, pid)
					else
				end	
			end
		end
	end
--[2]
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, amount)
	if amount >= 2 then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "There are already " ..amount.. " duelers in the room.")
		doTeleportThing(cid,fromPosition)
		doSendMagicEffect(fromPosition, CONST_ME_POOF)
end
	if amount == 1 then
		doTeleportThing(cid,toparea)
	else
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "There are " ..amount.. " duelers in the room.")
		doTeleportThing(cid,botarea)
	end
end
return true
end
This is my entire citizen script teleport, but the main problem I'm having is with the lines from [1] to [2] (labeled in the code). It seems as if there might be something wrong with getThingfromPos or isPlayer, because it always says that there are zero duelers in the room, even if the reverse is true. I know that the player is above 100. For some reason, my version doesn't seem to support stackpos either. It would be appreciated if somebody could help me, even if I have to incorporate an alternative function such as getWorldCreatures.
 
Last edited:
LUA:
function onStepIn(cid, item, position, fromPosition)
if item.actionid > 30020 and item.actionid < 30100 then
doPlayerSetTown(cid, item.actionid - 30021)
elseif item.actionid == 1776 then
local toparea={x = 445, y = 59, z = 7}
local botarea={x = 445, y = 64, z = 7}
local fromPos={x=444,y=59,z=7}
local toPos={x=446,y=64,z=7}

if not isPlayer(cid) then
return true
end

--[1] 
local amount = 0
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
for z = fromPos.z, toPos.z do
local pid = getThingfromPos({x=x,y=y,z=z})
if (isPlayer(pid) and getPlayerLevel(pid) >= 100) then
amount = amount+1
--doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, pid)
else
end	
end
end
end
--[2]
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, amount)
if amount >= 2 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "There are already " ..amount.. " duelers in the room.")
doTeleportThing(cid,fromPosition)
doSendMagicEffect(fromPosition, CONST_ME_POOF)
end
if amount == 1 then
doTeleportThing(cid,toparea)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "There are " ..amount.. " duelers in the room.")
doTeleportThing(cid,botarea)
end
end
return true
end

Make your lua tags like =
Code:
[code=lua]
not <lua> ... </lua>
 
Thank you for your help pertaining to the topic I'm questioning. And just in case you were wondering, yes, that was completely sarcastic.

--EDIT--
Repped you anyway, I can see you help people frequently and at the very least you bumped my thread, lol.
 
Last edited:
Thank you for your help pertaining to the topic I'm questioning. And just in case you were wondering, yes, that was completely sarcastic.

--EDIT--
Repped you anyway, I can see you help people frequently and at the very least you bumped my thread, lol.

Great :)
 
LUA:
function onStepIn(cid, item, position, fromPosition)

	if item.actionid > 30020 and item.actionid < 30100 then
		doPlayerSetTown(cid, item.actionid - 30021)
	elseif item.actionid == 1776 then

	local toparea = {x = 445, y = 59, z = 7}
	local botarea = {x = 445, y = 64, z = 7}
	local fromPos = {x = 444, y = 59, z = 7}
	local toPos = {x= 446, y = 64, z = 7}

		if not isPlayer(cid) then
			return true
		end

		local amount = 0
		for x = fromPos.x, toPos.x do
			for y = fromPos.y, toPos.y do
				for z = fromPos.z, toPos.z do
					local pid = getTopCreature({x=x,y=y,z=z}).uid
					if (isPlayer(pid) and getPlayerLevel(pid) >= 100) then
						amount = amount+1
					end
				end
			end
		end

		if amount >= 2 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "There are already " ..amount.. " duelers in the room.")
			doTeleportThing(cid,fromPosition)
			doSendMagicEffect(fromPosition, CONST_ME_POOF)
			return true
		end

		if amount == 1 then
			doTeleportThing(cid,toparea)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "There are " ..amount.. " duelers in the room.")
			doTeleportThing(cid,botarea)
		end
	end
	return true
end
 
Back
Top