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!

[Help] How to increase an integer by 1 every minute

Joined
Dec 16, 2011
Messages
1,994
Reaction score
632
Well it would be great if you told us more details, such as where do you want to implement such script? Will it be in PHP, or a server (emulator, or such..)? Mind you, if you have a lot of visitors, it may become somewhat resource hungry.
 
Watching from above
Legend
Joined
Apr 9, 2004
Messages
3,828
Reaction score
752
In many situations I would try to avoid such operations if possible and instead calculate the points any time they are needed from minutes passed since logged in. Should be simplier, too. Only on log out or any time you spend points you'd persist the current value.
 
  • Like
Reactions: x42
Joined
Feb 21, 2014
Messages
408
Reaction score
69
Here is the only code in the stored procedures that has anything to do with time in the database.

Code:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
/****** 개체: 저장 프로시저 dbo.up_GameLogout    스크립트 날짜: 2006-07-26 오후 4:09:34 ******/





--exec up_GameLogout_test 104387




ALTER        PROC [dbo].[up_GameLogout]
(        
/*
작성자 : 김현수(sizz@esofnet.com)
요약 : 코룸 게임 로그아웃 빼끼기
작성일 : 2004.01.20. 오전 10 : 18
수정사항 : 상용화 V. 0.2
*/ [USER=524049]Pro[/USER]pid varchar(20), [USER=873895]KIN[/USER]D INT = 0
)        
AS        

SET NOCOUNT ON         

DECLARE [USER=1333401102]LogiN[/USER]_id varchar(20)      --아이디
DECLARE @ip char(15)      --접속 아이피
DECLARE @type int      --결제타입에 따라서 다른 로그아웃 처리
DECLARE @USE_TIME int      --사용한 시간(개인,1시간무료 및 PC방 시간제)

DECLARE [USER=418890]nal[/USER]ja varchar(10)      --날짜 (2004106)
DECLARE @play_time int      --플레이시간   

DECLARE [USER=1333359122]SQL[/USER] varchar(4000)      --쿼리 작성용 변수       

DECLARE @utime int


DECLARE @PC_ID varchar(20)    --PC방 아이디

DECLARE @cur_day  char(10) --'현재시간 


--넘어온 유저 고유값에 해당하는 아이디를 가져온다
Set [USER=1333401102]LogiN[/USER]_id = (Select id_loginid From chr_log_info with(nolock) where propid [USER=524049]Pro[/USER]pid)

/*@type
0 - 무조건 공짜

1 - PC방 IP  PC_ip_ing/pc_ranky
2 - 개인 기간
3 - PC방 시간 pc_ranky/Time_PC
4 - 개인 시간  Time_User
9 - 무료 1시간
*/

set @type=0

--해당 아이디가 LoginTable에 존재한다면 (즉, 게임에 접속중이라면)
IF EXISTS (SELECT 1 FROM LoginTable with(nolock) WHERE user_id = [USER=1333401102]LogiN[/USER]_id)
     BEGIN    
          --접속 아이피, 접속한 서버, 과금 타입, 플레이한 시간을 가져온다
         --SELECT @ip=ip, [USER=873895]KIN[/USER]d=kind, @type=type, @USE_TIME=DATEDIFF(ss,Login_Date,getdate()) 
    SELECT @USE_TIME=DATEDIFF(ss,Login_Date,getdate()) 
              FROM LoginTable with(nolock) 
              WHERE user_id = [USER=1333401102]LogiN[/USER]_id
    BEGIN TRAN
    
    UPDATE LOGIN_LOG
    SET END_DATE = GETDATE()
    WHERE LOGIN_ID  = [USER=1333401102]LogiN[/USER]_ID AND
        START_DATE IN
    (
        SELECT LOGIN_DATE
        FROM LOGINTABLE WITH(READUNCOMMITTED)
        WHERE USER_ID = [USER=1333401102]LogiN[/USER]_ID
    )
    --2. 나간 시간 저장하기    
    UPDATE chr_log_info 
              SET game_out_date=getdate(), total_game_time=total_game_time+@USE_TIME 
              WHERE id_loginid [USER=1333401102]LogiN[/USER]_id

               --개인날짜별  플레이시간 저장(통계)---------------------------    
               SET @play_time =(SELECT datediff(mi,game_in_date,game_out_date) FROM chr_log_info with(nolock) WHERE id_loginid [USER=1333401102]LogiN[/USER]_id)

              SET @cur_day = (SELECT convert(char(10),getdate(),112)) 

               IF EXISTS (SELECT 1 FROM play_time_log with(nolock) WHERE id_loginid [USER=1333401102]LogiN[/USER]_id and play_date=@cur_day)
                    BEGIN
                         UPDATE play_time_log 
                         SET usetime=usetime + @play_time 
                         WHERE id_loginid [USER=1333401102]LogiN[/USER]_id and play_date=@cur_day
                    END
               ELSE
                    BEGIN
                         INSERT INTO play_time_log (play_Date,id_loginid,usetime) VALUES(@cur_day [USER=1333401102]LogiN[/USER]_id,@play_time)
                    END

               -- 3. Logintable 에 데이타 삭제
     DELETE FROM LoginTable 
               WHERE user_id = [USER=1333401102]LogiN[/USER]_id  

               /*공통 처리사항 */
     IF @@error > 0
          BEGIN
               ROLLBACK TRAN
               RETURN 0
          END
     ELSE
          BEGIN
               COMMIT TRAN
         RETURN 1
          END        
     END
 
◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜
Developer
Joined
May 29, 2007
Messages
2,167
Reaction score
899
I mean the game already logs the amount of time the account was logged in. But it records it in seconds. I want to change it to minutes instead..

Divide with 60.
 
Back
Top