Reloac
BETA Tester
Hey
I've been working on making items cost a custom currency, so far so good.. it will error if they dont have enough Magic Gold, and it will give them the item if they do and deduct the Magic Gold, but if their inventory is full, and they have the Magic Gold for the item, it takes that and doesn't give them the item, im trying to work out how i can add a check to see if they have space and if not to error and say they dont have any.. but all tries have failed :/
Any help would be awesome...
I've been working on making items cost a custom currency, so far so good.. it will error if they dont have enough Magic Gold, and it will give them the item if they do and deduct the Magic Gold, but if their inventory is full, and they have the Magic Gold for the item, it takes that and doesn't give them the item, im trying to work out how i can add a check to see if they have space and if not to error and say they dont have any.. but all tries have failed :/
Code:
if (pProto->mgcost > 0)
{
QueryResult result = LoginDatabase.PQuery("SELECT magic_gold FROM magic_gold WHERE id='%u'", GetSession()->GetAccountId());
if (result)
{
Field* fields = result->Fetch();
uint32 CurrentMagicGold = fields[0].GetUInt32();
if (pProto->zgcost > CurrentMagicGold)
{
ChatHandler(GetSession()).SetSentErrorMessage(true);
ChatHandler(GetSession()).PSendSysMessage("Not enough Magic Gold! [Item Cost : %u]", pProto->mgcost);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item, 0);
return false;
}
else
{
CurrentMagicGold -= pProto->mgcost;
ChatHandler(GetSession()).PSendSysMessage("Deducted %u Magic Gold!", pProto->mgcost);
LoginDatabase.PExecute("UPDATE magic_gold SET magic_gold='%u' WHERE id='%u'", CurrentMagicGold, GetSession()->GetAccountId());
}
}
}
Any help would be awesome...
Last edited: