How to install:
1: Open up your query analyser.
2: Paste this query, but don't execute yet.
Code:
USE master
CREATE DATABASE ban_info ON PRIMARY
(
NAME = baninfodata,
FILENAME = 'C:\DATABASES\baninfodata.mdf',
SIZE = 20MB,
MAXSIZE = UNLIMITED
)
LOG ON
(
NAME = baninfolog,
FILENAME = 'C:\DATABASES\baninfolog.ldf',
SIZE = 5MB,
MAXSIZE = UNLIMITED
)
GO
CREATE TABLE ban_info.dbo.ban_log
(
IP varchar(50) NOT NULL,
ip2long varchar(50),
Reason varchar(50),
ReasonInfo varchar(50),
DateBanned varchar(50),
Action_taken varchar(50),
PRIMARY KEY (IP)
)
GO
USE ban_info;
GO
/*
Name: Anti-GM-Hack
Version: V2.1
Description
1: Deletes all GM characters not stated in this procedure.
2: Automaticly bans their accounts and IPs.
3: Logs each ban.
Code:
USE master
CREATE DATABASE ban_info ON PRIMARY
(
NAME = baninfodata,
FILENAME = 'C:\DATABASES\baninfodata.mdf',
SIZE = 20MB,
MAXSIZE = UNLIMITED
)
LOG ON
(
NAME = baninfolog,
FILENAME = 'C:\DATABASES\baninfolog.ldf',
SIZE = 5MB,
MAXSIZE = UNLIMITED
)
GO
CREATE TABLE ban_info.dbo.ban_log
(
IP varchar(50) NOT NULL,
ip2long varchar(50),
Reason varchar(50),
ReasonInfo varchar(50),
DateBanned varchar(50),
Action_taken varchar(50),
PRIMARY KEY (IP)
)
GO
USE ban_info;
GO
/*
Name: Anti-GM-Hack
Version: V2.1
Description
1: Deletes all GM characters not stated in this procedure.
2: Automaticly bans their accounts and IPs.
3: Logs each ban.
Author: Zombe
*/
CREATE PROCEDURE AntiGmHack
AS
DECLARE @user_ip_addr varbinary(4);
DECLARE @DecimalIP varchar(20);
DECLARE @character_name varchar(40);
DECLARE @user_no varchar(50);
DECLARE @user_id varchar(50);
DECLARE @reason varchar(50);
SELECT
@character_name = character_name,
@user_ip_addr = user_ip_addr,
@user_no = user_no
FROM character.dbo.user_character
WHERE
character_name LIKE '_DEV_%'
AND user_no <> '19999999999991'
OR character_name LIKE '_DEKARON_%'
OR character_name LIKE '_GM_%'
AND character_name <> '[GM]Zombe'
AND character_name <> '[GM]YourName'
AND character_name <> '[GM]Etcetera'
;
if (@character_name IS NOT NULL)
BEGIN
SET @DecimalIP =
(Cast(Cast(SubString(@user_ip_addr, 1, 1) AS Int) As Varchar(3)) + '.' +
Cast(Cast(SubString(@user_ip_addr, 2, 1) AS Int) As Varchar(3)) + '.' +
Cast(Cast(SubString(@user_ip_addr, 3, 1) AS Int) As Varchar(3)) + '.' +
Cast(Cast(SubString(@user_ip_addr, 4, 1) AS Int) As Varchar(3)));
DELETE FROM character.dbo.user_character
WHERE character_name = @character_name;
SELECT @user_id = user_id
FROM account.dbo.Tbl_user
WHERE
user_no = @user_no;
SET @reason =
'Acc: ' +
@user_id +
' for creating a character' +
@character_name;
INSERT INTO ban_info.dbo.ban_log
(
IP,
ip2long,
Reason,
ReasonInfo,
DateBanned,
Action_taken
)
VALUES
(
@DecimalIP,
'Auto-Ban',
'GM hack',
@reason,
GetDate(),
'Banned IP and account, deleted hacked character'
);
INSERT INTO account.dbo.C_IP_BAN
(
start_ip,
end_ip,
ipt_time
)
VALUES
(
@user_ip_addr,
@user_ip_addr,
GetDate()
);
UPDATE account.dbo.USER_PROFILE
SET
login_tag = 'N'
WHERE
user_no = @user_no OR
user_ip_addr = @user_ip_addr
;
END;
3: Find the place in the query where it says:
AND character_name <> '[GM]Zombe'
AND character_name <> '[GM]YourName'
AND character_name <> '[GM]Etcetera'
Replace the names with the GM names you want to be excluded from banning.
If you would like, you can add more names, or delete. Just add another line under these, like
AND character_name <> 'GM's name'
4: Scroll up to the top of the script, find the place where it says:
FILENAME = 'C:\DATABASES\baninfodata.mdf'
and
FILENAME = 'C:\DATABASES\baninfolog.ldf'
Replace the directory (C:\DATABASES\) to where you keep your database files (sergcool uses C:\ but I think that's stupid.). Make sure the directory exists!
5: Once you have done that, run the query.
6: Turn on the SQL Server Agent from the SQL service manager.
7: Go to the Enterprise Manager,
go Management --> SQL Server Agent --> Jobs.
8: Create a new job, name it for example AntiGmHackV2.
9: Go to steps, press NEW, name it lets say "Execute stored procedure", select database ban_info, and at command write:
Code:
exec AntiGmHack;
Press OK.
10: Create new step, name it lets say "Wait", set database to ban_info (though its not 100% necessary), write the command:
Code:
WAITFOR DELAY '000:00:02';
Go advanced, set both on success and on failure actions to:
Goto step [1] Execute Stored Procedure
We want the on failure to that too, so that if the job accidentally lags for a bit, it still keeps running.
11: Open step 1 again, go advanced, set both on success and on failure actions to:
Goto step [2] Wait
12: Press OK in the job, click YES when it asks you.
13: If you have AntiGmHack V1 by silkbotter running, stop that job.
14: Rightclick the job, click start job, then START.
AntiGmHack V2 is running!
To edit the GMs list (If lets say a new GM joins):
1: Go to Databases --> ban_info --> Stored Procedures --> Doubleclick AntiGmHack
2:
Find
AND character_name <> 'Your 1st gm'
AND character_name <> 'Your 2nd GM'
etc
And delete 1 line, or add 1 line, according to your GM's name.
3: Press OK.
Your GM list is modified.