kito2
www.masteria.net
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?
Is this possible, and how?
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]);
}
}
}
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
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
--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
doPlayerAddItem(cid, item, getCreatureStorage(cid, count), [COLOR=red][B]true[/B][/COLOR])
doPlayerAddItem(uid, itemid[, count/subtype = 1[COLOR=red][B][, canDropOnMap = true[/B][/COLOR][, slot = 0][COLOR=red][B]][/B][/COLOR]])
local id = 5214 -- itemid.
if getPlayerFreeCap(cid) >= getItemWeightById(id,1) then
LUA:local id = 5214 -- itemid. if getPlayerFreeCap(cid) >= getItemWeightById(id,1) then
if getPlayerFreeCap(cid) >= getItemWeightById(id) then
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