Very Basic Player Tracker
This plugin is a simple player tracker that logs player information into a MySQL database. It uses the "default" database from your databases.cfg file for storage. It logs the player name, SteamID, player's IP address, server game type (using GetGameFolderName()) and server IP address, and the GeoIP country code for the player's location. It logs this information X seconds after being connected, which is controlled with a cvar. This is useful if you only want to keep track of players who are connected for a minimum amount of time, the default is 90 seconds. If a duplicate player is found, it updates their information
I am not providing any web interface at this time, though I may in the future. This is really just a base for anyone who may want to develop it further, or use it for a more specific purpose. For those of you in need of a web interface, I highly recommend using the
Sourcemod Webadmin which has built in support for this plugin!
Feel free to use this code for any other plugins, however please give credit back to me.
Installation
Installation is incredibly easy, install the plugin in your /addons/sourcemod/plugins/ directory and refresh your plugin list, or change map.
Configuration
A config file will automatically be generated in /cfg/sourcemod/ when the plugin is first ran.
sm_tracker_addtime - Add/update players in the database after this many seconds
sm_tracker_geoiptype - Add player's GeoIP country to the database. 0 = Disabled, 1 = 2 letter Country Code, 2 = 3 letter Country Code, 3 = full Country Name.
Use this SQL to create your table.
PHP Code:
CREATE TABLE `player_tracker` (
`id` int(11) NOT NULL auto_increment,
`steamid` varchar(255) NOT NULL,
`playername` varchar(255) NOT NULL,
`playerip` varchar(255) NOT NULL,
`servertype` varchar(255) NOT NULL,
`serverip` varchar(255) NOT NULL,
`serverport` varchar(255) NOT NULL,
`geoipcountry` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `steamid` (`steamid`),
KEY `playername` (`playername`),
KEY `playerip` (`playerip`),
KEY `servertype` (`servertype`),
KEY `serverip` (`serverip`),
KEY `status` (`status`)
);