forgee
Veteran OT User
I made this after it was requested here.
Not much to say, players are awarded premium points for reaching certain levels. See script comments for configuration.
Supports TFS 1.0+.
Works with both Gesior and ZnoteAAC, probably works with any AAC as long as you know where the points are stored.
creaturescripts.xml:
points_reward.lua:
Not much to say, players are awarded premium points for reaching certain levels. See script comments for configuration.
Supports TFS 1.0+.
Works with both Gesior and ZnoteAAC, probably works with any AAC as long as you know where the points are stored.
creaturescripts.xml:
Code:
<event type="login" name="register_points_reward" script="points_reward.lua"/>
<event type="advance" name="points_reward" script="points_reward.lua"/>
points_reward.lua:
Code:
--[[
Award premium points for reaching certain levels
Only for TFS 1.0+
config:
You need to know where premium points are stored in the database
Below are the values for Gesior and ZnoteAAC
db_table: ZnoteAAC: 'znote_accounts' Gesior: 'accounts'
db_pointsColumn: ZnoteAAC: 'points' Gesior: 'premium_points'
db_idColumn: ZnoteAAC: 'account_id' Gesior: 'id'
storage: set to a unused storage value
messageType: set the type of message the player receives, for example MESSAGE_STATUS_CONSOLE_BLUE
rewards:
Configure the amount of points awarded for reaching a certain level
format: [level] = points
]]
local config = {
storage = 123, -- Select unused storage
messageType = MESSAGE_STATUS_CONSOLE_BLUE,
db_table = 'accounts',
db_pointsColumn = 'premium_points',
db_idColumn = 'id',
}
local rewards = {
--[level] = points
[50] = 1,
[100] = 5,
[200] = 10,
}
-- End config
function onAdvance(player, skill, oldLevel, newLevel)
player = Player(player) -- for TFS 1.0
if not player then
return true
end
if skill == SKILL_LEVEL then
if newLevel > player:getStorageValue(config.storage) then
player:setStorageValue(config.storage, newLevel)
local points = 0
for i = oldLevel + 1, newLevel do
if rewards[i] then
points = points + rewards[i]
player:sendTextMessage(config.messageType, string.format("Congratulations! You have been awarded %s premium point%s for reaching level %s!", rewards[i], rewards[i] > 1 and "s" or "", i))
end
end
if points > 0 then
db.asyncQuery("UPDATE `"..config.db_table.."` SET `"..config.db_pointsColumn.."` = `"..config.db_pointsColumn.."` + "..points.." WHERE `"..config.db_idColumn.."` = "..player:getAccountId())
end
end
end
return true
end
function onLogin(player)
player = Player(player) -- for TFS 1.0
if player then
player:registerEvent("points_reward")
end
return true
end