Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[EP8] Script that gives Players eCoins per hour played

Joined
Jun 27, 2010
Messages
411
Reaction score
240
Well title says it all. You need to create a new table so the script can track how many hours per player are already paid:

Code:
USE [CabalCash]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[ecoin_by_time](
	[UserNum] [int] NOT NULL,
	[PlayTimeDepreciate] [int] NULL,
	[LastDepreciation] [datetime] NULL,
 CONSTRAINT [PK_ecoin_by_time] PRIMARY KEY CLUSTERED 
(
	[UserNum] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

And here's the script:
Code:
USE [Account]
GO

DECLARE c CURSOR FOR SELECT [UserNum], [PlayTime], [ID] FROM [cabal_auth_table] WHERE AuthType = 1 AND PlayTime > 0 
OPEN c

DECLARE @UserNum int, @PlayTime int, @m int, @d int, @uid varchar(50);

FETCH NEXT FROM c INTO @UserNum, @PlayTime, @uid;

WHILE @@Fetch_Status=0 
BEGIN
	BEGIN TRAN
		SELECT [UserNum] FROM [CabalCash].[dbo].[ecoin_by_time] WHERE [UserNum] = @UserNum				
		IF @@ROWCOUNT = 0
		BEGIN
			--Account not found, creating a new one;
			INSERT INTO [CabalCash].[dbo].[ecoin_by_time]
           ([UserNum], [PlayTimeDepreciate]) VALUES (@UserNum, 0)
		END
		
		SET @m = (@PlayTime - (SELECT [PlayTimeDepreciate] FROM [CabalCash].[dbo].[ecoin_by_time] WHERE [UserNum] = @UserNum)) / 60
		SELECT @m AS Multiplikator

		SELECT [UserNum] FROM [CabalCash].[dbo].[CashAccount] WHERE [UserNum] = @UserNum
		IF @@ROWCOUNT = 0
		BEGIN
			--Account not found, creating a new one;
			INSERT INTO [CabalCash].[dbo].[CashAccount]
           ([ID]
           ,[UserNum]
           ,[Cash]
           ,[CashBonus])
			VALUES
			(@uid
			,@UserNum
			,0
			,0)
		END

		SET @d = (SELECT [Cash] FROM [CabalCash].[dbo].[CashAccount] WHERE [UserNum] = @UserNum) +  (@m * 100)

		UPDATE [CabalCash].[dbo].[CashAccount]
			SET [Cash] = @d WHERE [UserNum] = @UserNum

		UPDATE [CabalCash].[dbo].[ecoin_by_time]
			SET [PlayTimeDepreciate] = [PlayTimeDepreciate] + (@m * 60) WHERE [UserNum] = @UserNum

   COMMIT TRAN
   SET @m = 0;
   FETCH NEXT FROM c INTO @UserNum, @PlayTime, @uid
END

CLOSE c
DEALLOCATE c

So why did I post it in the dev section? The script is not tested on a live server, so I'd appreciate feedback.
 
Last edited:
Elite Diviner
Joined
Aug 23, 2012
Messages
406
Reaction score
99
Re: Script that gives Players eCoins per hour played

How much eCoins can be gained per hour, 100ecoins (= @UserNum) + (@m * 100))? How about for example the AFK players, can still he gained eCoins when dancing/standing? Is this the protection for the AFK players (DECLARE c CURSOR FOR SELECT [UserNum])?
 
RaGEZONER
Joined
Sep 25, 2009
Messages
637
Reaction score
398
Re: Script that gives Players eCoins per hour played

Here is the feedback,

- Updates UserNum 2: 14400min / 60min = 240h x 100eCoin = 24,000Ecoin's

- login at 18:44 with 14400min and 24,000Ecoin's. Ok.
- run script to test at 19:15 with 14431min, ecoin table still at 14400min. Ok.
- run script at 19:44+ with 14460+min, ecoin table updated to 14460min, ecoin added to UserNum 2. Ok.
- Ingame check at 19:44+ is 24,100Ecoin's. Ok.

- While other UserNum XX when not above 0 playtime and dividable by 60 are not updated. Ok.

So I think it is doing what it is supposed to do.

I was wondering what to do with the Ecoin currency, well now I know.
 
█║▌║▌║TheMerc iful║▌║▌║█
Loyal Member
Joined
Jan 29, 2005
Messages
1,367
Reaction score
80
Re: Script that gives Players eCoins per hour played

Well title says it all. You need to create a new table so the script can track how many hours per player are already paid:

Code:
USE [CabalCash]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[ecoin_by_time](
	[UserNum] [int] NOT NULL,
	[PlayTimeDepreciate] [int] NULL,
	[LastDepreciation] [datetime] NULL,
 CONSTRAINT [PK_ecoin_by_time] PRIMARY KEY CLUSTERED 
(
	[UserNum] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

And here's the script:
Code:
USE [Account]
GO

DECLARE c CURSOR FOR SELECT [UserNum], [PlayTime], [ID] FROM [cabal_auth_table] WHERE AuthType = 1 AND PlayTime > 0 
OPEN c

DECLARE @UserNum int, @PlayTime int, @m int, @d int, @uid varchar(50);

FETCH NEXT FROM c INTO @UserNum, @PlayTime, @uid;

WHILE @@Fetch_Status=0 
BEGIN
	BEGIN TRAN
		SELECT [UserNum] FROM [CabalCash].[dbo].[ecoin_by_time] WHERE [UserNum] = @UserNum				
		IF @@ROWCOUNT = 0
		BEGIN
			--Account not found, creating a new one;
			INSERT INTO [CabalCash].[dbo].[ecoin_by_time]
           ([UserNum], [PlayTimeDepreciate]) VALUES (@UserNum, 0)
		END
		
		SET @m = (@PlayTime - (SELECT [PlayTimeDepreciate] FROM [CabalCash].[dbo].[ecoin_by_time] WHERE [UserNum] = @UserNum)) / 60
		SELECT @m AS Multiplikator

		SELECT [UserNum] FROM [CabalCash].[dbo].[CashAccount] WHERE [UserNum] = @UserNum
		IF @@ROWCOUNT = 0
		BEGIN
			--Account not found, creating a new one;
			INSERT INTO [CabalCash].[dbo].[CashAccount]
           ([ID]
           ,[UserNum]
           ,[Cash]
           ,[CashBonus])
			VALUES
			(@uid
			,@UserNum
			,0
			,0)
		END

		SET @d = (SELECT [Cash] FROM [CabalCash].[dbo].[CashAccount] WHERE [UserNum] = @UserNum) +  (@m * 100)

		UPDATE [CabalCash].[dbo].[CashAccount]
			SET [Cash] = @d WHERE [UserNum] = @UserNum

		UPDATE [CabalCash].[dbo].[ecoin_by_time]
			SET [PlayTimeDepreciate] = [PlayTimeDepreciate] + (@m * 60) WHERE [UserNum] = @UserNum

   COMMIT TRAN
   SET @m = 0;
   FETCH NEXT FROM c INTO @UserNum, @PlayTime, @uid
END

CLOSE c
DEALLOCATE c

So why did I post it in the dev section? The script is not tested on a live server, so I'd appreciate feedback.

Alpakilo!!! Could You Please!!! Please!!! Please!!! Make The Script Of Chump's Server Config With EXP And Channels And All Compatible With EP8...

That Would Really Make It All!... :):

Cheers! For The Man Who Made It All...
 
Elite Diviner
Joined
Aug 23, 2012
Messages
406
Reaction score
99
Re: Script that gives Players eCoins per hour played

@toast2250, Have you tried it to an AFK player for an hour if he can still gain the 100eCoin?
 
┌П┐(•_•)┌П┐
Joined
Dec 22, 2009
Messages
958
Reaction score
318
Re: Script that gives Players eCoins per hour played

You're right, that will be a problem. But you can take something else too, not only playtime. For example, playtime and level and so on.
 
Joined
Jun 27, 2010
Messages
411
Reaction score
240
Re: Script that gives Players eCoins per hour played

Alpakilo!!! Could You Please!!! Please!!! Please!!! Make The Script Of Chump's Server Config With EXP And Channels And All Compatible With EP8...

I'm not entirely sure what you want from me, could you please rephrase that?
 
Newbie Spellweaver
Joined
Jan 25, 2013
Messages
67
Reaction score
1
Re: Script that gives Players eCoins per hour played

this script works in EP8
 
Newbie Spellweaver
Joined
Jan 25, 2013
Messages
67
Reaction score
1
mais fiquei uma hora no jogo e nao acrescento nada

I was more an hour on the game and do not add anything
 
Experienced Elementalist
Joined
Sep 23, 2012
Messages
253
Reaction score
12
Invalid object name 'CabalCash.dbo.ecoin_by_time'.

-why i get this when i runn second command in Account ?thanks
 
Experienced Elementalist
Joined
Sep 23, 2012
Messages
253
Reaction score
12
Have you run the first command? Did it execute without any errors? Is the table [ecoin_by_time] present in the [CabalCash] database?
FIXED: i use 2x CabalCash like CabalCash1 and CabalCash2 and 1 only account i run the command only in cabalcash2 that's why when i run comand in account got errors,so i run the comand in cabalcash1 after in account and works,btw how can i edit the time,i mean give me 5 eCoin for 30 minutes,and the value of coins?thanks
 
Junior Spellweaver
Joined
Jan 20, 2009
Messages
147
Reaction score
56
um just first time run scrip gain e-coin
what can i do update e-coin per hour?
 
Newbie Spellweaver
Joined
Jan 25, 2013
Messages
67
Reaction score
1
um just first time run scrip gain e-coin
what can i do update e-coin per hour?
 
Junior Spellweaver
Joined
Mar 2, 2008
Messages
170
Reaction score
17
You already have this in the form of T.Coins in worldsvr setting, you can set the max amount, rate of which the coins are to be given and how many . It's all saved in the DB too. People need to learn to search.

so i just turn FALSE -> TRUE?
and reload cabal service?

Tpoint is same like eCoin?
 
RaGEZONER
Joined
Sep 25, 2009
Messages
637
Reaction score
398
Yes.

Alz - Drops ingame
E coin - SQL hourly script based on playtime
DP - Dungeon Points, you receive points for 3 hours from doing dungeons
T point - Based on play time per hour

They are not the same, Tpoint generating works but selling does not. T point is more or less useless.
 
Back
Top