• 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 How can I remove creature after player death?

Caduceus

Unknown Member
Joined
May 10, 2010
Messages
321
Solutions
2
Reaction score
24
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == 31299 then 
if item.itemid == 1946 then
local storage = 31300

playerpos = getPlayerPosition(cid)
player = getThingfromPos(playerpos) 
nplayerpos = {x=1169, y=1007, z=10}

if player.itemid > 0 then

playerlevel = getPlayerLevel(player.uid)

questlevel = 60

if playerlevel >= questlevel then


if getPlayerStorageValue(cid, storage) < 1 then 
	doSendMagicEffect(playerpos,2)
   			doTeleportThing(player.uid,nplayerpos)
   			doSendMagicEffect(nplayerpos,10)
   			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Hope to see you on the other side!")
   
   			
   			
   			demon1pos = {x=1173, y=993, z=10} 


        doSummonCreature("Stormblast", demon1pos)
        doTransformItem(item.uid,1945) 

 
   			else
   			doPlayerSendCancel(cid,"You Have Already Completed The Catacombs Quest.")
   			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You Have Already Completed The Catacombs Quest.")

   		
if item.itemid == 1945 then 

starting={x=1160, y=988, z=10, stackpos=253} 
checking={x=starting.x, y=starting.y, z=starting.z, stackpos=starting.stackpos} 
ending={x=1181, y=1011, z=10, stackpos=253} 
players=0 
totalmonsters=0 
monster = {} 
repeat 
creature= getThingfromPos(checking) 
if creature.itemid > 0 then 
if getPlayerAccess(creature.uid) == 0 then 
players=players+1 
end 
if getPlayerAccess(creature.uid) ~= 0 and getPlayerAccess(creature.uid) ~= 1 then 
totalmonsters=totalmonsters+1 
monster[totalmonsters]=creature.uid 
end 
end 
checking.x=checking.x+1 
if checking.x>ending.x then 
checking.x=starting.x 
checking.y=checking.y+1 
end 
until checking.y>ending.y 
if players==0 then 
trash= {x=1187, y=1013, z=10} 
current=0 
repeat 
current=current+1 
doTeleportThing(monster[current],trash) 
until current>=totalmonsters 
doTransformItem(item.uid,1946) 
end 
end
end
end
end
end
end
end
 
Last edited:
It is pretty easy to achieve however I won't be able to help you until the script is tabbed and until you are using
Lua:
[/B][B][[/B][B]/lua][/B] tags
 
did
Lua:
tags. not sure if it saved.

- - - Updated - - -

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == 31299 then 
if item.itemid == 1946 then
local storage = 31300

playerpos = getPlayerPosition(cid)
player = getThingfromPos(playerpos) 
nplayerpos = {x=1169, y=1007, z=10}

if player.itemid > 0 then

playerlevel = getPlayerLevel(player.uid)

questlevel = 60

if playerlevel >= questlevel then


if getPlayerStorageValue(cid, storage) < 1 then 
	doSendMagicEffect(playerpos,2)
   			doTeleportThing(player.uid,nplayerpos)
   			doSendMagicEffect(nplayerpos,10)
   			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Hope to see you on the other side!")
   
   			
   			
   			demon1pos = {x=1173, y=993, z=10} 


        doSummonCreature("Stormblast", demon1pos)
        doTransformItem(item.uid,1945) 

 
   			else
   			doPlayerSendCancel(cid,"You Have Already Completed The Catacombs Quest.")
   			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You Have Already Completed The Catacombs Quest.")

   		
if item.itemid == 1945 then 

starting={x=1160, y=988, z=10, stackpos=253} 
checking={x=starting.x, y=starting.y, z=starting.z, stackpos=starting.stackpos} 
ending={x=1181, y=1011, z=10, stackpos=253} 
players=0 
totalmonsters=0 
monster = {} 
repeat 
creature= getThingfromPos(checking) 
if creature.itemid > 0 then 
if getPlayerAccess(creature.uid) == 0 then 
players=players+1 
end 
if getPlayerAccess(creature.uid) ~= 0 and getPlayerAccess(creature.uid) ~= 1 then 
totalmonsters=totalmonsters+1 
monster[totalmonsters]=creature.uid 
end 
end 
checking.x=checking.x+1 
if checking.x>ending.x then 
checking.x=starting.x 
checking.y=checking.y+1 
end 
until checking.y>ending.y 
if players==0 then 
trash= {x=1187, y=1013, z=10} 
current=0 
repeat 
current=current+1 
doTeleportThing(monster[current],trash) 
until current>=totalmonsters 
doTransformItem(item.uid,1946) 
end 
end
end
end
end
end
end
end

- - - Updated - - -

sorry, not sure what tabbed means.

- - - Updated - - -

It is pretty easy to achieve however I won't be able to help you until the script is tabbed and until you are using
Lua:
[/B][B][[/B][B]/lua][/B] tags[/QUOTE]

I'm not real sure what you mean by "tabbed" care to explain?
 
add this which when you wanna remove the creature. (change xxxx for your pos

Code:
 local room = {   
        fromX = [COLOR="#FF0000"]xxxx[/COLOR],
        fromY = [COLOR="#FF0000"]xxxx[/COLOR],
        fromZ = [COLOR="#FF0000"]x[/COLOR],
        --------------
        toX = [COLOR="#FF0000"]xxxx[/COLOR],
        toY = [COLOR="#FF0000"]xxxx[/COLOR],
        toZ = [COLOR="#FF0000"]x[/COLOR]
        }


for x = room.fromX, room.toX do
        for y = room.fromY, room.toY do
        for z = room.fromZ, room.toZ do
        local pos = {x=x, y=y, z=z,stackpos = 253}
        local thing = getThingfromPos(pos, false)
        if thing.itemid > 0 then
        doRemoveCreature(thing.uid)
end end end end
 
added to script, creature is not removed

- - - Updated - - -

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.uid == 31299 then 
    if item.itemid == 1946 then
    local storage = 31300

    playerpos = getPlayerPosition(cid)
    player = getThingfromPos(playerpos) 
    nplayerpos = {x=1169, y=1007, z=10}

if player.itemid > 0 then

    playerlevel = getPlayerLevel(player.uid)

questlevel = 60

    if playerlevel >= questlevel then


if getPlayerStorageValue(cid, storage) < 1 then 
	doSendMagicEffect(playerpos,2)
				doTeleportThing(player.uid,nplayerpos)
				doSendMagicEffect(nplayerpos,10)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Hope to see you on the other side!")
	 
				
				
				demon1pos = {x=1173, y=993, z=10} 


				doSummonCreature("Stormblast", demon1pos)
				

 
				else
				doPlayerSendCancel(cid,"You Have Already Completed The Catacombs Quest.")
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You Have Already Completed The Catacombs Quest.")


 local room = {   
        fromX = 1160,
        fromY = 988,
        fromZ = 10,
        --------------
        toX = 1183,
        toY = 1012,
        toZ =10
        }


for x = room.fromX, room.toX do
        for y = room.fromY, room.toY do
        for z = room.fromZ, room.toZ do
        local pos = {x=x, y=y, z=z,stackpos = 253}
        local thing = getThingfromPos(pos, false)
        if thing.itemid > 0 then
        doRemoveCreature(thing.uid)
        
                  end
                end
              end 
            end
          end
        end
      end
    end
  end
end

- - - Updated - - -

Above script does not work, I really need some help with this. When a player dies & goes back to try again on this quest it summons another monster, which makes 2 of this same monster. I need a script that can remove said monster after player death.
 
Last edited:
You've added above in a wrong place, try this:

Lua:
 local room = {   
        fromX = 1160,
        fromY = 988,
        fromZ = 10,
        --------------
        toX = 1183,
        toY = 1012,
        toZ = 10
        }


function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.uid == 31299 then 
    if item.itemid == 1946 then
    local storage = 31300

    playerpos = getPlayerPosition(cid)
    player = getThingfromPos(playerpos) 
    nplayerpos = {x=1169, y=1007, z=10}

if player.itemid > 0 then

    playerlevel = getPlayerLevel(player.uid)

questlevel = 60

    if playerlevel >= questlevel then


if getPlayerStorageValue(cid, storage) < 1 then 
for x = room.fromX, room.toX do                  
        for y = room.fromY, room.toY do
        for z = room.fromZ, room.toZ do
        local pos = {x=x, y=y, z=z,stackpos = 253}
        local thing = getThingfromPos(pos, false)
        if thing.itemid > 0 then
        doRemoveCreature(thing.uid)
        
                  end
                end
              end 
            end
	            doSendMagicEffect(playerpos,2)
				doTeleportThing(player.uid,nplayerpos)
				doSendMagicEffect(nplayerpos,10)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Hope to see you on the other side!")
	 
				
				
				demon1pos = {x=1173, y=993, z=10} 


				doSummonCreature("Stormblast", demon1pos)
				

 
				else
				doPlayerSendCancel(cid,"You Have Already Completed The Catacombs Quest.")
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You Have Already Completed The Catacombs Quest.")






          end
        end
      end
    end
  end
return true
end
 
Last edited:
You've added above in a wrong place, try this:

Code:
 local room = {   
        fromX = 1160,
        fromY = 988,
        fromZ = 10,
        --------------
        toX = 1183,
        toY = 1012,
        toZ = 10
        }


function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.uid == 31299 then 
    if item.itemid == 1946 then
    local storage = 31300

    playerpos = getPlayerPosition(cid)
    player = getThingfromPos(playerpos) 
    nplayerpos = {x=1169, y=1007, z=10}

if player.itemid > 0 then

    playerlevel = getPlayerLevel(player.uid)

questlevel = 60

    if playerlevel >= questlevel then


if getPlayerStorageValue(cid, storage) < 1 then 
for x = room.fromX, room.toX do                  
        for y = room.fromY, room.toY do
        for z = room.fromZ, room.toZ do
        local pos = {x=x, y=y, z=z,stackpos = 253}
        local thing = getThingfromPos(pos, false)
        if thing.itemid > 0 then
        doRemoveCreature(thing.uid)
        
                  end
                end
              end 
            end
                doSendMagicEffect(playerpos,2)
                doTeleportThing(player.uid,nplayerpos)
                doSendMagicEffect(nplayerpos,10)
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Hope to see you on the other side!")
     
                
                
                demon1pos = {x=1173, y=993, z=10} 


                doSummonCreature("Stormblast", demon1pos)
                

 
                else
                doPlayerSendCancel(cid,"You Have Already Completed The Catacombs Quest.")
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You Have Already Completed The Catacombs Quest.")






          end
        end
      end
    end
  end
end

horrible tabbin DDDDD:

Lua:
 local room = {   
        fromX = 1160,
        fromY = 988,
        fromZ = 10,
        --------------
        toX = 1183,
        toY = 1012,
        toZ = 10
        }


function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.uid == 31299 and item.itemid == 1946 then
    
    local storage, playerpos, player, nplayerpos = 31300, getPlayerPosition(cid), getThingfromPos(playerpos), {x=1169, y=1007, z=10}
        if player.itemid > 0 then
            local playerlevel questlevel = getPlayerLevel(player.uid), 60
            if playerlevel >= questlevel then
                if getPlayerStorageValue(cid, storage) < 1 then 
                    for x = room.fromX, room.toX do
                        for y = room.fromY, room.toY do
                            for z = room.fromZ, room.toZ do
                                local pos, thing = {x=x, y=y, z=z,stackpos = 253}, getThingfromPos(pos, false)
                                if thing.itemid > 0 then
                                    doRemoveCreature(thing.uid)
                                end
                            end
                        end 
                    end
	            doSendMagicEffect(playerpos, 2)
                    doTeleportThing(player.uid, nplayerpos)
                    doSendMagicEffect(nplayerpos,10)
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Hope to see you on the other side!")
                    creaturepos = {x=1173, y=993, z=10} 
                    doSummonCreature("Stormblast", creaturepos)
		else
                    doPlayerSendCancel(cid, "You Have Already Completed The Catacombs Quest.")
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You Have Already Completed The Catacombs Quest.")
                end
            end
        end
    end
    return true
end
 
Last edited:
Can you explain, tabbing? I asked earlier in thread. I don't know what you mean by that.

@chriso thx ill try that when I get home. Rep+ to you for your time and patience.
 
Define Creature while creating it:
local monster = doSummonCreature("Stormblast", demon1pos)
insteat of:
doSummonCreature("Stormblast", demon1pos)

so later on you can remove by:
doRemoveCreature(monster)
 
[16/04/2013 16:09:46] Lua Script Error: [Action Interface]
[16/04/2013 16:09:46] data/actions/xxxx.lua:eek:nUse
[16/04/2013 16:09:46] attempt to index a boolean value
[16/04/2013 16:09:46] stack traceback:
[16/04/2013 16:09:46] [C]: ?
[16/04/2013 16:09:46] [C]: in function 'getThingfromPos'
[16/04/2013 16:09:46] ...cripts/actions/xxxx.lua:35: in function <...cripts/xxxx.lua:12>

- - - Updated - - -

Define Creature while creating it:
local monster = doSummonCreature("Stormblast", demon1pos)
insteat of:
doSummonCreature("Stormblast", demon1pos)

so later on you can remove by:
doRemoveCreature(monster)

How would I apply that to my script, using doRemoveCreature(cid).
 
Last edited:
ok, but this doesnt work. how can I fix it?


I get this error:

[16/04/2013 16:09:46] Lua Script Error: [Action Interface]
[16/04/2013 16:09:46] data/actions/xxxx.luanUse
[16/04/2013 16:09:46] attempt to index a boolean value
[16/04/2013 16:09:46] stack traceback:
[16/04/2013 16:09:46] [C]: ?
[16/04/2013 16:09:46] [C]: in function 'getThingfromPos'
[16/04/2013 16:09:46] ...cripts/actions/xxxx.lua:35: in function <...cripts/xxxx.lua:12>
 
This one should work (at least if you have function "doremovecreature") havent tested it.

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local storage = 31300
waittime = 10*60 -- 10 minutes

questlevel = 60

demon1pos = {x=1173, y=993, z=10} 

if item.uid == 31299 then 
	if item.itemid == 1946 then
 
playerpos = getPlayerPosition(cid)
player = getThingfromPos(playerpos) 
nplayerpos = {x=1169, y=1007, z=10}
 
		if player.itemid > 0 then
 
			playerlevel = getPlayerLevel(player.uid)
 
			if playerlevel >= questlevel then

				if getPlayerStorageValue(cid, storage) < 1 then 
					doSendMagicEffect(playerpos,2)
					doTeleportThing(player.uid,nplayerpos)
					doSendMagicEffect(nplayerpos,10)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Hope to see you on the other side!") 
 
					demon1 = doSummonCreature("Stormblast", demon1pos)
					doTransformItem(item.uid,1945)
					nexttime = os.time()+ waittime 
 
				else
					doPlayerSendCancel(cid,"You Have Already Completed The Catacombs Quest.")
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You Have Already Completed The Catacombs Quest.")
				end
			else
				doPlayerSendCancel(cid,"Your level is too low.")
			end
		else
			doPlayerSendCancel(cid,"Sorry, not possible.")
		end
	elseif item.itemid == 1945 then
		if os.time() >= nexttime then
			doTransformItem(item.uid,1946)
			if isCreature(demon1) == TRUE then
				doremovecreature(demon1)
            else
            end
		else
			waittime = nexttime - os.time()
			doPlayerSendCancel(cid,"Sorry, you need to wait " ..waittime.. " seconds.")
		end
	end
return 1
end
 
This one should work (at least if you have function "doremovecreature") havent tested it.

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local storage = 31300
waittime = 10*60 -- 10 minutes

questlevel = 60

demon1pos = {x=1173, y=993, z=10} 

if item.uid == 31299 then 
	if item.itemid == 1946 then
 
playerpos = getPlayerPosition(cid)
player = getThingfromPos(playerpos) 
nplayerpos = {x=1169, y=1007, z=10}
 
		if player.itemid > 0 then
 
			playerlevel = getPlayerLevel(player.uid)
 
			if playerlevel >= questlevel then

				if getPlayerStorageValue(cid, storage) < 1 then 
					doSendMagicEffect(playerpos,2)
					doTeleportThing(player.uid,nplayerpos)
					doSendMagicEffect(nplayerpos,10)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Hope to see you on the other side!") 
 
					demon1 = doSummonCreature("Stormblast", demon1pos)
					doTransformItem(item.uid,1945)
					nexttime = os.time()+ waittime 
 
				else
					doPlayerSendCancel(cid,"You Have Already Completed The Catacombs Quest.")
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You Have Already Completed The Catacombs Quest.")
				end
			else
				doPlayerSendCancel(cid,"Your level is too low.")
			end
		else
			doPlayerSendCancel(cid,"Sorry, not possible.")
		end
	elseif item.itemid == 1945 then
		if os.time() >= nexttime then
			doTransformItem(item.uid,1946)
			if isCreature(demon1) == TRUE then
				doremovecreature(demon1)
            else
            end
		else
			waittime = nexttime - os.time()
			doPlayerSendCancel(cid,"Sorry, you need to wait " ..waittime.. " seconds.")
		end
	end
return 1
end

summons creature, but does not remove after wait time.

[16/04/2013 17:20:43] Lua Script Error: [Action Interface]
[16/04/2013 17:20:43] data/actions/scripts/xxxx.lua:eek:nUse
[16/04/2013 17:20:43] ...cripts/xxxx.lua:47: attempt to call global 'doremovecreature' (a nil value)
[16/04/2013 17:20:43] stack traceback:
[16/04/2013 17:20:43] [C]: in function 'doremovecreature'
[16/04/2013 17:20:43] ...cripts/xxxx:47: in function <...cripts/xxxx.lua:1>
 
Last edited:
Here's an example:

Lua:
local monster = doSummonCreature("demon", {x = 100, y = 100, z = 7}) -- summon the monster 

-- # To remove the same monster after some time, do the following # --
addEvent(doRemoveCreature, 10 * 1000, monster) -- 10 seconds
 
This one should work (at least if you have function "doremovecreature") havent tested it.

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local storage = 31300
waittime = 10*60 -- 10 minutes

questlevel = 60

demon1pos = {x=1173, y=993, z=10} 

if item.uid == 31299 then 
	if item.itemid == 1946 then
 
playerpos = getPlayerPosition(cid)
player = getThingfromPos(playerpos) 
nplayerpos = {x=1169, y=1007, z=10}
 
		if player.itemid > 0 then
 
			playerlevel = getPlayerLevel(player.uid)
 
			if playerlevel >= questlevel then

				if getPlayerStorageValue(cid, storage) < 1 then 
					doSendMagicEffect(playerpos,2)
					doTeleportThing(player.uid,nplayerpos)
					doSendMagicEffect(nplayerpos,10)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Hope to see you on the other side!") 
 
					demon1 = doSummonCreature("Stormblast", demon1pos)
					doTransformItem(item.uid,1945)
					nexttime = os.time()+ waittime 
 
				else
					doPlayerSendCancel(cid,"You Have Already Completed The Catacombs Quest.")
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You Have Already Completed The Catacombs Quest.")
				end
			else
				doPlayerSendCancel(cid,"Your level is too low.")
			end
		else
			doPlayerSendCancel(cid,"Sorry, not possible.")
		end
	elseif item.itemid == 1945 then
		if os.time() >= nexttime then
			doTransformItem(item.uid,1946)
			if isCreature(demon1) == TRUE then
				doremovecreature(demon1)
            else
            end
		else
			waittime = nexttime - os.time()
			doPlayerSendCancel(cid,"Sorry, you need to wait " ..waittime.. " seconds.")
		end
	end
return 1
end

Here's an example:

Lua:
local monster = doSummonCreature("demon", {x = 100, y = 100, z = 7}) -- summon the monster 

-- # To remove the same monster after some time, do the following # --
addEvent(doRemoveCreature, 10 * 1000, monster) -- 10 seconds

Combined both , thank you to everyone that helped out. Got it to work. Rep+
 
Back
Top