Hi everybody !
I'm making a donation point system linked between the emu and the cms.
When a player buy some donation points on the website, these donation points are stored in a sql table.
I want these donation points to go to the player bag on login. So i started wrote this :
Code:
// Add Donation Points
QueryResult pts = LoginDatabase.PQuery("SELECT `dp` FROM account_data WHERE id = '%u'", pCurrChar->GetSession()->GetAccountId());
Field* fields = pts->Fetch();
uint32 dp = fields[0].GetUInt32();
if (dp == 0)
{
pCurrChar->GetSession()->SendAreaTriggerMessage("");
}
else
{
pCurrChar->AddItem(999910,dp);
QueryResult pts2 = LoginDatabase.PQuery("UPDATE account_data SET `dp`= 0 WHERE id ='%u'", pCurrChar->GetSession()->GetAccountId());
Field* fields = pts2->Fetch();
}
This part of code is include in CharacterHandler.cpp and it works like a charm.
My problem is here : I want these donation points to go in bag of any characters on the same account.
Explaination : I'm login in. I got in my bag 5 donation points. If i log out these 5 donation points stay in the character's bag.
I was asking my self about a solution, so i wrote this :
Code:
//Remove Donation Points
if (GetPlayer()->GetCurrency(999910,true))
{
QueryResult rmvpts = LoginDatabase.PQuery("UPDATE account_data SET `dp`= '%u'", GetPlayer()->GetItemCount(999910,true), "WHERE id ='%u'", GetPlayer()->GetSession()->GetAccountId());
Field* fields = rmvpts->Fetch();
uint32 dp = fields[0].GetUInt32();
GetPlayer()->RemoveMItem(999910);
}
This code, on log out, should check if the current character have some Donation Point (999910) and if the player has, it should get the amount of donation points and update this amount in the account table.
Unfortunately this part doesn't work, worldserver crash when trying to log out and all accounts are credited with the amount of donation point in the player bag..
That's the reason why i'm asking to this great community to help me about this shity problem !
Apologize for my bad english. Thank you all.