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

Remove creature

Elaney

Member
Joined
Jan 1, 2009
Messages
1,561
Reaction score
12
Location
Sweden
I need help to create something that removes an Creature/Monster. when pulled an lever.

like if u stand in

from x, y, z
to x, y, z

i want the script to remove 1 monster in it.

bump
 
Last edited by a moderator:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
doRemoveCreature(getThingfromPos({x=EDIT, y=EDIT, z=EDIT, stackpos = 253}.uid)
return true
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local from = {x = 1234, y = 1234, z = 7}
    local to = {x = 1234, y = 1234, z = 7}
    for x = from.x, to.x do
        for y = from.y, to.y do
            for z = from.z, to.z do
                pos = {x = x, y = y, z = z, stackpos = 253}
                doRemoveCreature(getThingfromPos(pos.uid))
                doTransformItem(item.uid, item.itemid+1)
            end
        end
    end
return true
end
test that one
 
LUA:
description:
attempt to index a nil value
stack traceback:
[c]: in function 'getThingFromPos'
data/bla/bla/bla.lua:8: in fuction data/bla/bla/bla/bla/bla.lua:1>
 
LUA:
doRemoveCreature(getThingfromPos(pos.uid))
That line to this:
LUA:
doRemoveCreature(getThingfromPos(pos).uid)
 
Because I think you're in the x, y, z position.

doRemoveCreature(isMonster(getThingfromPos(pos).uid))

Idk, just a thought, don't think that is the fix, I'm just totally guessing since I don't exactly know how to remove any creature in x, y, z and ignore players.
 
Add your fix, which I dont know which it is, but it should be something like this:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local from = {x = 1234, y = 1234, z = 7}
    local to = {x = 1234, y = 1234, z = 7}
    for x = from.x, to.x do
        for y = from.y, to.y do
            for z = from.z, to.z do
                pos = {x = x, y = y, z = z, stackpos = 253}
                v = getThingfromPos(pos).uid
                if isMonster(v) then
                   doRemoveCreature(v)
                end
            end
        end
    end
return true
end
Try it.
 
here you go:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local from = {x = 1234, y = 1234, z = 7}
    local to = {x = 1234, y = 1234, z = 7}
    local monster = "Demon"
    for x = from.x, to.x do
        for y = from.y, to.y do
            for z = from.z, to.z do
                pos = {x = x, y = y, z = z, stackpos = 253}
                v = getThingfromPos(pos).uid
                if isMonster(v) and getCreatureName(v) == monster then
                   doRemoveCreature(v)
                end
            end
        end
    end
return true
end
just change the Demon inside the " " to the name of the monster you want
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local from = {x = 779, y = 805, z = 5}
    local to = {x = 788, y = 814, z = 5}
	local monster = "bosse"
	if item.itemid == 1945 then
            for x = from.x, to.x do
                  for y = from.y, to.y do
                      for z = from.z, to.z do
                          pos = {x = x, y = y, z = z, stackpos = 253}
                          v = getThingfromPos(pos).uid
                         if isMonster(v) and getCreatureName(v) == monster then
                         doRemoveCreature(v)
	                 doTransformItem(item.uid, 1946)
                   end
		end
            end
        end
    end
return true
end

yepp
 
Last edited:
Then I don't know I too always have problems with that function (same errors alot) so guess you'll have to wait till someone more experienced comes.
 
Might help.

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local from = {x = 1234, y = 1234, z = 7}
    local to = {x = 1234, y = 1234, z = 7}
    local monster = "Demon"
    for x = from.x, to.x do
        for y = from.y, to.y do
            for z = from.z, to.z do
                pos = {x = x, y = y, z = z, stackpos = 253}
                v = getThingfromPos(pos).uid
                if isMonster(v) and getCreatureName(v):lower() == monster:lower() then
                   doRemoveCreature(v)
                end
            end
        end
    end
return true
end
 
Back
Top