神泣单机 - 在线泡点设置教程

管理员 shaiya 2019-8-12 14302

1. 添加在线状态
	设置 PS_UserData  库  Users_Master表添加列
	
	列名		数据类型		允许空
	online		int			√
-----------------------------------------
	设置 PS_GameData  库  Chars 表添加列
	
	列名		数据类型		允许空
	online		int			√
	
2.添加在线状态触发器
	设置 PS_GameLog  库  ActionLog表  触发器
	******************************SQL语句*****************************************************
	use PS_GameLog
	set ANSI_NULLS ON
	set QUOTED_IDENTIFIER ON
	go
	/*
	PS_GameLog  -  ActionLog  -  触发器
	账号设置	添加 PS_UserData  -  Users_Master  -  列= online 类型=int 默认值=0 允许空
	角色设置	添加 PS_GameData  -  Chars  -  列= online 类型=int 默认值=0 允许空
	功能: 
			记录账号、角色上线状态 
			记录账号、角色下线状态
			记录账号上线IP地址
	*/
	CREATE TRIGGER [Trig_online_update] ON [dbo].[ActionLog] FOR INSERT
	AS
	declare @ActionType tinyint
	declare @UserUID int
	declare @Text1 varchar(100)
	declare @CharID int
	select @UserUID=UserUID,@ActionType=ActionType,@Text1=Text1,@CharID=CharID from PS_GameLog.dbo.ActionLog
	/* 账号上线状态 记录IP */
	if @ActionType=107
	begin
	update PS_UserData.dbo.Users_Master set online=1,UserIp=@Text1 where UserUID=@UserUID
	end
	/* 账号下线状态 清空IP*/
	if @ActionType=108
	begin
	update PS_UserData.dbo.Users_Master set online=0,UserIp=NUll where UserUID=@UserUID
	end
	/* 角色上线状态*/
	if @ActionType=107
	begin
	update PS_GameData.dbo.Chars set online=1 where UserUID=@UserUID and CharID=@CharID
	end
	/* 角色下线状态*/
	if @ActionType=108
	begin
	update PS_GameData.dbo.Chars set online=0 where UserUID=@UserUID and CharID=@CharID
	end
	***********************************************************************************
	
	
3. 添加在线泡点
	
	***************************************执行sql语句************************************************
	USE [msdb]
	GO
	/****** 对象:  Job [在线泡点]    脚本日期: 01/08/2015 22:25:44 ******/
	BEGIN TRANSACTION
	DECLARE @ReturnCode INT
	SELECT @ReturnCode = 0
	/****** 对象:  JobCategory [[Uncategorized (Local)]]]    脚本日期: 01/08/2015 22:25:44 ******/
	IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
	BEGIN
	EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'[Uncategorized (Local)]'
	IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
	END
	DECLARE @jobId BINARY(16)
	EXEC @ReturnCode =  msdb.dbo.sp_add_job @job_name=N'在线泡点', 
			@enabled=1, 
			@notify_level_eventlog=0, 
			@notify_level_email=0, 
			@notify_level_netsend=0, 
			@notify_level_page=0, 
			@delete_level=0, 
			@description=N'无描述。', 
			@category_name=N'sa', 
			@owner_login_name=N'SHAIYASERVER\Administrator', @job_id = @jobId OUTPUT
	IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
	/****** 对象:  Step [泡点执行语句]    脚本日期: 01/08/2015 22:25:44 ******/
	EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'泡点执行语句', 
			@step_id=1, 
			@cmdexec_success_code=0, 
			@on_success_action=1, 
			@on_success_step_id=0, 
			@on_fail_action=2, 
			@on_fail_step_id=0, 
			@retry_attempts=0, 
			@retry_interval=0, 
			@os_run_priority=0, @subsystem=N'TSQL', 
			@command=N'update PS_UserData.dbo.Users_Master set point=point+1000 where online=1', 
			@database_name=N'PS_UserData', 
			@flags=0
	IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
	EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
	IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
	EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'泡点执行时间', 
			@enabled=1, 
			@freq_type=4, 
			@freq_interval=1, 
			@freq_subday_type=8, 
			@freq_subday_interval=1, 
			@freq_relative_interval=0, 
			@freq_recurrence_factor=0, 
			@active_start_date=20150108, 
			@active_end_date=99991231, 
			@active_start_time=0, 
			@active_end_time=235959
	IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
	EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
	IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
	COMMIT TRANSACTION
	GOTO EndSave
	QuitWithRollback:
		IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
	EndSave:
	******************************************************************************************************************
	
	***********************************手动执行步骤***********************************
	1. SQL server 代理 --> 作业 --> 新建作业 
	
	2. 常规 --> 名称(xxx)
	
	3.步骤 --> 新建 --> 步骤名称(xxx) --> 数据库 --> PS_UserData __
	__命令:update PS_UserData.dbo.Users_Master set point=point+200 where online=1 -->确定
	
	4. 计划 --> 名称(xxx) --> 计划类型(重复执行) (已启用) --> 频率 --> 执行(每天) ____
	__每天频率 --> 执行间隔 1 小时 --> 确定
	***********************************************************************************


最新回复 (1)
全部楼主
  • 中级神泣玩家 shunfeiair 2020-11-26
    0 2
    神泣发布网<www.shaiyasf.cc>我大力支持!
    • 温馨提示:请认真回帖,请勿回复垃圾内容,严重者直接封号处理!感谢支持!
      3
        立即登录 立即注册 QQ登录
返回
发新帖 此处广告位(50元1条 100元3条 200元10条)/月 此处广告位(50元1条 100元3条 200元10条)/月 此处广告位(50元1条 100元3条 200元10条)/月 此处广告位(50元1条 100元3条 200元10条)/月 此处广告位(50元1条 100元3条 200元10条)/月 此处广告位(50元1条 100元3条 200元10条)/月 此处广告位(50元1条 100元3条 200元10条)/月 此处广告位(50元1条 100元3条 200元10条)/月 此处广告位(50元1条 100元3条 200元10条)/月