• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Making an item UNLOOTEABLE

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,764
Solutions
1
Reaction score
227
Location
Chile, Santiago
Hi, I want to make that a item with id X doesn't get dropped o looted from a player when he dies, even if he has red skull or black skull...

Is this possible, and how?
 
edit source ;)
If item is always in same slot its easy, just edit:
PHP:
void Player::dropLoot(Container* corpse)
{
	if(!corpse || lootDrop != LOOT_DROP_FULL)
		return;

	uint32_t start = g_config.getNumber(ConfigManager::BLESS_REDUCTION_BASE), loss = lossPercent[LOSS_CONTAINERS], bless = getBlessings();
	while(bless > 0 && loss > 0)
	{
		loss -= start;
		start -= g_config.getNumber(ConfigManager::BLESS_REDUCTION_DECREAMENT);
		bless--;
	}

	uint32_t itemLoss = (uint32_t)std::floor((5. + loss) * lossPercent[LOSS_ITEMS] / 1000.);
	for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)
	{
		Item* item = inventory[i];
		if(!item)
			continue;

		uint32_t rand = random_range(1, 100);
		if(skull > SKULL_WHITE || (item->getContainer() && rand < loss) || (!item->getContainer() && rand < itemLoss))
		{
			g_game.internalMoveItem(NULL, this, corpse, INDEX_WHEREEVER, item, item->getItemCount(), 0);
			sendRemoveInventoryItem((slots_t)i, inventory[(slots_t)i]);
		}
	}
}
 
But do you want the player to have the item on next login, even if it was in a backpack that was dropped?

Maybe you could use onPrepareDeath and onLogin with a storage then.
 
That would be a nice idea..

If player dies, check if he has the item, if he has, then it get deleted and add a storage = 1.
When player login, check storage, if is = 1, gives the item and then set storage = 0.
 
Uhm, something like this probably
LUA:
local storage = xxxx
local item = xxxx
function onKill(cid, target)
if isPlayer(target) then
   if getPlayerItemCount(target,item) > 0 then
      doRemoveItem(target,item,1)
      setPlayerStorageValue(target,storage,1)
   end
end
return true
end

LUA:
local storage = xxxx
local item = xxxx
function onLogin(cid)
if getPlayerStorageValue(cid,storage) == 1 then
   doPlayerAddItem(cid,item,1)
   setPlayerStorageValue(cid,storage,0)
   end
return true
end
 
only 1 storage to store # of item
LUA:
--STORAGE
local count = 14501
--ITEMID
local item = 2472

function onPrepareDeath(cid, deathList)
    if getPlayerItemCount(cid, item) > 0 then
        doCreatureSetStorage(cid, count, getPlayerItemCount(cid, item))
        doPlayerRemoveItem(cid, item)
    end
    return true
end

function onLogin(cid)
    registerCreatureEvent(cid, "itemlose")
    if getCreatureStorage(cid, count) > 0 then
        doPlayerAddItem(cid, item, getCreatureStorage(cid, count), true)
        doCreatureSetStorage(cid, count, 0)
    end
    return true
end
 
humm what if player have no space, or no cap
Code:
doPlayerAddItem(cid, item, getCreatureStorage(cid, count), [COLOR=red][B]true[/B][/COLOR])
will drop on map
Code:
doPlayerAddItem(uid, itemid[, count/subtype = 1[COLOR=red][B][, canDropOnMap = true[/B][/COLOR][, slot = 0][COLOR=red][B]][/B][/COLOR]])
 
- I was thinking, if the player dies with red skull, he will lose all items, and will appear with a bag, and with the item, so there isn't a problem.
- But, if the player dies without bless or AOL, he will loose the backpack and when he logs in, then he will get a new backpack and the item, so space there will be...
- But what happens if the player dies with and the item is removed? I mean, it was on the backpack, and he is fully equiped... Where will the ring appear? I think it will give a bug and the player won't be able to login... :S

How to make a check if the player have enought space and have enought cap?
1) Dunno.
2) getPlayerFreeCap(cid) > item weight?
 
@up
add itemEx with drop map = 0, it return lua_error when item can't be added, you can add message when error and remove storage when msg is number and > 0 (return UID of item)
@topic
Can you tell us WHAT this script will do and what item you want use? I could be much easier to post script.
 
Try thaat, i had it as a talkaction, and i put in the creatire file.
LUA:
local items = {
				--// [itemid] = {empty storage} \\--
				[2446] = 199209,
				[2466] = 199219,
				[2160] = 199229
			  }
local storage = 192289    -- empty storage 


 
function onPrepareDeath(cid, deathList)
   	if getPlayerSlotItem(cid,CONST_SLOT_NECKLACE).itemid ~= 2173 or isInArray({4,5},getCreatureSkullType(cid))   then
		for k, v in pairs(items) do
			local count = getPlayerItemCount(cid, k)
				if count > 0 then
					doPlayerRemoveItem(cid, k,count) 
					setPlayerStorageValue(cid,v,count)
					setPlayerStorageValue(cid,storage,1)
				end
		end
	end
	return true
end
 
function onLogin(cid)
    registerCreatureEvent(cid, "itemlose")
	if getPlayerStorageValue(cid,storage) > 0 then
		local check = true
		for k,v in pairs(items) do
			local count = getPlayerStorageValue(cid,v)
				if count > 0 then
					if isItemStackable(k) then
						if doPlayerAddItem(cid,k,count,0) then
							setPlayerStorageValue(cid,v,-1)
						else
							check = false
						end
					else
						for i = 1, count do
							if doPlayerAddItem(cid,k,i,0) then
								doPlayerSetStorageValue(cid,v,-1)
							else
								check = false
							end
						end
					end
				end
			
				
		end

		if check == true then	
			doPlayerSendTextMessage(cid,25,"Item retrieving process was completed sucessfuly.")
			setPlayerStorageValue(cid,storage,-1)
		else
			doPlayerSendTextMessage(cid,18,"Warning : items retrieving process was interrupted , seems you don't have enough space or cap to hold rest of your items.Free some space and login again")
		end
	end
    return true
end
 
Last edited:
if getPlayerSlotItem(cid,CONST_SLOT_NECKLACE).itemid ~= 2173 or isInArray({4,5},getCreatureSkullType(cid)) then

It doesn't check all spaces?
 
dude , this is just a check so if player doesnt have a redskull or black and is wearing aol then script shouldnt work, other than that script would work
 
Doggy, there is a bug that haven't been fixed on many years... I have seen people without red skull, black skull, with blessings and aol that dies and lose items, that's why Im doing this.
 
Back
Top