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

Action/ bomb destroying wall

baalrukh

New Member
Joined
Jan 28, 2019
Messages
2
Reaction score
0
HI. I trying to make script but i have problerm, porapablt its very easy but im beginner and i need help. I try yo make script : i put barrel next to wall, and when use magical torch id(9956) Barrel explode and destroy 3 walls on positions, i Cut off some code from other script its explode, do "Puff" effect on wall but walls does nto dissapear., any help ? Thanks, //tfs 1.3

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, topos, frompos)
  
local t = {
    {x = 32543, y = 32215, z = 6, stackpos = 0},
    {x = 32544, y = 32215, z = 6, stackpos = 0},
    {x = 32545, y = 32215, z = 6, stackpos = 0}
}


    if(itemEx.uid == 65535 and itemEx.itemid == 30758) then
        for i = 1, #t do
            doremoveItem(1050, 1, t[i])
            doSendMagicEffect(t[i], 45)
        end
        doTransformItem(itemEx.uid, 1309)
        doSendMagicEffect(toPosition, CONST_ME_POFF)
    end

    return false
end
 
Last edited:
HI. I trying to make script but i have problerm, porapablt its very easy but im beginner and i need help. I try yo make script : i put barrel next to wall, and when use magical torch id(9956) Barrel explode and destroy 3 walls on positions, i Cut off some code from other script its explode, do "Puff" effect on wall but walls does nto dissapear., any help ? Thanks, //tfs 1.3

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, topos, frompos)

local t = {
    {x = 32543, y = 32215, z = 6, stackpos = 0},
    {x = 32544, y = 32215, z = 6, stackpos = 0},
    {x = 32545, y = 32215, z = 6, stackpos = 0}
}


    if(itemEx.uid == 65535 and itemEx.itemid == 30758) then
        for i = 1, #t do
            doremoveItem(1050, 1, t[i])
            doSendMagicEffect(t[i], 45)
        end
        doTransformItem(itemEx.uid, 1309)
        doSendMagicEffect(toPosition, CONST_ME_POFF)
    end

    return false
end
Maybe I can help you a different way.
First things first.. TFS 1.3 uses the below line for onUse scripts.
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
It's fine to rename these functions, if you prefer different words. The data won't change.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)

Second portion is that your remove item function is being used incorrectly. (you also aren't calling the function properly, since capitalization of the letters IS important. If you don't use the exact function name, including capitals, the script won't know what you are trying to do.)
Here's the function.
Lua:
doRemoveItem(uid[, count])
As you can see, there is one mandatory parameter, and one optional parameter.

In your code you are using 3 parameters, which don't quite fit the criteria we are looking for.
Code:
1050, which is likely the wall's itemid
1, which is likely item count you want to remove
t[i], which is the position of the item you are trying to remove.

In order to remove an item, you need to specify exactly which item you are trying to remove.
In order to do that, we need to find the uid (uniqueID) of that item.

To do that, you can use this following function, if you know Exactly where the item is going to be, including the stackpos.
In the example below, we will omit the optional count parameter, since we know walls can't stack.
Lua:
getThingFromPos(pos)
-- example
doRemoveItem(getThingFromPos(t[i]).uid)
If you don't know the exact position of the item, you can use this function.
We'll ignore the subType optional parameter, since we don't need it.
Lua:
getTileItemById(pos, itemId[, subType = -1])
-- example
doRemoveItem(getTileItemById(t[i], 1050).uid)

Hope that helps!
 
Back
Top