Jump to content

Trade OnlineHours for Reward Script


wannabepro

Recommended Posts

i am working on multiplayer online game and i am having some difficulties with basic sql stuff.

my system is windows 7 x64 and sql 2005 with SP4

 

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.

 

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.

 

here is how my database structure looks like:

30cwvpj.jpg

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.