Basic Admin Tool has 3 built in ways of dealing with SQL, all explained bellow, but its not required it still supports a users.ini file if thats what you want. MySQL is vell suited to if you have multiple servers or have alot of admins ( BAT has been known to have 1500+ users in a text file without problems, but in cases like this MySQL is better). The reason for this is that the SQL code is threaded, so the main server does not "hang" while BAT checks what access a spesfic user has.
bat_mysql 1
This mode is the standard mode that the most stripped down, its the standard one that comes with its own homegown web interface that can be downloaded here. Please note that the webinterface is very crude and is not for everyone.
To use this mode you need the following table in MySQL table.
CREATE TABLE `admin` (
`AdminCount` int(10) unsigned NOT NULL auto_increment COMMENT 'Contains the number of admins on in the SQL server',
`PlayerID` varchar(64) NOT NULL COMMENT 'The uniqe ID of the player, like his steam id or IP address',
`AdminFlags` varchar(45) NOT NULL COMMENT 'The access of the player, to know more about the flags, check the users.ini',
`AdminName` varchar(45) NOT NULL,
PRIMARY KEY (`AdminCount`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Where BAT admin accounts are checked' AUTO_INCREMENT=1 ;
CREATE TABLE `log` (
`LogCount` int(10) unsigned NOT NULL auto_increment,
`ServerIP` varchar(45) NOT NULL,
`AdminID` varchar(45) NOT NULL,
`LogEntry` varchar(260) NOT NULL,
`LogTime` datetime NOT NULL,
PRIMARY KEY (`LogCount`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
bat_mysql 2
This mode of MySQL mode uses amxbans to control admins, this mode is very usefull if you run both hlds ( halflife 1 ) and srcds ( Halflife 2) servers and you want to share a admin access. When this mode is active {cms_selflink page='60' text='BAT '} converts amxmodx style admin access to what {cms_selflink page='60' text='BAT '} uses internaly.
When using this mode run the following commands on the SQL commmands:
CREATE VIEW bat_admin AS
SELECT adm.id "AdminCount", adm.steamid "PlayerID", adm.access "AdminFlags", adm.nickname "AdminName",srv.address "SrvAddress", srv.id "SrvId"
FROM amx_amxadmins AS adm
LEFT JOIN amx_admins_servers AS admSrv ON adm.id=admSrv.admin_id
LEFT JOIN amx_serverinfo AS srv ON srv.id=admSrv.server_id
WHERE admSrv.server_id IS NOT NULL
Remember you still need the logs table, where BAT adds its log information:
CREATE TABLE `log` (
`LogCount` int(10) unsigned NOT NULL auto_increment,
`ServerIP` varchar(45) NOT NULL,
`AdminID` varchar(45) NOT NULL,
`LogEntry` varchar(260) NOT NULL,
`LogTime` datetime NOT NULL,
PRIMARY KEY (`LogCount`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
bat_mysql 3
This mode uses sourcebans . In this mode BAT is going to convert sourcemod style admin rights to what BAT uses internaly.
SQL command you need to run:
DELIMITER //
DROP FUNCTION IF EXISTS uniqueChars//
CREATE DEFINER=sourcebansuser FUNCTION uniqueChars(s TEXT) RETURNS TEXT
DETERMINISTIC
BEGIN
DECLARE output TEXT DEFAULT '';
DECLARE temp CHAR(1);
DECLARE i INT DEFAULT 1;
WHILE i < LENGTH(s) DO
SET temp = SUBSTR(s FROM i FOR 1);
IF NOT LOCATE(temp, output) THEN
SET output = CONCAT(output, temp);
END IF;
SET i = i + 1;
END WHILE;
RETURN output;
END//
DELIMITER ;
CREATE OR REPLACE DEFINER=sourcebansuser VIEW bat_admin AS
SELECT
a.authid identity,
uniqueChars(GROUP_CONCAT(CONCAT(COALESCE(TRIM(a.srv_flags), ''), COALESCE(TRIM(ag.flags), '')) SEPARATOR '')) flags,
a.user,
GREATEST(sg.server_id , asg.server_id) server_id
FROM
sb_admins_servers_groups asg
LEFT JOIN
sb_admins AS a ON a.aid = asg.admin_id
LEFT JOIN
sb_srvgroups AS ag ON ag.id = asg.group_id
LEFT JOIN
sb_servers_groups AS sg ON sg.group_id = asg.srv_group_id
WHERE
srv_group_id = ANY(SELECT sg.group_id FROM sb_servers_groups)
AND a.aid IS NOT NULL AND
(
(LENGTH(TRIM(a.srv_flags)) > 0 AND a.srv_flags IS NOT NULL) OR
(LENGTH(TRIM(ag.flags)) > 0 AND ag.flags IS NOT NULL)
)
GROUP BY
Cvar settings:
bat_sqladmintable = should point to your BAT view table ( default "bat_admin" )