• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lever to remove wall (time based) rep++

Chrippe

New Member
Joined
Jun 17, 2007
Messages
51
Reaction score
0
Hello!

I've been trying to get this to work without no results, my lua skills is simply not enough. So I turn to you, the professionals!


What I want is a lever which will remove 2 walls when being pulled. That's exactly what the script does, but I'd like to add a time-limit to it, so it goes back to its standard position after 10 seconds (both the lever and the walls).

LUA:
  function onUse(cid, item, frompos, item2, topos)
        wall1 = {x=505, y=598, z=8, stackpos=1}
        wall2 = {x=505, y=599, z=8, stackpos=1}
        getwall1 = getThingfromPos(wall1)
        getwall2 = getThingfromPos(wall2)

        if item.uid == 7002 and item.itemid == 1945 then
                doRemoveItem(getwall1.uid,1)
                doRemoveItem(getwall2.uid,1)
                doTransformItem(item.uid,item.itemid+1)
				doCreatureSay(cid, "You just opened a secret passage!", TALKTYPE_ORANGE_1)
        elseif item.uid == 7002 and item.itemid == 1946 then
                doCreateItem(1025,1,wall1)
                doCreateItem(1025,1,wall2)
                doTransformItem(item.uid,item.itemid-1)        
        else
                doPlayerSendCancel(cid,"Sorry, not possible.")
        end

        return 1
end


If you manage to help me, I'll gladly give you reputation points!
And talking about reputation, thanks apsivaflines for the script in the first place. Now only thing left is for someone to advance it.

Thanks in advance!
Chrippe
 
What if I tell you how to do it so that you learn more?

addEvent(function, time in miliseconds, parameters)

:)

[e.g: addEvent(doPlayerAddItem, 10000, cid, 2666, 1)]
 
What if I tell you how to do it so that you learn more?

addEvent(function, time in miliseconds, parameters)

:)

[e.g: addEvent(doPlayerAddItem, 10000, cid, 2666, 1)]


Belive me, I already tried to understand for a couple of hours and actually, I did use the addEvent command, but I don't really know how to fit it in. Btw that example you made, that would give the character 1 piece of meat wouldn't it?

I appreciate that you try to teach me how to do this, but I think it would be better if you included a final script to forfill my wishes ;) and by that way I could see what you changed.

Please help me!
 
Yes, it would.

Also; fulfill, not forfill.

And:

LUA:
function eventual(cid, item, wallpos)
	doCreateItem(1025,1,wallpos[1])
	doCreateItem(1025,1,wallpos[2])
	doTransformItem(item.uid,item.itemid-1)        
end

function onUse(cid, item, frompos, item2, topos)
	wallpos = {
	{x=505, y=598, z=8, stackpos=1},
	{x=505, y=599, z=8, stackpos=1}
}
	getwalls = {
	getThingfromPos(wall1),
	getThingfromPos(wall2)
}

	if item.uid == 7002 and item.itemid == 1945 then
		doRemoveItem(getwalls[1].uid,1)
		doRemoveItem(getwalls[2].uid,1)
		doTransformItem(item.uid,item.itemid+1)
		doCreatureSay(cid, "You just opened a secret passage!", TALKTYPE_ORANGE_1)
		addEvent(eventual, 10000, cid, item, wallpos)
	elseif item.uid == 7002 and item.itemid == 1946 then
		doPlayerSendCancel(cid,"You can't use this yet.")
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end
	return 1
end

Hope it works.
 
Yes, it would.

Also; fulfill, not forfill.

And:

LUA:
function eventual(cid, item, wallpos)
	doCreateItem(1025,1,wallpos[1])
	doCreateItem(1025,1,wallpos[2])
	doTransformItem(item.uid,item.itemid-1)        
end

function onUse(cid, item, frompos, item2, topos)
	wallpos = {
	{x=505, y=598, z=8, stackpos=1},
	{x=505, y=599, z=8, stackpos=1}
}
	getwalls = {
	getThingfromPos(wall1),
	getThingfromPos(wall2)
}

	if item.uid == 7002 and item.itemid == 1945 then
		doRemoveItem(getwalls[1].uid,1)
		doRemoveItem(getwalls[2].uid,1)
		doTransformItem(item.uid,item.itemid+1)
		doCreatureSay(cid, "You just opened a secret passage!", TALKTYPE_ORANGE_1)
		addEvent(eventual, 10000, cid, item, wallpos)
	elseif item.uid == 7002 and item.itemid == 1946 then
		doPlayerSendCancel(cid,"You can't use this yet.")
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end
	return 1
end

Hope it works.
the event wouldn't work because item uids change between script callbacks.
 
Oh. I didn't know that. Thank you, once again, for clearing something up for me ^_^.

LUA:
function eventual(cid, getThingPos(item.uid), wallpos)
        doCreateItem(1025,1,wallpos[1])
        doCreateItem(1025,1,wallpos[2])
        doTransformItem(getThingPos(item.uid),item.itemid-1)        
end

function onUse(cid, item, frompos, item2, topos)
        wallpos = {
        {x=505, y=598, z=8, stackpos=1},
        {x=505, y=599, z=8, stackpos=1}
}
        getwalls = {
        getThingfromPos(wall1),
        getThingfromPos(wall2)
}

        if item.uid == 7002 and item.itemid == 1945 then
                doRemoveItem(getwalls[1].uid,1)
                doRemoveItem(getwalls[2].uid,1)
                doTransformItem(item.uid,item.itemid+1)
                doCreatureSay(cid, "You just opened a secret passage!", TALKTYPE_ORANGE_1)
                addEvent(eventual, 10000, cid, getThingPos(item.uid), wallpos)
        elseif item.uid == 7002 and item.itemid == 1946 then
                doPlayerSendCancel(cid,"You can't use this yet.")
        else
                doPlayerSendCancel(cid,"Sorry, not possible.")
        end
        return 1
end
 
Back
Top