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

[Support]Check player at tile area?

tosse12

Panchira Project Member
Joined
Jun 10, 2007
Messages
864
Reaction score
9
Location
Sweden
Greetings Otland!

I'am trying to do a bridge with a lever, but as you already maybe know, most of the bridge levers don't check if there is a player at the bridge, so if someone use the lever at the same time as the player is on the bridge, that player will be stuck in the lava / water.
And I want that the lever won't be able to be pulled if there is a player at the bridge.


Code:
local b = {
	{x=9848, y=9849, z=11},
	{x=9848, y=9848, z=11},
	{x=9848, y=9847, z=11},
	{x=9848, y=9846, z=11},
	{x=9848, y=9845, z=11},
	{x=9848, y=9844, z=11},
	{x=9848, y=9843, z=11}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local k, v = item.uid, item.itemid
	if k == 1015 then
		for i = 1, 7 do
			doRemoveItem(getTileItemById(b[i], v == 1945 and 598 or 1284).uid)
			doCreateItem(v == 1945 and 1284 or 598, 1, b[i])
                end
         else
                doPlayerSendTextMessage(cid, "You can't do that right now")
	
	end
	doTransformItem(k, tonumber("194".. (v == 1945 and 6 or 5)))
	return TRUE
end

To edit this "Check if player is on bridge"
Code:
local b = {
	{x=9848, y=9849, z=11},
	{x=9848, y=9848, z=11},
	{x=9848, y=9847, z=11},
	{x=9848, y=9846, z=11},
	{x=9848, y=9845, z=11},
	{x=9848, y=9844, z=11},
	{x=9848, y=9843, z=11}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local k, v = item.uid, item.itemid
        for i = 1, 7 do
                local player = getThingfromPos(b[i])
                        if (player > 0 and isCreature(player) == TRUE) then
                                doPlayerSendTextMessage(cid, "You can't do that right now")

                        else
	                         if k == 1015 then
		                         for i = 1, 7 do
			                  doRemoveItem(getTileItemById(b[i], v == 1945 and 598 or 1284).uid)
			                  doCreateItem(v == 1945 and 1284 or 598, 1, b[i])
                                  end
                        doTransformItem(k, tonumber("194".. (v == 1945 and 6 or 5)))
	                end
	return TRUE
end

I am not sure if this is the right way to do it but :P correct me if I am wrong.
another thing I have been thinking about, is that this script shall check every 2 min if there is a creature at the bridge, if not, the bridge shall be removed and the lever turned back as normal
 
Last edited:
ah :p Thanks, didn't knew about that function xD
Maybe should read all functions next time :P

Edit:

Script working now, no errors when pulling lever :D
but haven't tested if u get teleported if using the lever
Code:
local b = {
	{x=9848, y=9849, z=11},
	{x=9848, y=9848, z=11},
	{x=9848, y=9847, z=11},
	{x=9848, y=9846, z=11},
	{x=9848, y=9845, z=11},
	{x=9848, y=9844, z=11},
	{x=9848, y=9843, z=11}
}
local npos = {x=9848, y=9850, z=11}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local k, v = item.uid, item.itemid
	if k == 1015 then
		for i = 1, 7 do
			doRelocate(b[i], npos)
			doRemoveItem(getTileItemById(b[i], v == 1945 and 598 or 1284).uid)
			doCreateItem(v == 1945 and 1284 or 598, 1, b[i])
		end
	doTransformItem(k, tonumber("194".. (v == 1945 and 6 or 5)))
	return TRUE
	end
end
 
Last edited:
Back
Top