Jump to content
Sign in to follow this  
V3ct0r

Auto-ban

Recommended Posts

Auto-ban

Credits:  insider

The following SQL trigger will ban a player when he enters the game, if there are already banned accounts with the same MAC-address.

USE AccountServer
GO
CREATE TRIGGER auto_ban
   ON account_login
   AFTER UPDATE
AS
BEGIN
    IF UPDATE(last_login_mac)
    BEGIN
        DECLARE @mac varchar(50), @count int
        SELECT @mac = last_login_mac FROM inserted
        SELECT @count = COUNT(*) FROM account_login WHERE last_login_mac = @mac AND ban = 1 AND last_login_mac <> '00-00-00-00-00-00-00-00' AND last_login_mac <> ''
        IF @count <> 0
        BEGIN
            ROLLBACK
            UPDATE account_login SET ban = 1 WHERE last_login_mac = @mac AND ban = 0
        END
    END
END

 

How to install:

Open MSSQL Management studio and press button 'New Query' on tool bar or CTRL + N. Then execute (F5) the SQL Query above:

a87af01549bdt.jpg

  • Like 4

Share this post


Link to post
Share on other sites

Very helpful, thanks!

 

Just leaving this here if you wish to Disable the trigger:

 

Run New Query with this:

USE AccountServer
GO
; DISABLE TRIGGER dbo.auto_ban ON dbo.account_login

I believe if you want it to be enabled just change 'DISABLE' to 'ENABLE' (Untested)

Edited by Sultan

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

×
×
  • Create New...