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

[onDeath] remove item from corpse

BeniS

Advanced OT User
Senator
Joined
Aug 8, 2009
Messages
1,850
Reaction score
189
Location
New Zealand
I need a script for Mystic Spirit 0.2.5 that removes a certain item from the player that has just died, if that item is in the backpack.

nvm I got it working perfectly :)

YUS GOT IT!:
LUA:
  local bodycontainer = {}
local bagItems = {}
local containerSize = getContainerSize(corpse)

  for count = 0, containerSize-1 do
   bodycontainer[count] = getContainerItem(corpse, count)
    if bodycontainer[count].itemid == 2345 then
       doRemoveItem(bodycontainer[count].uid, 1)
    end
    if isItemContainer(bodycontainer[count].itemid) == TRUE then
      doRemoveBagItems(bodycontainer[count].uid)
    end

    if bodycontainer[count].itemid == 7726 then
       doRemoveItem(bodycontainer[count].uid, 1)
    end
    if isItemContainer(bodycontainer[count].itemid) == TRUE then
      doRemoveBagItems(bodycontainer[count].uid)
    end

    if bodycontainer[count].itemid == 8694 then
       doRemoveItem(bodycontainer[count].uid, 1)
    end
    if isItemContainer(bodycontainer[count].itemid) == TRUE then
      doRemoveBagItems(bodycontainer[count].uid)
    end
  end


function doRemoveBagItems(bag)
local itemsInBag = {}
local bagSize = getContainerSize(bag)

  for bagcount = 0, bagSize-1 do
   itemsInBag[bagcount] = getContainerItem(bag, bagcount)
  end

   for bagcount = 0, bagSize-1 do
      if itemsInBag[bagcount].itemid == 2345 then
        doRemoveItem(itemsInBag[bagcount].uid, 1)
      end
      if itemsInBag[bagcount].itemid == 7726 then
        doRemoveItem(itemsInBag[bagcount].uid, 1)
      end
      if itemsInBag[bagcount].itemid == 8694 then
        doRemoveItem(itemsInBag[bagcount].uid, 1)
      end
   end

   for bagcount = 0, bagSize-1 do
     itemsInBag[bagcount] = getContainerItem(bag, bagcount)
   end

   for bagcount = 0, bagSize-1 do
     itemsInBag[bagcount] = getContainerItem(bag, bagcount)
        if isItemContainer(itemsInBag[bagcount].itemid) == TRUE then
          doRemoveBagItems(itemsInBag[bagcount].uid)
        end
   end
end

Regards,
Maaav
 
Last edited:
I need a script for Mystic Spirit 0.2.5 that removes a certain item from the player that has just died, if that item is in the backpack.

I have tried a number of my own made commands but I haven't had any luck with it. If someone could help me with this it would be great!

Heres what I tried first:
LUA:
repeat
      doRemoveItem(corpse, 2345)
      doPlayerRemoveItem(cid, 2345, 1)
until(getPlayerItemCount(corpse.uid, 2345) ~=1)

repeat
      doRemoveItem(corpse, 7726)
      doPlayerRemoveItem(cid, 7726, 1)
until(getPlayerItemCount(corpse.uid, 7726) ~=1)

repeat
      doRemoveItem(corpse, 8694)
      doPlayerRemoveItem(cid, 8694, 1)
until(getPlayerItemCount(corpse.uid, 8694) ~=1)

Regards,
Maaav

what about the charges= 1 attribute
 
loop with 0, getContainerSize-1 and getContainerItem in the loop

YUS I was up to like 2am getting this code working haha and finally got it ;]

LUA:
local bodycontainer = {}
local bagItems = {}
local containerSize = getContainerSize(corpse)

  for count = 0, containerSize-1 do
   bodycontainer[count] = getContainerItem(corpse, count)
    if bodycontainer[count].itemid == 2345 then
       doRemoveItem(bodycontainer[count].uid, 1)
    end
    if isItemContainer(bodycontainer[count].itemid) == TRUE then
      doRemoveBagItems(bodycontainer[count].uid)
    end

    if bodycontainer[count].itemid == 7726 then
       doRemoveItem(bodycontainer[count].uid, 1)
    end
    if isItemContainer(bodycontainer[count].itemid) == TRUE then
      doRemoveBagItems(bodycontainer[count].uid)
    end

    if bodycontainer[count].itemid == 8694 then
       doRemoveItem(bodycontainer[count].uid, 1)
    end
    if isItemContainer(bodycontainer[count].itemid) == TRUE then
      doRemoveBagItems(bodycontainer[count].uid)
    end
  end


function doRemoveBagItems(bag)
local itemsInBag = {}
local bagSize = getContainerSize(bag)

  for bagcount = 0, bagSize-1 do
   itemsInBag[bagcount] = getContainerItem(bag, bagcount)
  end

   for bagcount = 0, bagSize-1 do
      if itemsInBag[bagcount].itemid == 2345 then
	doRemoveItem(itemsInBag[bagcount].uid, 1)
      end
      if itemsInBag[bagcount].itemid == 7726 then
	doRemoveItem(itemsInBag[bagcount].uid, 1)
      end
      if itemsInBag[bagcount].itemid == 8694 then
	doRemoveItem(itemsInBag[bagcount].uid, 1)
      end
   end

   for bagcount = 0, bagSize-1 do
     itemsInBag[bagcount] = getContainerItem(bag, bagcount)
   end

   for bagcount = 0, bagSize-1 do
     itemsInBag[bagcount] = getContainerItem(bag, bagcount)
	if isItemContainer(itemsInBag[bagcount].itemid) == TRUE then
	  doRemoveBagItems(itemsInBag[bagcount].uid)
	end
   end
end
 
Exactly what I had in mind! :D
Not sure how deep does it search in containers, though.

I goes through every backpack thats in the corpse :) i made it check each bp slot and if it runs into a container again then it executes the removeBagItems function untill all bags have been searched through :P works perfectly
 
Shouldn't it be:
Code:
for i = 1, getContainerSize(corpse) do
	if (getContainerItem(corpse[i]).itemid == 6666) then
		doRemoveItem(getContainerItem(corpse[i]).uid)
	end
end
? xd
 
Ah, sry xD
I didn't read the whole thread.

Code:
for i = 1, getContainerSize(corpse) do
	local now = getContainerItem(corpse[i])
	if (now.itemid == backpack id) then
		for i = 1, getContainerSize(now.uid) do
			-- w00t w00t ? :D
		end
	end
end

Maybe? :d
 
Ah, sry xD
I didn't read the whole thread.

Code:
for i = 1, getContainerSize(corpse) do
	local now = getContainerItem(corpse[i])
	if (now.itemid == backpack id) then
		for i = 1, getContainerSize(now.uid) do
			-- w00t w00t ? :D
		end
	end
end

Maybe? :d

I got it working properly already :p

thx tho
 
I need a script that prevents drope certain items, even for red skulls.
If the player dies will not lose items? You help?

local BlokedItens {2001, 2002, 2003, 2004, 2005, 2006}



for death (remove BlokedItens)
LUA:
function onDeath(cid, corpse)
local item1 = doPlayerItemCount(cid, 2001)
local item2 = doPlayerItemCount(cid, 2002)
local item3 = doPlayerItemCount(cid, 2003)
local allItens = (doPlayerItemCount(cid, 2001) + doPlayerItemCount(cid, 2002) + doPlayerItemCount(cid, 2003))
if item1 >= 1 then 
setPlayerStorageValue(cid, 1111, item1)
doPlayerRemoveItem(cid, 2001, item1) 
doCreatureSay(cid, "".. allItens .." Protected Item(s)!", TALKTYPE_ORANGE_1)
elseif item2 >= 1 then 
setPlayerStorageValue(cid, 2222, item2)
doPlayerRemoveItem(cid, 2002, item2) 
doCreatureSay(cid, "".. allItens .." Protected Item(s)!", TALKTYPE_ORANGE_1)
elseif item3 >= 1 then 
setPlayerStorageValue(cid, 3333, item3)
doPlayerRemoveItem(cid, 2003, item3) 
doCreatureSay(cid, "".. allItens .." Protected Item(s)!", TALKTYPE_ORANGE_1)
end
return true
end
and for login (add BlokedItens)
LUA:
function onLogin(cid)
local item1 = getPlayerStorageValue(cid, 1111)
local item2 = getPlayerStorageValue(cid, 2222)
local item3 = getPlayerStorageValue(cid, 3333)
if item1  > 0 then 
setPlayerStorageValue(cid, 1111, 0)
doPlayerAddItem(cid, 2001, item1) 
elseif item2  > 0 then 
setPlayerStorageValue(cid, 2222, 0)
doPlayerAddItem(cid, 2002, item2) 
elseif item3  > 0 then 
setPlayerStorageValue(cid, 3333, 0)
doPlayerAddItem(cid, 2003, item3) 
end
return true
end
Ok NOW HELP!
??? ???? ?????
don't working
 
Last edited:
Back
Top