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

Rope.lua - Need help!

Veterana

Oldschool Player
Joined
May 4, 2010
Messages
194
Reaction score
7
How can i fix so that rope only works if there is no item blocking the roping spot?
If there is a item/object on the rope spot, it should not be possible to rope.


Here is my Rope.lua code:

LUA:
function onUse(cid, item, frompos, item2, topos)
	if(topos.x == 0 and topos.y == 0 and topos.z == 0) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		return false
	end 
	
	topos.stackpos = 255
	local tmp = getThingFromPos(topos)
	if (tmp.itemid ~= 0) then
		return false
	end
	
	topos.stackpos = 254
	local field = getThingFromPos(topos)
	if (field.itemid ~= 0) then
		return false
	end
	
	newPos = {x = topos.x, y = topos.y, z = topos.z, stackpos = 0}
	groundItem = getThingFromPos(newPos)
	if (isIntegerInArray(ROPE_SPOT, groundItem.itemid)) then
		newPos.y = newPos.y + 1
		newPos.z = newPos.z - 1
		doTeleportThing(cid, newPos)
	elseif (isIntegerInArray(OPENED_HOLE, groundItem.itemid) or isIntegerInArray(OPENED_TRAP, groundItem.itemid) or isIntegerInArray(DOWN_LADDER, groundItem.itemid)) then
		newPos.y = newPos.y + 1
		downPos = {x = topos.x, y = topos.y, z = topos.z + 1, stackpos = 255}
		downItem = getThingFromPos(downPos)
		if (downItem.itemid > 0) then
			doTeleportThing(downItem.uid, newPos)
		else
			doPlayerSendCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		end
	else
		return false
	end
	
	return true
end
 
Last edited by a moderator:
Try this

LUA:
function onUse(cid, item, frompos, item2, topos)
	local check = getThingFromPos(topos)
	if (check.uid > 0) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		return false
	end

	if(topos.x == 0 and topos.y == 0 and topos.z == 0) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		return false
	end 
 
	topos.stackpos = 255
	local tmp = getThingFromPos(topos)
	if (tmp.itemid ~= 0) then
		return false
	end
 
	topos.stackpos = 254
	local field = getThingFromPos(topos)
	if (field.itemid ~= 0) then
		return false
	end
 
	newPos = {x = topos.x, y = topos.y, z = topos.z, stackpos = 0}
	groundItem = getThingFromPos(newPos)
	if (isIntegerInArray(ROPE_SPOT, groundItem.itemid)) then
		newPos.y = newPos.y + 1
		newPos.z = newPos.z - 1
		doTeleportThing(cid, newPos)
	elseif (isIntegerInArray(OPENED_HOLE, groundItem.itemid) or isIntegerInArray(OPENED_TRAP, groundItem.itemid) or isIntegerInArray(DOWN_LADDER, groundItem.itemid)) then
		newPos.y = newPos.y + 1
		downPos = {x = topos.x, y = topos.y, z = topos.z + 1, stackpos = 255}
		downItem = getThingFromPos(downPos)
		if (downItem.itemid > 0) then
			doTeleportThing(downItem.uid, newPos)
		else
			doPlayerSendCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		end
	else
		return false
	end
 
	return true
end
 
Last edited:
Try this

LUA:
function onUse(cid, item, frompos, item2, topos)
	if(topos.x == 0 and topos.y == 0 and topos.z == 0) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		return false
	end 
 
	topos.stackpos = 255
	local tmp = getThingFromPos(topos)
	if (tmp.itemid ~= 0) then
		return false
	end
 
	topos.stackpos = 254
	local field = getThingFromPos(topos)
	if (field.itemid ~= 0) then
		return false
	end
 
	newPos = {x = topos.x, y = topos.y, z = topos.z, stackpos = 0}
	check = getThingFromPos(topos)
	if (check.uid > 0) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "The tile must be clear.") return true end
	groundItem = getThingFromPos(newPos)
	if (isIntegerInArray(ROPE_SPOT, groundItem.itemid)) then
		newPos.y = newPos.y + 1
		newPos.z = newPos.z - 1
		doTeleportThing(cid, newPos)
	elseif (isIntegerInArray(OPENED_HOLE, groundItem.itemid) or isIntegerInArray(OPENED_TRAP, groundItem.itemid) or isIntegerInArray(DOWN_LADDER, groundItem.itemid)) then
		newPos.y = newPos.y + 1
		downPos = {x = topos.x, y = topos.y, z = topos.z + 1, stackpos = 255}
		downItem = getThingFromPos(downPos)
		if (downItem.itemid > 0) then
			doTeleportThing(downItem.uid, newPos)
		else
			doPlayerSendCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		end
	else
		return false
	end
 
	return true
end


Didnt work, but i fixed the problem by alot of editing in codes and stuff.
 
Things this basic should be the same, if you remove the doplayersendtext then it should work just like the rest if the script that's the only thing that's not already in the script
 
from latest avesta revision:

LUA:
function onUse(cid, item, frompos, item2, topos)
	if(topos.x == 0 and topos.y == 0 and topos.z == 0) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		return FALSE
	end 
	
	topos.stackpos = 255
	local tmp = getThingfromPos(topos)
	if (tmp.itemid ~= 0) then
		return FALSE
	end
	
	topos.stackpos = 254
	local field = getThingfromPos(topos)
	if (field.itemid ~= 0) then
		return FALSE
	end
	
	
	newPos = {x = topos.x, y = topos.y, z = topos.z, stackpos = 0}
	groundItem = getThingfromPos(newPos)
	if (isInArray(ROPE_SPOT, groundItem.itemid) == TRUE) then
		newPos.y = newPos.y + 1
		newPos.z = newPos.z - 1
		doTeleportThing(cid, newPos)
	elseif (isInArray(OPENED_HOLE, groundItem.itemid) == TRUE or isInArray(OPENED_TRAP, groundItem.itemid) == TRUE or isInArray(DOWN_LADDER, groundItem.itemid) == TRUE) then
		newPos.y = newPos.y + 1
		downPos = {x = topos.x, y = topos.y, z = topos.z + 1, stackpos = 255}
		downItem = getThingfromPos(downPos)
		if (downItem.itemid > 0) then
			doTeleportThing(downItem.uid, newPos)
		else
			doPlayerSendCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		end
	else
		return FALSE
	end
	
	return TRUE
end

EDIT:

realized you have the same script that i posted ... if it doesn't work, maybe the topOrder is wrong in game.cpp?
 
Last edited:
Back
Top