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

Solved Delete/Create

Mera Mero

Guess Who?
Joined
Dec 27, 2014
Messages
417
Reaction score
86
Hi otlanders i've got problem with script that remove wall by killing monsters and this wall will appear after x time and i have this working good with one wall only and now i tried to edit to to remove 2 walls but got some errors
death.lua
Code:
function onDeath(cid, corpse, killer)

local M ={
["Serpent Spawn"] = {Pos = {x=983,y=994,z=7},id= 1060 ,Pos2 = {x=990,y=992,z=7},id2= 5009 ,time = 30},
}

local x = M[getCreatureName(cid)]
function criar()
local parede = getTileItemById(x.Pos, x.id, x.Pos2, x.id2)
doCreateItem(x.id, 1, x.Pos)
doCreateItem(x.id2, 1, x.Pos2)
end
if x then
local parede = getTileItemById(x.Pos, x.id, x.Pos2, x.id2)
if parede then
doRemoveItem(parede.uid, 1)
doRemoveItem(parede.uid, 1)
doCreatureSay(cid, "The wall will appears in "..x.time.." seconds.", TALKTYPE_ORANGE_1)
addEvent(criar, x.time*1000)
end
end
return TRUE
end
and this is error got it when monster died and i couldn't find his corpse
Code:
[03/03/2015 01:51:48] [Error - CreatureScript Interface]
[03/03/2015 01:51:48] data/creaturescripts/scripts/death.lua:onDeath
[03/03/2015 01:51:48] Description:
[03/03/2015 01:51:48] attempt to index a number value
[03/03/2015 01:51:48] stack traceback:
[03/03/2015 01:51:48]     [C]: in function 'getTileItemById'
[03/03/2015 01:51:48]     data/creaturescripts/scripts/death.lua:14: in function <data/creaturescripts/scripts/death.lua:1>
TFS 0.3.6
 
try this .. not tested
Code:
function onDeath(cid, corpse, killer)

local M ={
["Serpent Spawn"] = {{Pos = {x=983,y=994,z=7}, {x=990,y=992,z=7}},{id= 1060,5009},
}

local x = M[getCreatureName(cid)]
function criar()
local parede = getTileItemById(x.Pos, x.id, x.Pos2, x.id2)
doCreateItem(x.id[i], 1, x.Pos[i])
end
if x then
local parede = getTileItemById(x.Pos[i], x.id[i])
if parede then
doRemoveItem(parede.uid, 1)
doCreatureSay(cid, "The wall will appears in "..x.time.." seconds.", TALKTYPE_ORANGE_1)
addEvent(criar, x.time*1000)
end
end
return TRUE
end
 
try this .. not tested
Code:
function onDeath(cid, corpse, killer)

local M ={
["Serpent Spawn"] = {{Pos = {x=983,y=994,z=7}, {x=990,y=992,z=7}},{id= 1060,5009},
}

local x = M[getCreatureName(cid)]
function criar()
local parede = getTileItemById(x.Pos, x.id, x.Pos2, x.id2)
doCreateItem(x.id[i], 1, x.Pos[i])
end
if x then
local parede = getTileItemById(x.Pos[i], x.id[i])
if parede then
doRemoveItem(parede.uid, 1)
doCreatureSay(cid, "The wall will appears in "..x.time.." seconds.", TALKTYPE_ORANGE_1)
addEvent(criar, x.time*1000)
end
end
return TRUE
end
Code:
[03/03/2015 02:32:25] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/KillMonster 2.lua:7: '}' expected (to close '{' at line 3) near 'local'
[03/03/2015 02:32:25] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/KillMonster 2.lua)
[03/03/2015 02:32:25] data/creaturescripts/scripts/KillMonster 2.lua:7: '}' expected (to close '{' at line 3) near 'local'
found this error
 
ah srry forgot to add one more } xD
here you are
Code:
function onDeath(cid, corpse, killer)

local M ={
["Serpent Spawn"] = {{Pos = {x=983,y=994,z=7}, {x=990,y=992,z=7}},{id= 1060,5009},
}}

local x = M[getCreatureName(cid)]
function criar()
local parede = getTileItemById(x.Pos, x.id, x.Pos2, x.id2)
doCreateItem(x.id[i], 1, x.Pos[i])
end
if x then
local parede = getTileItemById(x.Pos[i], x.id[i])
if parede then
doRemoveItem(parede.uid, 1)
doCreatureSay(cid, "The wall will appears in "..x.time.." seconds.", TALKTYPE_ORANGE_1)
addEvent(criar, x.time*1000)
end
end
return TRUE
end
 
ah srry forgot to add one more } xD
here you are
Code:
function onDeath(cid, corpse, killer)

local M ={
["Serpent Spawn"] = {{Pos = {x=983,y=994,z=7}, {x=990,y=992,z=7}},{id= 1060,5009},
}}

local x = M[getCreatureName(cid)]
function criar()
local parede = getTileItemById(x.Pos, x.id, x.Pos2, x.id2)
doCreateItem(x.id[i], 1, x.Pos[i])
end
if x then
local parede = getTileItemById(x.Pos[i], x.id[i])
if parede then
doRemoveItem(parede.uid, 1)
doCreatureSay(cid, "The wall will appears in "..x.time.." seconds.", TALKTYPE_ORANGE_1)
addEvent(criar, x.time*1000)
end
end
return TRUE
end
Found this error :S
Code:
[03/03/2015 12:01:33] [Error - CreatureScript Interface]
[03/03/2015 12:01:34] data/creaturescripts/scripts/KillMonster 2.lua:onDeath
[03/03/2015 12:01:34] Description:
[03/03/2015 12:01:34] data/creaturescripts/scripts/KillMonster 2.lua:13: attempt to index field 'Pos' (a nil value)
[03/03/2015 12:01:34] stack traceback:
[03/03/2015 12:01:34]     data/creaturescripts/scripts/KillMonster 2.lua:13: in function <data/creaturescripts/scripts/KillMonster 2.lua:1>
 
Found this error :S
Code:
[03/03/2015 12:01:33] [Error - CreatureScript Interface]
[03/03/2015 12:01:34] data/creaturescripts/scripts/KillMonster 2.lua:onDeath
[03/03/2015 12:01:34] Description:
[03/03/2015 12:01:34] data/creaturescripts/scripts/KillMonster 2.lua:13: attempt to index field 'Pos' (a nil value)
[03/03/2015 12:01:34] stack traceback:
[03/03/2015 12:01:34]     data/creaturescripts/scripts/KillMonster 2.lua:13: in function <data/creaturescripts/scripts/KillMonster 2.lua:1>
srry honey i forgot to edit getTileByItemID xD
try this
Code:
function onDeath(cid, corpse, killer)

local M ={
["Serpent Spawn"] = {{Pos = {x=983,y=994,z=7}, {x=990,y=992,z=7}},{id= 1060,5009},
}}

local x = M[getCreatureName(cid)]
function criar()
local parede = getTileItemById(x.Pos[i], x.id[i])
doCreateItem(x.id[i], 1, x.Pos[i])
end
if x then
local parede = getTileItemById(x.Pos[i], x.id[i])
if parede then
doRemoveItem(parede.uid, 1)
doCreatureSay(cid, "The wall will appears in "..x.time.." seconds.", TALKTYPE_ORANGE_1)
addEvent(criar, x.time*1000)
end
end
return TRUE
end
 
srry honey i forgot to edit getTileByItemID xD
try this
Code:
function onDeath(cid, corpse, killer)

local M ={
["Serpent Spawn"] = {{Pos = {x=983,y=994,z=7}, {x=990,y=992,z=7}},{id= 1060,5009},
}}

local x = M[getCreatureName(cid)]
function criar()
local parede = getTileItemById(x.Pos[i], x.id[i])
doCreateItem(x.id[i], 1, x.Pos[i])
end
if x then
local parede = getTileItemById(x.Pos[i], x.id[i])
if parede then
doRemoveItem(parede.uid, 1)
doCreatureSay(cid, "The wall will appears in "..x.time.." seconds.", TALKTYPE_ORANGE_1)
addEvent(criar, x.time*1000)
end
end
return TRUE
end
:( error again
Code:
[03/03/2015 17:08:12] [Error - CreatureScript Interface]
[03/03/2015 17:08:13] data/creaturescripts/scripts/KillMonster 2.lua:onDeath
[03/03/2015 17:08:13] Description:
[03/03/2015 17:08:13] data/creaturescripts/scripts/KillMonster 2.lua:13: attempt to index field 'Pos' (a nil value)
[03/03/2015 17:08:13] stack traceback:
[03/03/2015 17:08:13]     data/creaturescripts/scripts/KillMonster 2.lua:13: in function <data/creaturescripts/scripts/KillMonster 2.lua:1>
 
:( error again
Code:
[03/03/2015 17:08:12] [Error - CreatureScript Interface]
[03/03/2015 17:08:13] data/creaturescripts/scripts/KillMonster 2.lua:onDeath
[03/03/2015 17:08:13] Description:
[03/03/2015 17:08:13] data/creaturescripts/scripts/KillMonster 2.lua:13: attempt to index field 'Pos' (a nil value)
[03/03/2015 17:08:13] stack traceback:
[03/03/2015 17:08:13]     data/creaturescripts/scripts/KillMonster 2.lua:13: in function <data/creaturescripts/scripts/KillMonster 2.lua:1>

w8 i make it and test it
i have no error . but is also no effect xD
 
@Limos any tips xD
i don't get error , but nothing happen when i kill monster :(
Code:
function onDeath(cid, corpse, killer)

local M ={
["Serpent Spawn"] = {{Pos = {x=983,y=994,z=7}, {x=990,y=992,z=7}},{id= 1060,5009},{time = 30}
}}

local x = M[getCreatureName(cid)]
function criar()
local parede = getTileItemById(x.Pos[i], x.id[i])
doCreateItem(x.id[i], 1, x.Pos[i])
end
if x then
local parede = getTileItemById(x.Pos[i], x.id[i])
if parede then
doRemoveItem(parede.uid, 1)
doCreatureSay(cid, "The wall will appears in "..x.time.." seconds.", TALKTYPE_ORANGE_1)
addEvent(criar, x.time*1000)
end
end
return TRUE
end
 
@Limos any tips xD
i don't get error , but nothing happen when i kill monster :(
Code:
function onDeath(cid, corpse, killer)

local M ={
["Serpent Spawn"] = {{Pos = {x=983,y=994,z=7}, {x=990,y=992,z=7}},{id= 1060,5009},{time = 30}
}}

local x = M[getCreatureName(cid)]
function criar()
local parede = getTileItemById(x.Pos[i], x.id[i])
doCreateItem(x.id[i], 1, x.Pos[i])
end
if x then
local parede = getTileItemById(x.Pos[i], x.id[i])
if parede then
doRemoveItem(parede.uid, 1)
doCreatureSay(cid, "The wall will appears in "..x.time.." seconds.", TALKTYPE_ORANGE_1)
addEvent(criar, x.time*1000)
end
end
return TRUE
end
LoL we are 2 now need help with this script ahahha
 
Code:
local c = {
   {id = 1060, pos = {x = 983, y = 994, z = 7}},
   {id = 5009, pos = {x = 990, y = 992, z = 7}}
}

function onDeath(cid, corpse, killer)
     for x = 1, #c do
         local parede = getTileItemById(c[x].pos, c[x].id).uid
         if parede > 0 then
             doRemoveItem(parede, 1)
             addEvent(doCreateItem, 30 * 1000, c[x].id, 1, c[x].pos)
         end
     end
     doCreatureSay(cid, "The walls will appear again in 30 seconds.", TALKTYPE_ORANGE_1)
     return true
end

If the script should work for more monsters with different items/positions (you can add more in the table)
Code:
local c = {
   ["serpent spawn"] = {
     {id = 1060, pos = {x = 983, y = 994, z = 7}},
     {id = 5009, pos = {x = 990, y = 992, z = 7}}
   }
}

function onDeath(cid, corpse, killer)
     local m = c[getCreatureName(cid):lower()]
     for x = 1, #m do
         local parede = getTileItemById(m[x].pos, m[x].id).uid
         if parede > 0 then
             doRemoveItem(parede, 1)
             addEvent(doCreateItem, 30 * 1000, m[x].id, 1, m[x].pos)
         end
     end
     doCreatureSay(cid, "The walls will appear again in 30 seconds.", TALKTYPE_ORANGE_1)
     return true
end
 
Code:
local c = {
   {id = 1060, pos = {x = 983, y = 994, z = 7}},
   {id = 5009, pos = {x = 990, y = 992, z = 7}},
}

function onDeath(cid, corpse, killer)
     for x = 1, #c do
         local parede = getTileItemById(c[x].pos, c[x].id).uid
         if parede > 0 then
             doRemoveItem(parede, 1)
             addEvent(doCreateItem, 30 * 1000, c[x].id, 1, c[x].pos)
         end
     end
     doCreatureSay(cid, "The walls will appear again in 30 seconds.", TALKTYPE_ORANGE_1)
     return true
end
Oh thanks but may you make time for every wall? Like this
["Dragon Lord"] = {Pos = {x=988,y=992,z=7},id= 9290 ,time = 30}
 
@Limos
That's what i made and its worked only with one wall and another one got error on it
Code:
local c = {
   ["serpent spawn"] = {
     {id = 1060, pos = {x = 983, y = 994, z = 7},time = 30},
     {id = 1060, pos = {x = 983, y = 992, z = 7},time = 30}
   }
}

function onDeath(cid, corpse, killer)
     local m = c[getCreatureName(cid):lower()]
     for x = 1, #m do
         local parede = getTileItemById(m[x].pos, m[x].id).uid
         if parede > 0 then
             doRemoveItem(parede, 1)
             addEvent(doCreateItem, m.time*1000, m[x].id, 1, m[x].pos)
         end
     end
     doCreatureSay(cid, "The walls will appear again in 30 seconds.", TALKTYPE_ORANGE_1)
     return true
end
Error Btw Wall, which disappeared did not appear again
Code:
[06/03/2015 23:44:36] [Error - CreatureScript Interface]
[06/03/2015 23:44:37] data/creaturescripts/scripts/KillMonster 2.lua:onDeath
[06/03/2015 23:44:37] Description:
[06/03/2015 23:44:37] data/creaturescripts/scripts/KillMonster 2.lua:14: attempt to perform arithmetic on field 'time' (a nil value)
[06/03/2015 23:44:37] stack traceback:
[06/03/2015 23:44:37]     data/creaturescripts/scripts/KillMonster 2.lua:14: in function <data/creaturescripts/scripts/KillMonster 2.lua:8>
 
If you add it there, use: m[x].time
Thanks its working good now but when i tried to make different time between each wall i found that only one wall is working
Code:
local c = {
   ["serpent spawn"] = {
     {id = 1060, pos = {x = 983, y = 994, z = 7},time = 30},
     {id = 1060, pos = {x = 983, y = 992, z = 7},time = 50}
   }
}

function onDeath(cid, corpse, killer)
     local m = c[getCreatureName(cid):lower()]
     for x = 1, #m do
         local parede = getTileItemById(m[x].pos, m[x].id).uid
         if parede > 0 then
             doRemoveItem(parede, 1)
             addEvent(doCreateItem, m[x].time*1000, m[x].id, 1, m[x].pos)
         end
     end
     doCreatureSay(cid, "The walls will appear again "..m[x].time.." seconds.", TALKTYPE_ORANGE_1)
     return true
end
Like this 30 seconds for first one and 50 seconds for second one but only first wall who appeared not both
 
You can't use m[x].time outside the loop, since you have different time for both walls you could just change the message to something like ""The walls will appear again after some time".
 
@Limos
Sorry but i found this error when i killed player on server :(
Code:
[08/03/2015 00:13:19] [Error - CreatureScript Interface]
[08/03/2015 00:13:19] data/creaturescripts/scripts/KillMonster 2.lua:onDeath
[08/03/2015 00:13:19] Description:
[08/03/2015 00:13:19] data/creaturescripts/scripts/KillMonster 2.lua:14: attempt to get length of local 'm' (a nil value)
[08/03/2015 00:13:19] stack traceback:
[08/03/2015 00:13:19]     data/creaturescripts/scripts/KillMonster 2.lua:14: in function <data/creaturescripts/scripts/KillMonster 2.lua:12>
 
Back
Top