Purpose
Each tier has a list of accounts belonging to that tier and its rewards: one-time, daily, weekly, monthly. The module creates two NPCs: talk to the first NPC to claim the one-time reward; the second NPC hands out all periodic rewards currently available. Rewards can be coins (WCoin, Goblin Point, Ruud, Zen), item bags and buffs. Buffs marked OnLogin = true are granted again on every login while the account still belongs to the tier.
How to enable
- Run the file
Includes\CumulativeRecharge\CumulativeRecharge.sqlonce on the game DB (creates the table). - Remove the
--in front ofLoadModule("CumulativeRecharge\\CumulativeRecharge")inMain.lua. - Edit
Config.lua: the positions of the 2 NPCs, tiers, accounts, rewards. - Click Reload LuaAPI.
The module attaches OnReadScript (creates the NPCs), OnNpcTalk, OnSQLAsyncResult, OnCharacterEntry. The NPCs are removed when LuaAPI is reloaded and created again, so they are not duplicated.
SQL to create (SQL Server)
IF OBJECT_ID(N'dbo.CumulativeRewardLog', N'U') IS NULL
CREATE TABLE dbo.CumulativeRewardLog (
Account NVARCHAR(10) NOT NULL,
Tier INT NOT NULL,
RewardType NVARCHAR(10) NOT NULL,
LastClaimTime BIGINT NOT NULL,
CONSTRAINT PK_CumulativeRewardLog PRIMARY KEY (Account, Tier, RewardType)
);
The table stores the most recent claim time of each reward type (OneTime, Daily, Weekly, Monthly) per account and tier. The claim is written to the DB before the reward is granted.
Configuration (Config.lua, CumulativeRechargeConfig table)
| Key | Value | Default | Meaning |
|---|---|---|---|
Enable | true / false | true | Turns the module on / off. |
TableName | string | "CumulativeRewardLog" | DB table name. |
MinFreeSlots | number | 8 | Number of free inventory slots required when the reward includes an item bag. |
DailyResetHour | hour 0..23 | 4 | Hour at which a new day starts for daily rewards. |
WeeklyResetDay | 0..6 | 1 | Day the week starts (0 = Sunday ... 6 = Saturday), at 00:00. The month starts on the 1st at 00:00. |
OneTimeNpc | table | Class 247, Lorencia | NPC for the one-time reward: Class, Map, X, Y, Dir. |
PeriodicNpc | table | Class 249, Lorencia | NPC for periodic rewards: same fields as above. |
Tiers | table | 2 sample tiers | [tier number] = { Accounts, OneTime, Daily, Weekly, Monthly }. The tier number is the name shown to the player. |
Text | table | (built in) | The notice messages. |
Structure of a reward:
Coins = { WCoin = 0, GoblinPoint = 0, Ruud = 0, Zen = 0 }Bags = { bag number / name, ... }(GUID or name per the files inData\ItemBags)Buffs = { { Id = buff number, Seconds = duration, OnLogin = true / false }, ... }
CumulativeRechargeConfig.Tiers = {
[500] = {
Accounts = { "account1" },
OneTime = {
Coins = { WCoin = 10000, GoblinPoint = 50000, Ruud = 1000, Zen = 100000000 },
Bags = { 15 },
Buffs = { { Id = 3, Seconds = 3600, OnLogin = true } },
},
Daily = { Coins = { WCoin = 50, GoblinPoint = 250 } },
},
}