This function work only if you add in LUA (in engine - C++) new function getCharges():
LUA script:
If you want copy container use copyItem(item),where item = container, not copyContainer!
I use it to drop copy of EQ when player die:
container = corpse from onDEath
PHP:
int32_t LuaScriptInterface::luaGetCharges(lua_State* L)
{
//getCharges(uid)
uint32_t uid = popNumber(L);
ScriptEnviroment* env = getScriptEnv();
Item* item = env->getItemByUID(uid);
if(item)
{
lua_pushnumber(L, item->getSubType());
}
else
lua_pushnumber(L, -1);
return 1;
}
PHP:
function copyItem(item)
if (isContainer(item.uid) == TRUE) then
return copyContainer(item.uid, item.itemid)
else
return doCreateItemEx(item.itemid, getCharges(item.uid))
end
end
function copyContainer(uid, itemid)
local container = doCreateItemEx(itemid, 1)
local iterator = getContainerSize(uid)
while iterator >= 0 do
doAddContainerItemEx(container, copyItem(getContainerItem(uid, iterator)))
iterator = iterator - 1
end
return container
end
I use it to drop copy of EQ when player die:
PHP:
function dropLoot(cid, container)
i = CONST_SLOT_AMMO
while i >= CONST_SLOT_HEAD do
local slot_item = getPlayerSlotItem(cid, i)
if (slot_item.itemid ~= 0) then
if (isContainer(slot_item.uid) == TRUE) then
doAddContainerItemEx(container, copyItem(slot_item))
elseif (math.random(1, 100) <= 40) then
doAddContainerItemEx(container, copyItem(slot_item))
end
end
i = i - 1
end
end