Hourly Reward

SIM

Newbie Spellweaver
Joined
Aug 22, 2014
Messages
15
Reaction score
22
Have you ever wanted to have a hourly reward system in your server, but you don't know where to start??

Okey here an few steps of example..

Step1. Let's add new column in the cabal_character_table its because maybe the PlayTime column might be already in used for other function on your server.
Code:
ALTER TABLE cabal_character_table
ADD [HourPlay] [INT] NOT NULL CONSTRAINT [DEF_HourPlay] DEFAULT ((0)) --This is SQL 2012 style

Step2. Let's create a stored procedure 'cabal_sp_hourly_auto_reward' under SERVER01.
/****** Object: StoredProcedure [dbo].[cabal_sp_hourly_auto_reward] Script Date: 8/30/2014 9:50:24 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


-- =========================================
-- Author: PX2000
-- Create date: 2014-08-20
-- Description: Hourly reward
-- =========================================
CREATE PROCEDURE [dbo].[cabal_sp_hourly_auto_reward]
(
@CharIdx INT,
@MinHourPlay INT = 360
)
AS
BEGIN
DECLARE @HourPlay INT
DECLARE @UserNum INT
DECLARE @LoginPlayers INT
DECLARE @Message VARCHAR(1024)
SELECT @HourPlay = HourPlay FROM dbo.cabal_Character_table WHERE CharacterIdx=@CharIdx
SELECT @LoginPlayers = Count(*) FROM dbo.cabal_Character_table WHERE Login=1


IF (@HourPlay >= @MinHourPlay)
BEGIN
SELECT @UserNum = @CharIdx/8
UPDATE dbo.cabal_Character_table SET HourPlay=0 WHERE CharacterIdx=@CharIdx
UPDATE CBL_CabalCash.dbo.CashAccountPlus SET Cash=Cash+@LoginPlayers WHERE UserNum=@UserNum
SET @Message = 'You have been rewarded a total of ('+CAST(@LoginPlayers AS VARCHAR)+') CCash. The more players is online the more CCash you will receive.'
EXEC dbo.cabal_sp_mail_send_GM @CharIdx, 'Playtime Event', @Message, 0, 0, 0, 0
END
END

In this case we are filtering the character who has the minimum of 6 hours of total played time and the reward amount of cash given is depending on how many players is online on the character re/logged-in time. Before the character is flag to be rewarded his HourPlay will be reset to 0 to avoid abuse. It will send a notification email to the character if he/she has been rewarded.

Step3. Now let's add our store procedure in the get_cabal_character default sp.
Modify
get_cabal_character and find SET NOCOUNT ON and insert this line before him.
Code:
EXEC dbo.[cabal_sp_hourly_auto_reward] @[I][B][URL="http://forum.ragezone.com/members/1333352388.html"]Character[/URL][/B][/I]idx

Step4. I forgot to put this xD...
Modify the existing sp set_cabal_character, find PLAYTIME = PLAYTIME + and this below to him.
Code:
HOURPLAY = HOURPLAY + DATEDIFF(MINUTE, LOGOUTTIME, @[I][B][URL="http://forum.ragezone.com/members/756596.html"]update[/URL][/B][/I]TIME),

Since this query is counting the total online characters then you must have the accurate count of total online characters. Click Here.
 
Last edited:
Step3. Now let's add our store procedure in the get_cabal_character default sp.
Modify get_cabal_character and find SET NOCOUNT ON and insert this line before him.


Code:
EXEC dbo.[cabal_sp_hourly_auto_reward] Characteridx


get_cabal_character and

Hello, I won't here, can you teach me where?
 
Step3. Now let's add our store procedure in the get_cabal_character default sp.
Modify get_cabal_character and find SET NOCOUNT ON and insert this line before him.


Code:
EXEC dbo.[cabal_sp_hourly_auto_reward] Characteridx


get_cabal_character and

Hello, I won't here, can you teach me where?

Find get_cabal_character on stored procedure of your SERVER01 then modify
 
Back