• 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 [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 that prevents drope certain items, even for red skulls.
If the player dies will not lose items? You help?

local BlokedItens {10511, 10512, 10513, 10514, 10515, 10516}
 
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 {10511, 10512, 10513, 10514, 10515, 10516}

Just make a script so it will delete it on Preparedeath and set a storage value and onLogin you check if he has that storage the player will get his item and it deletes the storage ? not a perfect script but its a simple script.. else i guess you will have to sourceedit ;P
 
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!
??? ???? ?????
 
Last edited:

Similar threads

Back
Top