hi all;
i've wroted a script about custom event. and i trying to adding items on player's party. here's the code :
void JustDied(Unit * killer)
{
Group * killerGroup = ((Player *)killer)->GetGroup();
if (killerGroup)
{
DoScriptText(SAY_CONGRULATIONS, m_creature, killer);
for(GroupReference * itr = killerGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player * receiver = itr->getSource();
// possible fix crash i think
if (!receiver)
continue;
if (receiver)
{
// Item bla_bla_bla
int32 count = 1;
uint32 itemid = ITEM_BLA_BLA_BLA;
//now we can add items
uint32 noSpaceForCount = 0;
// check space and find places
ItemPosCountVec dest;
uint8 msg = receiver->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count, &noSpaceForCount);
if(count == 0 || dest.empty())
continue;
Item * item = receiver->StoreNewItem(dest, itemid, true, Item::GenerateItemRandomPropertyId(itemid));
if (count > 0 && item)
receiver->SendNewItem(item, count, false, true);
else
continue;
}
}
}
}
server crashed after first player's have taked the item. also there isn't any crashlog about this situation. the server don't give me any crashlog.
anybody have an idea? thanks ..