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

Solved Cant figure out this removeitem script

Clay502

New Member
Joined
Mar 18, 2016
Messages
3
Reaction score
0
it crashes the server after 60 seconds everything else works fine, summons mobs and makes the magic wall, it just doesnt disappear... I am using TFS 0.2.11
Code:
local playerPosition = {x = 976, y = 912, z = 8}
local newPosition = {x = 967, y = 911, z = 8}
local actionid = 6555
local time = 60
mob2pos = {x=963, y=908, z=8}
mob3pos = {x=963, y=914, z=8}
mob4pos = {x=959, y=911, z=8}
wallid = 1497
wallpos = {x=958, y=911, z=8, stackpos=1}
local lvl = 100

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerLevel(cid) >= lvl then
    doCreateItem(wallid,1,wallpos)
    addEvent(doRemoveItem, time * 1000)
    doTeleportThing(cid,newPosition)
    doSummonCreature("Persian Warrior", mob2pos)
    doSummonCreature("Persian Warrior", mob3pos)
    doSummonCreature("Persian Warrior", mob4pos)
        function removewall()
        doRemoveItem(wallpos.uid,1)
        doPlayerSendTextMessage(cid, 19, "The Magic Wall has disappeared.")
        end
    else
        doPlayerSendTextMessage(cid, 19, "Sorry you need to be atleast level "..lvl.." to enter.")
    end
    return true
end
 
Okay fixed the
Code:
addEvent(doRemoveItem, time * 1000)
to
Code:
addEvent(removewall, time * 1000)
now I get this when I use the action....
Code:
[22/03/2016 15:50:20] Lua Script Error: [Action Interface] 
[22/03/2016 15:50:20] data/actions/scripts/quests/persiantrigger.lua:onUse
[22/03/2016 15:50:21] luaAddEvent(). callback parameter should be a function.
[22/03/2016 15:50:21] stack traceback:
[22/03/2016 15:50:21]     [C]: in function 'addEvent'
[22/03/2016 15:50:21]     data/actions/scripts/quests/persiantrigger.lua:15: in function <data/actions/scripts/quests/persiantrigger.lua:12>
 
because you've added a function inside a function, make the removewall function a local function and put it outside the onuse function.

Also for further reference, even if it wasn't a function, you've added it under the addEvent, therefore when the addEvent is called removewall doesn't even exist.
 
Thanks for your quick responses! Figured it out with your help, only thing I had trouble with was sending a message to them about it disappearing but I think they will figure it out cause they cant go nowhere else. Here's the final script
Code:
local playerPosition = {x = 976, y = 912, z = 8}
local newPosition = {x = 967, y = 911, z = 8}
local actionid = 6555
local time = 60
mob2pos = {x=963, y=908, z=8}
mob3pos = {x=963, y=914, z=8}
mob4pos = {x=959, y=911, z=8}
wallid = 1497
wallpos = {x=958, y=911, z=8, stackpos=1}
local lvl = 100

function removewall()
    doRemoveItem(getThingfromPos(wallpos).uid,1)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerLevel(cid) >= lvl then
    doCreateItem(wallid,1,wallpos)
    addEvent(removewall, time * 1000)
    doTeleportThing(cid,newPosition)
    doSummonCreature("Persian Warrior", mob2pos)
    doSummonCreature("Persian Warrior", mob3pos)
    doSummonCreature("Persian Warrior", mob4pos)
    else
        doPlayerSendTextMessage(cid, 19, "Sorry you need to be level "..lvl.." to enter.")
    end
    return true
end
 
Back
Top