static bool HandleVPointsCommand(ChatHandler* handler, const char* args)
{
std::string name;
Player* player;
char* targetName = strtok((char*)args[0], ""); // Get entered name
int votepoints = atoi((char*)args[1]);
if (targetName)
{
name = targetName;
normalizePlayerName(name);
player = sObjectAccessor->FindPlayerByName(name);
}
else // If no name was entered - use target
{
player = handler->getSelectedPlayer();
if (player)
name = player->GetName();
}
WorldSession * m_session = player->GetSession();
QueryResult select = LoginDatabase.PQuery("SELECT vpoints FROM account WHERE id = '%u'", player->GetSession()->GetAccountId());
if (!select)
{
handler->PSendSysMessage("Failed to Votes,character probably doesnt exist!");
return false;
}
Field* fields = select->Fetch();
uint32 vp = fields[0].GetUInt32();
int vpoints = vp + votepoints;
LoginDatabase.PExecute("UPDATE account SET `vpoints` = '%u' WHERE id = '%u'", vpoints, player->GetSession()->GetAccountId());
ChatHandler(player->GetSession()).PSendSysMessage("Your vote points have been modified,you now have %u Vote Point(s)!", vpoints);
handler->PSendSysMessage("You have succesfully set %u Vote point(s) to player %s!", vpoints, player->GetName().c_str());
player->SaveToDB();
return true;
}
The idea is after usage of “.player vpoints 10” vpoints value must be updated by +10,when “.player vpoints -10” is used to reduce that value by 10.
I tried too hard but seems like i am not able to do it,the result of my work is just crash on use /emoticons/default_sleep.png
Can someone help me about this one?