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

A bit more thinking required (Wall scripts)

gr33nd3v1l

You see a Green Devil.
Joined
Feb 12, 2008
Messages
140
Reaction score
0
Location
Croatia
I made 11 scripts that can't be simpler then they are. Simple remove wall scripts with uid. The point of the script is this: You push a lever, remove a distant wall/rock/metal bars so that you may get to another lever. That lever removes the small wall right next to the first lever. Now you can get to the third lever and remove the distant wall yadda yadda mostly all over again. The point is you have to run all around a large area and face poi monsters as they respawn (I tried to make a simpler POI then real Tibia because i never done it and i don't know the details of the quest).

I get no errors in my console, i can push the lever, but the text doesn't show up, and it doesn't remove the rocks it's supposed to.

My question is: could it maybe place 2 more rocks in the same place? Have i done the script the wrong way :D? And if someone could add a storage value and a check to this script so a person may pull the first lever only once.
Thanks in advance.

This is only the first script. I don't see the point of posting all 11 of them when not even the first one works.

Code:
function onUse(cid, item, frompos, item2, topos)
	wall1 = {x=694, y=698, z=10, stackpos=1}
	wall2 = {x=694, y=699, z=10, stackpos=1}
	getwall1 = getThingfromPos(wall1)
	getwall2 = getThingfromPos(wall2)

	if item.uid == 7677 and item.itemid == 1945 then
			doRemoveItem(getwall1.uid,1)
			doRemoveItem(getwall2.uid,1)
			doTransformItem(item.uid,item.itemid+1)
   		doPlayerSendTextMessage(cid,18,"Something heavy was moved.")
	elseif item.uid == 7677 and item.itemid == 1946 then
		doCreateItem(1304,1,wall1)
		doCreateItem(1304,1,wall2)
		doTransformItem(item.uid,item.itemid-1)
   		doPlayerSendTextMessage(cid,18,"Something heavy was moved.")		
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end

	return 1
end

I tried adding storage values but it had so many errors, simply had no nerves after making all the other scripts =\
 
PHP:
function onUse(cid, item, frompos, item2, topos)
	wall1 = {x=694, y=698, z=10, stackpos=1}
	wall2 = {x=694, y=699, z=10, stackpos=1}
	getwall1 = getThingfromPos(wall1)
	getwall2 = getThingfromPos(wall2)

	if item.uid == 7677 and item.itemid == 1945 then
	        if getPlayerStorageValue(cid, 8721) ~= 1 then
			doRemoveItem(getwall1.uid)
			doRemoveItem(getwall2.uid)
			doTransformItem(item.uid,item.itemid + 1)
   		doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
   		else
   		doPlayerSendTextMessage(cid, 22, "You have already pulled the lever.")
   		end
	elseif item.uid == 7677 and item.itemid == 1946 then
		doCreateItem(1304, 1, wall1)
		doCreateItem(1304, 1, wall2)
		doTransformItem(item.uid,item.itemid - 1)
   		doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
	else
		doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
	end

	end
	return TRUE
end

Try if that works :confused:
 
This one should work.

Code:
function onUse(cid, item, frompos, item2, topos)
    wall1 = {x=694, y=698, z=10, stackpos=1}
    wall2 = {x=694, y=699, z=10, stackpos=1}
    getwall1 = getThingfromPos(wall1)
    getwall2 = getThingfromPos(wall2)

    if item.uid == 7677 and item.itemid == 1945 then
            if getPlayerStorageValue(cid, 8721) ~= 1 then
            doRemoveItem(getwall1.uid)
            doRemoveItem(getwall2.uid)
            doTransformItem(item.uid,item.itemid + 1)
           doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
           else
           doPlayerSendTextMessage(cid, 22, "You have already pulled the lever.")
           end
    elseif item.uid == 7677 and item.itemid == 1946 then
        doCreateItem(1304, 1, wall1)
        doCreateItem(1304, 1, wall2)
        doTransformItem(item.uid,item.itemid - 1)
           doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
    else
        doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
    end
    return TRUE
end

EDIT: Added storageValue to the script, should work.

Code:
function onUse(cid, item, frompos, item2, topos)
    local wall1 = {x=694, y=698, z=10, stackpos=1}
    local wall2 = {x=694, y=699, z=10, stackpos=1}
    local getwall1 = getThingfromPos(wall1)
    local getwall2 = getThingfromPos(wall2)
    local used = getPlayerStorageValue(cid, 1337)

    if item.uid == 7677 and item.itemid == 1945 and used == 1 then
            if getPlayerStorageValue(cid, 8721) ~= 1 then
            doRemoveItem(getwall1.uid)
            doRemoveItem(getwall2.uid)
            doTransformItem(item.uid,item.itemid + 1)
            doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
            doSetPlayerStorageValue(cid, 1337, 1 )
           else
           doPlayerSendTextMessage(cid, 22, "You have already pulled the lever.")
           end
    elseif item.uid == 7677 and item.itemid == 1946 then
        doCreateItem(1304, 1, wall1)
        doCreateItem(1304, 1, wall2)
        doTransformItem(item.uid,item.itemid - 1)
        doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
    else
        doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
    end
    return TRUE
end
 
Last edited:
ED:

I'm gonna try this one out, thanks

(i noticed the storage values are different, it checks for 8721 but sets a 1337 - is that wrong?)

rep+ to you two
 
This one should work.

Code:
function onUse(cid, item, frompos, item2, topos)
    wall1 = {x=694, y=698, z=10, stackpos=1}
    wall2 = {x=694, y=699, z=10, stackpos=1}
    getwall1 = getThingfromPos(wall1)
    getwall2 = getThingfromPos(wall2)

    if item.uid == 7677 and item.itemid == 1945 then
            if getPlayerStorageValue(cid, 8721) ~= 1 then
            doRemoveItem(getwall1.uid)
            doRemoveItem(getwall2.uid)
            doTransformItem(item.uid,item.itemid + 1)
           doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
           else
           doPlayerSendTextMessage(cid, 22, "You have already pulled the lever.")
           end
    elseif item.uid == 7677 and item.itemid == 1946 then
        doCreateItem(1304, 1, wall1)
        doCreateItem(1304, 1, wall2)
        doTransformItem(item.uid,item.itemid - 1)
           doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
    else
        doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
    end
    return TRUE
end

EDIT: Added storageValue to the script, should work.

Code:
function onUse(cid, item, frompos, item2, topos)
    local wall1 = {x=694, y=698, z=10, stackpos=1}
    local wall2 = {x=694, y=699, z=10, stackpos=1}
    local getwall1 = getThingfromPos(wall1)
    local getwall2 = getThingfromPos(wall2)
    local used = getPlayerStorageValue(cid, 1337)

    if item.uid == 7677 and item.itemid == 1945 and used == 1 then
            if [b]getPlayerStorageValue(cid, 8721)[/b] ~= 1 then
            doRemoveItem(getwall1.uid)
            doRemoveItem(getwall2.uid)
            doTransformItem(item.uid,item.itemid + 1)
            doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
            [b]doSetPlayerStorageValue(cid, 1337, 1 )[/b]
           else
           doPlayerSendTextMessage(cid, 22, "You have already pulled the lever.")
           end
    elseif item.uid == 7677 and item.itemid == 1946 then
        doCreateItem(1304, 1, wall1)
        doCreateItem(1304, 1, wall2)
        doTransformItem(item.uid,item.itemid - 1)
        doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
    else
        doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
    end
    return TRUE
end

:confused:

PS:
Da Numbers......


########
UP
########

Yea, they should be the same.
 
What's the ID of the stones you are using?

Was it I who missed a ) ?

@Marcinek: You had an "end" too much in your script. ^^
 
No i was wrong about that (i didn't notice the scroll to right thingy so it looked like it's missing ;D)

The stones are the tall spikey ones id 1304
 
Ok.

Another one error in yours:
Code:
if item.uid == 7677 and item.itemid == 1945 and [b]used == 1[/b] then

( ~= )


####

Try to removing stackpos = 1 from everywhere.

^ wont work ^
^ but u can try ;D ^
 
Try this one.
Code:
function onUse(cid, item, frompos, item2, topos)

    local wall1 = {x=694, y=698, z=10, stackpos=255}
    local wall2 = {x=694, y=699, z=10, stackpos=255}
    local getwall1 = getThingfromPos(wall1)
    local getwall2 = getThingfromPos(wall2)
    local used = getPlayerStorageValue(cid, 1337)
    
    if item.uid == 7677 and item.itemid == 1945 then
        if used ~= 0 then
            doRemoveItem(getwall1.uid,1)
            doRemoveItem(getwall2.uid,1)
            doTransformItem(item.uid,item.itemid + 1)
            doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
            DoSetPlayerStorageValue(cid, 1337, 1)
        else
            doPlayerSendCancel(cid, "You have already pulled this lever.")
        end
    elseif item.itemid == 1946 and item.uid == 7677 then
        doCreateItem(1304, 1, wall1)
        doCreateItem(1304, 1, wall2)
        doTransformItem(item.uid,item.itemid - 1)
        doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
    else
        doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
    end
end

Tell me if there's any errors.
 
Last edited:
local wall1 = {x=694, y=698, z=10}
local wall2 = {x=694, y=699, z=10}
local getwall1 = getThingfromPos(wall1)
local getwall2 = getThingfromPos(wall2)

maybe it's a mistake in naming them?

local wall1 or wall1

or is local a prefix \ command to get the wall1

~ just brainstorming a bit D;
 
I quote Vagabond@otland (Nate@OpenLua)

Nate said:
Use local variables

One stumbling block for Lua programmers coming from other languages is the fact that all variables are global unless specified otherwise. Many times, the use of global variables is necessary: saved variables are created via the global environment; all API functions and UI frames are in the global namespace. However, globals come at a cost of both performance, and naming conflicts.

EDIT: Edited previous post, try it out.
 
Last edited:
Try this one.
Code:
function onUse(cid, item, frompos, item2, topos)

    local wall1 = {x=694, y=698, z=10, stackpos=255}
    local wall2 = {x=694, y=699, z=10, stackpos=255}
    local getwall1 = getThingfromPos(wall1)
    local getwall2 = getThingfromPos(wall2)
    local used = getPlayerStorageValue(cid, 1337)
    
    if item.uid == 7677 and item.itemid == 1945 then
        if used ~= 1 then
            doRemoveItem(getwall1.uid,1)
            doRemoveItem(getwall2.uid,1)
            doTransformItem(item.uid,item.itemid + 1)
            doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
            setPlayerStorageValue(cid, 1337, 1)
        else
            doPlayerSendCancel(cid, "You have already pulled this lever.")
        end
    elseif item.itemid == 1946 and item.uid == 7677 then
        doCreateItem(1304, 1, wall1)
        doCreateItem(1304, 1, wall2)
        doTransformItem(item.uid,item.itemid - 1)
        doPlayerSendTextMessage(cid, 18, "Something heavy was moved.")
    else
        doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
    end
end

Tell me if there's any errors.

Quoted with a bugfix.
koepakpeoa
 
Back
Top