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

Lua Code error

RinQ

New Member
Joined
Nov 4, 2010
Messages
10
Reaction score
0
Hello. I write that code myself and my tfs (8.6) show me the error:

Code:
[01/07/2015 13:20:22] [Error - TalkAction Interface]
[01/07/2015 13:20:22] In a timer event called from:
[01/07/2015 13:20:22] data/talkactions/scripts/do mapy/magecamp.lua:onSay
[01/07/2015 13:20:22] Description:
[01/07/2015 13:20:22] (luaDoTeleportThing) Thing not found

How can i solve this? (Script running correctly, but i dont want any error)

Fully code (yea, i know - length :D ):

Code:
function onSay(cid, words, param)

enableSleep(function()

tile1 = {x = 858, y = 888, z = 6}
tile2 = {x = 866, y = 889, z = 6}
tile3 = {x = 866, y = 888, z = 6}
tile4 = {x = 858, y = 889, z = 6}
zapadnia = {x = 862, y = 888, z = 7}

pos = getPlayerPosition(cid)
pos11 = {x = 865, y = 888, z = 6, stackpos = 1}
pos21 = {x = 864, y = 888, z = 6, stackpos = 1}
pos31 = {x = 863, y = 888, z = 6, stackpos = 1}
pos41 = {x = 862, y = 888, z = 6, stackpos = 1}
pos51 = {x = 861, y = 888, z = 6, stackpos = 1}
pos61 = {x = 860, y = 888, z = 6, stackpos = 1}
pos71 = {x = 859, y = 888, z = 6, stackpos = 1}

pos12 = {x = 865, y = 889, z = 6, stackpos = 1}
pos22 = {x = 864, y = 889, z = 6, stackpos = 1}
pos32 = {x = 863, y = 889, z = 6, stackpos = 1}
pos42 = {x = 862, y = 889, z = 6, stackpos = 1}
pos52 = {x = 861, y = 889, z = 6, stackpos = 1}
pos62 = {x = 860, y = 889, z = 6, stackpos = 1}
pos72 = {x = 859, y = 889, z = 6, stackpos = 1}

if pos.x == tile1.x and pos.y == tile1.y and pos.z == tile1.z then
zmienna = 1
elseif pos.x == tile2.x and pos.y == tile2.y and pos.z == tile2.z then
zmienna = 2
elseif pos.x == tile3.x and pos.y == tile3.y and pos.z == tile3.z then
zmienna = 3
elseif pos.x == tile4.x and pos.y == tile4.y and pos.z == tile4.z then
zmienna = 4
else
zmienna = 0
end

if zmienna ~= 0 then
doCreateItem(1284,1,pos11)
doCreateItem(1284,1,pos21)
doCreateItem(1284,1,pos31)
doCreateItem(1284,1,pos41)
doCreateItem(1284,1,pos51)
doCreateItem(1284,1,pos61)
doCreateItem(1284,1,pos71)
doCreateItem(1284,1,pos12)
doCreateItem(1284,1,pos22)
doCreateItem(1284,1,pos32)
doCreateItem(1284,1,pos42)
doCreateItem(1284,1,pos52)
doCreateItem(1284,1,pos62)
doCreateItem(1284,1,pos72)
doSendMagicEffect(getPlayerPosition(cid), 12)
sleep(4000)
gpos11 = getThingfromPos(pos11)
gpos21 = getThingfromPos(pos21)
gpos31 = getThingfromPos(pos31)
gpos41 = getThingfromPos(pos41)
gpos51 = getThingfromPos(pos51)
gpos61 = getThingfromPos(pos61)
gpos71 = getThingfromPos(pos71)
gpos12 = getThingfromPos(pos12)
gpos22 = getThingfromPos(pos22)
gpos32 = getThingfromPos(pos32)
gpos42 = getThingfromPos(pos42)
gpos52 = getThingfromPos(pos52)
gpos62 = getThingfromPos(pos62)
gpos72 = getThingfromPos(pos72)


doTeleportThing(gpos11.uid, zapadnia, true)
doTeleportThing(gpos21.uid, zapadnia, true)
doTeleportThing(gpos31.uid, zapadnia, true)
doTeleportThing(gpos41.uid, zapadnia, true)
doTeleportThing(gpos51.uid, zapadnia, true)
doTeleportThing(gpos61.uid, zapadnia, true)
doTeleportThing(gpos71.uid, zapadnia, true)
doTeleportThing(gpos12.uid, zapadnia, true)
doTeleportThing(gpos22.uid, zapadnia, true)
doTeleportThing(gpos32.uid, zapadnia, true)
doTeleportThing(gpos42.uid, zapadnia, true)
doTeleportThing(gpos52.uid, zapadnia, true)
doTeleportThing(gpos62.uid, zapadnia, true)
doTeleportThing(gpos72.uid, zapadnia, true)


doCleanTile(pos11,false)
doCleanTile(pos21,false)
doCleanTile(pos31,false)
doCleanTile(pos41,false)
doCleanTile(pos51,false)
doCleanTile(pos61,false)
doCleanTile(pos71,false)
doCleanTile(pos12,false)
doCleanTile(pos22,false)
doCleanTile(pos32,false)
doCleanTile(pos42,false)
doCleanTile(pos52,false)
doCleanTile(pos62,false)
doCleanTile(pos72,false)

doCreateItem(12661,1,pos11)
doCreateItem(12661,1,pos21)
doCreateItem(12661,1,pos31)
doCreateItem(12661,1,pos41)
doCreateItem(12661,1,pos51)
doCreateItem(12661,1,pos61)
doCreateItem(12661,1,pos71)
doCreateItem(12661,1,pos12)
doCreateItem(12661,1,pos22)
doCreateItem(12661,1,pos32)
doCreateItem(12661,1,pos42)
doCreateItem(12661,1,pos52)
doCreateItem(12661,1,pos62)
doCreateItem(12661,1,pos72)
doSendMagicEffect(getPlayerPosition(cid), 12)
else
doPlayerSendCancel(cid,"Something wrong.")
end
end)
end

Code have 4 steps:
1. on say create drawbridge
after 4 seconds:
2.if sth lie on the drawbridge, they are teleported floor below
3. if in 1 tile lie more than 1 item rest are deleted
4. if player miss -> fall down

Help me please.
 
Code:
gpos11 = getThingfromPos(pos11)
.
.
.
doTeleportThing(gpos11.uid, zapadnia, true)
When you check to find what is on the tile, you never actually check if something is there. This is where the error is occurring (most likely more then once). Check the tile for a player before returning the teleport function for each tile, and you'll no longer have the error.

Cheers,

Xikini
 
Last edited:
Try this.
Code:
function onSay(cid, words, param)

   enableSleep(function()

     tile1 = {x = 858, y = 888, z = 6}
     tile2 = {x = 866, y = 889, z = 6}
     tile3 = {x = 866, y = 888, z = 6}
     tile4 = {x = 858, y = 889, z = 6}
     zapadnia = {x = 862, y = 888, z = 7}
     
     pos = getPlayerPosition(cid)
     
     local locations = {
       [1] = {x = 865, y = 888, z = 6, stackpos = 1},
       [2] = {x = 864, y = 888, z = 6, stackpos = 1},
       [3] = {x = 863, y = 888, z = 6, stackpos = 1},
       [4] = {x = 862, y = 888, z = 6, stackpos = 1},
       [5] = {x = 861, y = 888, z = 6, stackpos = 1},
       [6] = {x = 860, y = 888, z = 6, stackpos = 1},
       [7] = {x = 859, y = 888, z = 6, stackpos = 1},
       
       [8] = {x = 865, y = 889, z = 6, stackpos = 1},
       [9] = {x = 864, y = 889, z = 6, stackpos = 1},
       [10] = {x = 863, y = 889, z = 6, stackpos = 1},
       [11] = {x = 862, y = 889, z = 6, stackpos = 1},
       [12] = {x = 861, y = 889, z = 6, stackpos = 1},
       [13] = {x = 860, y = 889, z = 6, stackpos = 1},
       [14] = {x = 859, y = 889, z = 6, stackpos = 1}
     }
     
     if pos.x == tile1.x and pos.y == tile1.y and pos.z == tile1.z then
       zmienna = 1
     elseif pos.x == tile2.x and pos.y == tile2.y and pos.z == tile2.z then
       zmienna = 2
     elseif pos.x == tile3.x and pos.y == tile3.y and pos.z == tile3.z then
       zmienna = 3
     elseif pos.x == tile4.x and pos.y == tile4.y and pos.z == tile4.z then
       zmienna = 4
     else
       zmienna = 0
     end
     
     if zmienna ~= 0 then
       for i = 1, #locations do
         doCreateItem(1284,1,locations[i])
       end
       doSendMagicEffect(getPlayerPosition(cid), 12)
       sleep(4000)
       for i = 1, #locations do
         if getThingfromPos[i] > 0 then
           doRelocate(locations[i], zapadnia)
         end
       end
       doCleanTile(zapadnia,false)
       for i = 1, #locations do
         doCreateItem(12661,1,locations[i])
       end
       doSendMagicEffect(getPlayerPosition(cid), 12)
     else
       doPlayerSendCancel(cid,"Something wrong.")
     end
   end)
   return true
end
 
Back
Top