[DiscordArchive] Can you help me, please?
[DiscordArchive] Can you help me, please?
Archived author: Nyeriah • Posted: 2024-03-16T01:32:42.020000+00:00
Original source
Archived author: Foe • Posted: 2024-03-16T01:36:35.269000+00:00
Original source
Just don't fetch the player object twice
Archived author: Foe • Posted: 2024-03-16T01:36:51.703000+00:00
Original source
It makes no sense to get the player at the top of the script, and then again further down
Archived author: Nyeriah • Posted: 2024-03-16T01:44:48.381000+00:00
Original source
it does because one is the sender and the other is the receiver
Archived author: Nyeriah • Posted: 2024-03-16T01:45:50.225000+00:00
Original source
code is bad but its 11pm so no way im bothering with it past the crash fix at this time
Archived author: Nyeriah • Posted: 2024-03-16T01:47:16.200000+00:00
Original source
it was crashing because it tried to get the player sender when the command is used from console (session is nullptr)
Archived author: Foe • Posted: 2024-03-16T01:51:17.120000+00:00
Original source
But why do you need to know the sender? The only reason you need to know the sender is whether or not they are a GM to remove the bind flag, but only if the sender *is* the receiver
Archived author: Foe • Posted: 2024-03-16T01:51:32.572000+00:00
Original source
So by that logic, you only have to remove the flag if the receiver is a GM
Archived author: Foe • Posted: 2024-03-16T01:52:45.652000+00:00
Original source
The sender in this case is completely useless ♂️
Archived author: Foe • Posted: 2024-03-16T01:54:10.446000+00:00
Original source
```C++
// Adding items
uint32 noSpaceForCount = 0;
// check space and find places
ItemPosCountVec dest;
InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
if (msg != EQUIP_ERR_OK) // convert to possible store amount
count -= noSpaceForCount;
if (!count || dest.empty()) // can't add any
{
handler->SendErrorMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
return false;
}
Item* item = playerTarget->StoreNewItem(dest, itemId, true);
if (!item)
return false;
playerTarget->SendNewItem(item, count, true, false);
if (playerTarget->GetSession()->GetSecurity() > SEC_PLAYER)
item->SetBinding(false);
if (noSpaceForCount)
handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
return true;```