mirror of
https://github.com/freekode/mod-reward-played-time-improved.git
synced 2026-01-13 00:28:34 +00:00
Update of the reward_system script
This commit is contained in:
@@ -6,3 +6,10 @@
|
|||||||
# Default: 1 - (Enabled)
|
# Default: 1 - (Enabled)
|
||||||
# 0 - (Disabled)
|
# 0 - (Disabled)
|
||||||
RewardSystemEnable = 1
|
RewardSystemEnable = 1
|
||||||
|
|
||||||
|
#
|
||||||
|
# MaxRoll
|
||||||
|
# Description: Can alter the max roll for players
|
||||||
|
# Default: 1000 - (Enabled)
|
||||||
|
#
|
||||||
|
MaxRoll = 1000
|
||||||
@@ -7,39 +7,48 @@
|
|||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include "GossipDef.h"
|
#include "GossipDef.h"
|
||||||
|
|
||||||
|
int32 roll;
|
||||||
|
bool RewardSystem_Enable;
|
||||||
|
uint32 Max_roll;
|
||||||
|
|
||||||
class reward_system : public PlayerScript
|
class reward_system : public PlayerScript
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
reward_system() : PlayerScript("rewardsystem") {}
|
reward_system() : PlayerScript("rewardsystem") {}
|
||||||
|
|
||||||
uint32 rewardtimer = urand(2 * HOUR*IN_MILLISECONDS, 4 * HOUR*IN_MILLISECONDS);
|
uint32 rewardtimer = urand(2 * HOUR*IN_MILLISECONDS, 4 * HOUR*IN_MILLISECONDS);
|
||||||
int32 roll = urand(1, 1000);
|
|
||||||
|
|
||||||
void OnBeforePlayerUpdate(Player* player, uint32 p_time)
|
void OnBeforePlayerUpdate(Player* player, uint32 p_time)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!sConfigMgr->GetBoolDefault("RewardSystemEnable", true))
|
if (!RewardSystem_Enable)
|
||||||
return;
|
return;
|
||||||
{
|
{
|
||||||
if (rewardtimer <= p_time)
|
if (rewardtimer <= p_time)
|
||||||
{
|
{
|
||||||
roll = urand(1, 1000); //Lets make a random number from 1 - 1000
|
roll = urand(1, Max_roll); //Lets make a random number from 1 -
|
||||||
QueryResult result = CharacterDatabase.PQuery("SELECT item, quantity FROM reward_system WHERE roll = '%u'", roll);
|
QueryResult result = CharacterDatabase.PQuery("SELECT item, quantity FROM reward_system WHERE roll = '%u'", roll);
|
||||||
rewardtimer = urand(2 * HOUR*IN_MILLISECONDS, 4 * HOUR*IN_MILLISECONDS);
|
rewardtimer = urand(2 * HOUR*IN_MILLISECONDS, 4 * HOUR*IN_MILLISECONDS);
|
||||||
|
|
||||||
if (!result || player->isAFK())
|
if (!result || player->isAFK())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Lets now get the item
|
do
|
||||||
Field* fields = result->Fetch();
|
{
|
||||||
uint32 pItem = fields[0].GetInt32();
|
//Lets now get the item
|
||||||
uint32 quantity = fields[1].GetInt32();
|
Field* fields = result->Fetch();
|
||||||
|
uint32 pItem = fields[0].GetInt32();
|
||||||
|
uint32 quantity = fields[1].GetInt32();
|
||||||
|
|
||||||
// now lets add the item
|
// now lets add the item
|
||||||
player->AddItem(pItem, quantity);
|
player->AddItem(pItem, quantity);
|
||||||
|
|
||||||
ChatHandler(player->GetSession()).PSendSysMessage("You have rolled %u which gave you item %u", roll, pItem);
|
ChatHandler(player->GetSession()).PSendSysMessage("You have rolled %u which gave you item %u", roll, pItem);
|
||||||
|
|
||||||
|
} while (result->NextRow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -62,6 +71,9 @@ public:
|
|||||||
sConfigMgr->LoadMore(cfg_def_file.c_str());
|
sConfigMgr->LoadMore(cfg_def_file.c_str());
|
||||||
|
|
||||||
sConfigMgr->LoadMore(cfg_file.c_str());
|
sConfigMgr->LoadMore(cfg_file.c_str());
|
||||||
|
|
||||||
|
RewardSystem_Enable = sConfigMgr->GetBoolDefault("RewardSystemEnable", true);
|
||||||
|
Max_roll = sConfigMgr->GetIntDefault("MaxRoll", 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user