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

I need help with this remove stone script.

Udun

Well-Known Member
Joined
Jan 5, 2012
Messages
193
Solutions
1
Reaction score
68
Hello there, I got this script that remove a big stone by lever (this is a stone that uses 4sqm), in fact are 4 different items id's
Doesn't work, I was wondering if here is a experienced scripter that can give me a hand.
I use TFS 0.3.6

This is the script:
Lua:
function onUse(cid, item, frompos, item2, topos)
wall1 = {x=2625, y=1678, z=3, stackpos=1},
wall2 = {x=2626, y=1678, z=3, stackpos=1},
wall3 = {x=2625, y=1679, z=3, stackpos=1},
wall4 = {x=2626, y=1679, z=3, stackpos=1}
getwall1 = getThingfromPos(wall1),
getwall2 = getThingfromPos(wall2),
getwall3 = getThingfromPos(wall3),
getwall4 = getThingfromPos(wall4)

if item.uid == 60261 and item.itemid == 1945 then
doRemoveItem(getwall1.uid,1)
doRemoveItem(getwall1.uid,2)
doRemoveItem(getwall1.uid,3)
doRemoveItem(getwall1.uid,4)
doTransformItem(item.uid,item.itemid+1)
doTransformItem(item.uid,item.itemid+1)
doTransformItem(item.uid,item.itemid+1)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 60261 and item.itemid == 1946 then
doCreateItem(1300,1,wall1)
doTransformItem(item.uid,item.itemid-1)  
else
doCreateItem(1301,1,wall2)
doTransformItem(item.uid,item.itemid-1)  
else
doCreateItem(1302,1,wall3)
doTransformItem(item.uid,item.itemid-1)  
else
doCreateItem(1303,1,wall4)
doTransformItem(item.uid,item.itemid-1)  
else
doPlayerSendCancel(cid,"Sorry, not possible.")
end
return 1
end

Thanks!
------------------------------
EDIT

Well, I found a new one, so the problem is solved, credits to: Chaootiick

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    removals = {
 { item = 1300, pos = {x = 2625, y = 1678, z = 3 } },
 { item = 1301, pos = {x = 2626, y = 1678, z = 3 } },   
 { item = 1302, pos = {x = 2625, y = 1679, z = 3 } },   
 { item = 1303, pos = {x = 2626, y = 1679, z = 3 } }   
    }
    
    if item.itemid == 1945 then
        for i = 1, #removals do
            removals[i].pos.stackpos = 1
            doRemoveItem(getThingfromPos(removals[i].pos).uid, 1)
        end
        doTransformItem(item.uid, item.itemid + 1)
    elseif item.itemid == 1946 then
        for i = 1, #removals do
            doCreateItem(removals[i].item, 1, removals[i].pos)
        end
        doTransformItem(item.uid, item.itemid - 1)
    end
    return TRUE
end
 
Last edited:
I know you said its solved now but I wanted to give you a better code. This one checks to see if the players are standing where stones will be created. It also makes sure it doesn't spawn a stone on top of another stone.

Code:
local positions = { -- Teleport back is the position to teleport a player if he is standing where the stone will be created.
    [1] = {itemId = 1300, pos = {x = 2625, y = 1678, z = 3, stackpos = 1}, teleportBack = {x = 1000, y = 1000, z = 7}},
    [2] = {itemId = 1301, pos = {x = 2626, y = 1678, z = 3, stackpos = 1}, teleportBack = {x = 1000, y = 1000, z = 7}},
    [3] = {itemId = 1302, pos = {x = 2625, y = 1679, z = 3, stackpos = 1}, teleportBack = {x = 1000, y = 1000, z = 7}},
    [4] = {itemId = 1303, pos = {x = 2626, y = 1679, z = 3, stackpos = 1}, teleportBack = {x = 1000, y = 1000, z = 7}}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
        for i = 1, #positions do
            local item = getThingFromPos(positions[i])
            if item then
                doRemoveItem(item.uid, 1)
            end
        end
        doTransformItem(item.uid, item.itemid + 1)
    elseif item.itemid ==  1946 then
        for i = 1, #positions do
            local item = getThingFromPos(positions[i])
            if item then
                return true
            end
            
            doCreateItem(positions[i].itemId, 1, positions[i].pos)
            positions[i].stackpos = 255
            local playerCheck = getThingFromPos(positions[i])
            if isPlayer(playerCheck) then
                doTeleportThing(playerCheck, positions[i].teleportBack)
            end
        end
        doTransformItem(item.uid, item.itemid - 1)
    end    
return true
end
 
I know you said its solved now but I wanted to give you a better code. This one checks to see if the players are standing where stones will be created. It also makes sure it doesn't spawn a stone on top of another stone.

Code:
local positions = { -- Teleport back is the position to teleport a player if he is standing where the stone will be created.
    [1] = {itemId = 1300, pos = {x = 2625, y = 1678, z = 3, stackpos = 1}, teleportBack = {x = 1000, y = 1000, z = 7}},
    [2] = {itemId = 1301, pos = {x = 2626, y = 1678, z = 3, stackpos = 1}, teleportBack = {x = 1000, y = 1000, z = 7}},
    [3] = {itemId = 1302, pos = {x = 2625, y = 1679, z = 3, stackpos = 1}, teleportBack = {x = 1000, y = 1000, z = 7}},
    [4] = {itemId = 1303, pos = {x = 2626, y = 1679, z = 3, stackpos = 1}, teleportBack = {x = 1000, y = 1000, z = 7}}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
        for i = 1, #positions do
            local item = getThingFromPos(positions[i])
            if item then
                doRemoveItem(item.uid, 1)
            end
        end
        doTransformItem(item.uid, item.itemid + 1)
    elseif item.itemid ==  1946 then
        for i = 1, #positions do
            local item = getThingFromPos(positions[i])
            if item then
                return true
            end
           
            doCreateItem(positions[i].itemId, 1, positions[i].pos)
            positions[i].stackpos = 255
            local playerCheck = getThingFromPos(positions[i])
            if isPlayer(playerCheck) then
                doTeleportThing(playerCheck, positions[i].teleportBack)
            end
        end
        doTransformItem(item.uid, item.itemid - 1)
    end   
return true
end

Thanks for answering man I'll test to see how it works :)
rep+
 
Back
Top