[SQL] OnlineHours Reward Script

Junior Spellweaver
Joined
Nov 3, 2008
Messages
171
Reaction score
58
I have script that automatically trades OnlineHours to special cash points "cspoints" in game every hour.Those Points are located in
sql dbo.MEMB_INFO under "cspoints" column.

What i want to do is,to rewrite this script so it would add me Money and Credits.

Money are located in dbo.Character table under column "Money"
(memb__id is named AccountID in this .dbo)

Credits are located in dbo.MEMB_CREDITS table under column "credits"
(memb__id is memb__id)


But i am facing few difficulties replacing things in script, because i need to change in one place memb__id from dbo.MEMB_INFO
to AccountID from dbo.Character while to keep memb__id from dbo.MEMB_STATS untouched


and i am confused where i have to rename it and where to leave it in default state.


Code:
CREATE PROCEDURE [dbo].[WZ_DISCONNECT_MEMB]
@memb___id varchar(10)
 AS
Begin    
set nocount on
    Declare  @find_id varchar(10)    
    Declare @ConnectStat tinyint
	declare @OnlineHours real
	declare @cspoints int
    Set @ConnectStat = 0     
    Set @find_id = 'NOT'
    select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id 
           where I.memb___id = @memb___id
    if( @find_id <> 'NOT' )    
    begin        
	SELECT @cspoints= cs_points FROM MEMB_INFO where memb___id = @memb___id
        update MEMB_STAT set ConnectStat = @ConnectStat, DisConnectTM = getdate(), OnlineHours = @cspoints/10+(DATEDIFF(hh,ConnectTM,getdate()))
         where memb___id = @memb___id
	SELECT  @OnlineHours =OnlineHours FROM MEMB_STAT WHERE memb___id = @memb___id

	UPDATE [dbo].[MEMB_INFO]
	SET cs_points=(@OnlineHours * 10)
	WHERE memb___id = @memb___id

    end
end
GO

can someone help me out to understand which memb__id in this script is from dbo.MEMB_STAT and which memb__id from MEMB_INFO
so i could proceed with my trial to rewrite this script further.


or if anyone willing to spend 1 minute of his time and provide me working scripts for money and credits i can make a small donation
of 3€ paypal


here is how my database structure looks like
OneManArmy - [SQL] OnlineHours Reward Script - RaGEZONE Forums
 
ok i have rewritten script and made it work but now i have 2 versions of this script with different rewards.And i can use 1 script at a time without problems but how to add both of them into stored procedure correctly?


here is how 1 version of script looks like :

Code:
CREATE PROCEDURE [dbo].[WZ_DISCONNECT_MEMB]
@memb___id varchar(10)
 AS
Begin    
set nocount on
    Declare  @find_id varchar(10)    
    Declare @ConnectStat tinyint
	declare @OnlineHours real
	declare @cspoints int
    Set @ConnectStat = 0     
    Set @find_id = 'NOT'
    select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id 
           where I.memb___id = @memb___id
    if( @find_id <> 'NOT' )    
    begin        
	SELECT @cspoints= cs_points FROM MEMB_INFO where memb___id = @memb___id
        update MEMB_STAT set ConnectStat = @ConnectStat, DisConnectTM = getdate(), OnlineHours = @cspoints/10+(DATEDIFF(hh,ConnectTM,getdate()))
         where memb___id = @memb___id
	SELECT  @OnlineHours =OnlineHours FROM MEMB_STAT WHERE memb___id = @memb___id

	UPDATE [dbo].[MEMB_INFO]
	SET cs_points=(@OnlineHours * 10)
	WHERE memb___id = @memb___id

    end
end
GO

with what line should first script end so the second script could be also executed? and with what line second script should start?
 
Back