Raised This Month: $ Target: $400
 0% 

SQL Ban (not AMXbans)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BlancMange
New Member
Join Date: Mar 2009
Old 03-25-2009 , 03:39   SQL Ban (not AMXbans)
Reply With Quote #1

Hi, i run a large amount of public servers, and we have moved to a custom centralised ban database in SQL

We have a sourcemod plugin that on player connection checks their steamid against our own custom bans database, and if the ban is still active, the user is kicked and the server sets a 5minute ban on their steamid.

I understand what's happening in source mod, but i am having a lot of issue porting it to amxmodx for use on our 1.6 servers.

Would it be possible (if i post the sourcemod scripting file) for someone to explain to me, how to convert it into amxmodx, or guide me along the way?

below is the sourcemod code:
PHP Code:
#include <sourcemod>
#define PLUGIN_VERSION "0.1"


public Plugin:myinfo =
{
    
name        "SteamID Validator",
    
author    "User",
    
description    "Validates users from the Ban database.",
    
version    PLUGIN_VERSION,
    
url        "site"
}


new 
Handle:hDatabase        INVALID_HANDLE;
new 
Handle:g_Enable        INVALID_HANDLE;
new 
Handle:g_LocalBanLength    INVALID_HANDLE;
new 
Handle:g_BanMessage        INVALID_HANDLE;


public 
OnPluginStart()
{

    
// Settings
    
g_Enable        CreateConVar("sqlban_enable""1""Enable or disable the plugin.")
    
g_LocalBanLength    CreateConVar("sqlban_localbanlength""5""How long do you want to ban the player locally after being kicked? If set to -1 locally bans are disabled, and the player will just be kicked.")
    
g_BanMessage    CreateConVar("sqlban_banmessage""[sqlBAN] You are banned from this server!""The message that's showed to the user when kicked or banned.")
    
CreateConVar("sqlban_sm_version"PLUGIN_VERSION"sqlBan SteamID Validator Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY)



    
// Misc (Connection to DB/Give deactivation warning)
    
if (GetConVarInt(g_Enable) == 1)
    {
        
SQL_TConnect(GotDatabase);
        
//SQL_TConnect(GotDatabase, "amxbans")
        
PrintToServer("[sqlban] Connecting to DB")
    }
    else if (
GetConVarInt(g_Enable) == 0)
    {
        
PrintToServer("[sqlban] WARNING - The plugin is disabled!")
        
PrintToServer("[sqlban] This will disable the check for banned players. To reactivate, set 'sqlban_enable' to 1")
    }

}


public 
GotDatabase(Handle:ownerHandle:hndl, const String:error[], any:data)
{

    if (
hndl == INVALID_HANDLE)
    {
        
LogError("[sqlban] Database failure: %s"error);
        
PrintToServer("[sqlban] Failed to connect to DB")
    }
    else
    {
        
PrintToServer("[sqlban] Connected to DB")
        
hDatabase hndl;
    }

}


public 
OnClientAuthorized(userid, const String:auth[])
{

    if (
GetConVarInt(g_Enable) == 1)
    {
        
decl String:query[255];
        
Format(querysizeof(query), "SELECT `steamid` FROM user_bans WHERE `status` = 'true' AND ((`stamp`+0)>20060101000000) AND (`length` = '0' OR (adddate(`stamp`, INTERVAL `length` MINUTE)+0)>(NOW()+0)) AND `player_game_id` = '%s'"auth);
        
        
SQL_TQuery(hDatabaseT_CheckSteamIDqueryuserid)
    }
    else if (
GetConVarInt(g_Enable) == 0)
    {
        
PrintToServer("[sqlban] The plugin is disabled. Player not checked!")
    }

}


public 
T_CheckSteamID(Handle:ownerHandle:hndl, const String:error[], any:player)
{

    
// Make sure the client didn't disconnect while the thread was running
    
if(!IsClientConnected(player) && player 0)
    {
        return;
    }

    if (
hndl == INVALID_HANDLE)
    {
        
LogError("[sqlban] Query failed! %s"error);
    }
    else if (
SQL_GetRowCount(hndl))
    {
        new 
BanTime GetConVarInt(g_LocalBanLength)
        new 
String:BanReason[64]
        
GetConVarString(g_BanMessage,BanReason,64)

        if (
GetConVarInt(g_LocalBanLength) == -1)
        {
            
KickClient(playerBanReason)
        }
        else
        {
            
BanClient(
                
player
                
BanTime
                
BANFLAG_AUTO
                
BanReason
                
BanReason
                
"local_ban",
                
player);
        }
    }


Thanks in advance
-Blanc
BlancMange is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode