• 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 Create Ladder Remove with time.

destroyer667

Member
Joined
Nov 21, 2007
Messages
290
Reaction score
6
I've done some searching on the forums and all i could find was "Stepin tile create ladder Stepout remove ladder" Scripts so i tried creating my own script and i was unsuccessful so now im looking for some help ik it's something small in the script but i cant figure it out.


EDIT: using Avesta 7.6

LUA:
function onUse(cid, item, frompos, item2, topos) 
gatepos = {x=32854, y=32321, z=11, stackpos=1} 
getgate = getThingfromPos(gatepos) 

if item.uid == 7509 and item.itemid == 1945 and getgate.itemid == 1386 then 
doCreateItem(getgate.uid,1) 
addEvent(doTransformItem, 5*60*1000, item.uid, 1945) 
addEvent(onTimer5, 5*60*1000) 
doTransformItem(item.uid,item.itemid+1) 
else 
doPlayerSendCancel(cid,"HURRY!!") 
end 
  return 1 
  end 

function onTimer5() 

wallnewpos = {x=32854, y=32321, z=11}  
        doRemoveItem(1386,1,wallnewpos) 
end
 
Last edited:
LUA:
 function onUse(cid, item, frompos, item2, topos) 
local config = {
getgate = getThingfromPos({x=32854, y=32321, z=11, stackpos=1}), 
gatepos = {x=32854, y=32321, z=11, stackpos=1},
} 

 	if item.itemid == 1945 then  
		doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)   
    end 


	if item.uid == 7509 and item.itemid == 1945 and config.getgate.itemid == 1386 then 
		doCreateItem(1386, 1, config.gatepos) 
 		addEvent(removeLadder, 6 * 1000) 
	else 
		doPlayerSendCancel(cid,"HURRY!!") 
	end 
return TRUE 
end 
 
function removeLadder() 
local ladderPos = {x=32854, y=32321, z=11}
local ladder = getTileItemById(machinePos, 1386)
    if ladder.uid > 0 then
		doRemoveItem(ladder.uid, 1)
		doSendMagicEffect(ladderPos, CONST_ME_SMOKE)
	end
end
 
@ Gabriel Tibiano

Doesn't work :/ im using Avesta 7.6 the switch says "Hurry" when you pull it but you can also move it back as well and it doesn't create the ladder.
 
then you have problably set some uniqueid wrong or any itemid from what i see here, idk i can be completly lost too hehe xD
and in the gatepos, if u have any ground or anything under it i think you must set the stackpos to 2 try that and see if it works, might just be the problem :ninja:

Code:
{x=32854, y=32321, z=11, stackpos=1}
to
Code:
{x=32854, y=32321, z=11, stackpos=2}
 
sorry for my mistake in removeFunction
and u not said which version ur using

LUA:
return TRUE
to
return 1


try out this:
LUA:
function onUse(cid, item, frompos, item2, topos) 
local config = {
getgate = getThingfromPos({x=32854, y=32321, z=11, stackpos=1}), 
gatepos = {x=32854, y=32321, z=11, stackpos=1},
} 
 
 	if item.itemid == 1945 then  
		doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)   
    end 
 
 
	if item.uid == 7509 and item.itemid == 1945 and config.getgate.itemid == 1386 then 
		doCreateItem(1386, 1, config.gatepos) 
 		addEvent(removeLadder, 6 * 1000) 
	else 
		doPlayerSendTextMessage(cid, 22, "BE HURRY!")
	end 
return 1 
end 

function removeLadder() 
local ladderPos = {x=32854, y=32321, z=11}
local ladder = getThingfromPos(ladderPos)
    if ladder.uid > 0 then
		doRemoveItem(ladder.uid, 1)
		doSendMagicEffect(ladderPos, CONST_ME_SMOKE)
	end
end
 
I rechecked all the postions a few times each on map and in scripts to make sure everything was right. I checked the lever unique id and everything. The script doesn't work. You can pull the lever and it says "BE HURRY!" then i go to the spot and the ladder doesn't appear. I don't know why its not working. I've tried multiple scripts nothing works :/
 
ah sorry for my mistake...

try this

LUA:
function onUse(cid, item, frompos, item2, topos) 
local config = {
getgate = getThingfromPos({x=32854, y=32321, z=11, stackpos=1}), 
gatepos = {x=32854, y=32321, z=11, stackpos=1},
} 
 
	if item.uid == 7509 and item.itemid == 1945 and not config.getgate.itemid == 1386 then 
		doTransformItem(item.uid,item.itemid+1)
			doCreateItem(1386, 1, config.gatepos) 
			addEvent(removeLadder, 20 * 1000) 
		doPlayerSendTextMessage(cid, 22, "BE HURRY!")
	elseif item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)  
		doPlayerSendDefaultCancel(cid, "Sorry, not possible.")
	end 
return 1 
end 
 
function removeLadder() 
local ladderPos = {x=32854, y=32321, z=11}
local ladder = getThingfromPos(ladderPos)
    if ladder.uid > 0 then
		doRemoveItem(ladder.uid, 1)
		doSendMagicEffect(ladderPos, CONST_ME_SMOKE)
	end
end
 
easy to understand and configure
'ive tested, repp + + : D


LUA:
local config = {
	ladderPos = {x=52, y=56, z=8, stackpos=1},
	effect = CONST_ME_POFF, -- effect when ladder disappear
	messageOne = "BE HURRY!", -- message when player pull on the lever
	messageTwo = "Sorry, not possible.", -- message that returns when player pull on the lever until ladder back off
	timeRemove = 20, -- Time, in seconds, to remove the ladder
}


function onUse(cid, item, frompos, item2, topos, position)
	if item.uid == 1234 and getThingfromPos(config.ladderPos).itemid < 1386 then
		doCreateItem(1386, 1, config.ladderPos)
			doSendMagicEffect(config.ladderPos, config.effect)
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, config.messageOne)
            doCreatureSay(cid, config.messageOne, TALKTYPE_ORANGE_1)
		addEvent(removeLadder, config.timeRemove * 1000)
	elseif item.uid == 1234 and getThingfromPos(config.ladderPos).itemid == 1386 then 
		doPlayerSendCancel(cid, config.messageTwo)
	end
end


function removeLadder() 
    if getThingfromPos(config.ladderPos).uid > 0 then
		doRemoveItem(getThingfromPos(config.ladderPos).uid, 1)
		doSendMagicEffect(config.ladderPos, CONST_ME_POFF)
	end
end
 
Back
Top