hello,guys i have a little problem i want to show, vp, and dp at the same time
with same command without separated commands
i mean if i use .coin i want to see my vp, and dp at the same time
i tried to modify it but i cant the script is made by tommy here is the script
with same command without separated commands
i mean if i use .coin i want to see my vp, and dp at the same time
i tried to modify it but i cant the script is made by tommy here is the script
Code:
/*
// Create our map that will hold necessary data for all players
std::unordered_map<uint32, uint32> VoteMap;
class vote_worldscript : public WorldScript
{
public:
vote_worldscript() : WorldScript("vote_worldscript") { }
void OnStartup() override
{
// Give our updateTimer a value of every 5 minutes. Don't want it to be super low.
updateTimer = 5 * MINUTE * IN_MILLISECONDS;
// Here we're going to load all the data into our map 'VoteMap'
// Selects accountId (id) and vp from the account table
QueryResult result = LoginDatabase.PQuery("SELECT id, vp, dp FROM account");
if (result)
{
do
{
Field* field = result->Fetch();
uint32 accountId = field[0].GetUInt32();
uint32 vp = field[1].GetUInt32();
uint32 dp = field[2].GetUInt32();
// Fill our map
VoteMap[accountId] = vp, dp;
} while (result->NextRow());
}
}
void OnUpdate(uint32 diff) override
{
// Reload vp for all players every 5 minutes
if (updateTimer <= diff)
{
VoteMap.clear();
QueryResult result = LoginDatabase.PQuery("SELECT id, vp, dp FROM account");
if (result)
{
do
{
Field* field = result->Fetch();
uint32 accountId = field[0].GetUInt32();
uint32 vp = field[1].GetUInt32();
uint32 dp = field[2].GetUInt32();
// Fill our map
VoteMap[accountId] = vp, dp;
} while (result->NextRow());
}
updateTimer = 5 * MINUTE * IN_MILLISECONDS;
}
else
updateTimer -= diff;
}
private:
uint32 updateTimer;
};
class cmd_vote_points : public CommandScript
{
public:
cmd_vote_points() : CommandScript("cmd_vote_points") { }
std::vector<ChatCommand> GetCommands() const override
{
static std::vector<ChatCommand> pointCommandTable =
{
{ "VP", SEC_PLAYER, false, &HandleGetPointsCommand, "" },
};
return pointCommandTable;
}
static bool HandleGetPointsCommand(ChatHandler* handler, char const* args)
{
Player* player = handler->GetSession()->GetPlayer();
// Find player's data in 'VoteMap' by searching for accountId
// Remember: first (accountId), second (vp)
std::unordered_map<uint32, uint32>::iterator itr = VoteMap.find(player->GetSession()->GetAccountId());
if (itr != VoteMap.begin())
ChatHandler(player->GetSession()).PSendSysMessage(78231, itr->second);
if (itr != VoteMap.end())
ChatHandler(player->GetSession()).PSendSysMessage(78230, itr->second);
return true;
}
};
Last edited: