MySQL plugin which keep playerlist table up-to-date. Humans only.
Table store name, steamid, score and time
- Then do what ever you like with that table, for example, make PHP page of current players.
Installation MySQL table:
- You need manually create table with rows in MySQL, plugin won't do that for you. (I'm lazy to code that part)
- Go phpMyAdmin and select or create database where you want new table.
- After you selected database, go to sql tab page.
- Use these 3 steps queries
Code:
(XAMPP) MySQL PHPMyAdmin sql query steps:
1)
DROP TABLE IF EXISTS `playerlist`;
2)
CREATE TABLE `playerlist` ( `clientid` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(128) NULL DEFAULT NULL ,
`steamid` VARCHAR(128) NULL DEFAULT NULL ,
`score` INT NOT NULL DEFAULT '0' ,
`time` VARCHAR(15) NULL DEFAULT NULL , PRIMARY KEY (`clientid`));
3)
DELIMITER $$
DROP PROCEDURE IF EXISTS test$$
CREATE PROCEDURE test()
BEGIN
DECLARE count INT DEFAULT 1;
WHILE count <= 65 DO
INSERT INTO `playerlist` () VALUES ();
SET count = count + 1;
END WHILE;
END$$
DELIMITER ;
CALL test();
If you have table called playerlist and it have about 65 rows empty data, you are good to go
Installation plugin configure:
- Go ...addons\sourcemod\configs\databases.cfg
- Add playerlist configure with your right database name, example
Code:
"Databases"
{
"driver_default" "mysql"
// When specifying "host", you may use an IP address, a hostname, or a socket file path
"default"
{
"driver" "default"
"host" "localhost"
"database" "sourcemod"
"user" "root"
"pass" ""
//"timeout" "0"
//"port" "0"
}
"playerlist"
{
"driver" "default"
"host" "localhost"
"database" "database_test"
"user" "root"
"pass" ""
//"timeout" "0"
//"port" "0"
}
"storage-local"
{
"driver" "sqlite"
"database" "sourcemod-local"
}
"clientprefs"
{
"driver" "sqlite"
"host" "localhost"
"database" "clientprefs-sqlite"
"user" "root"
"pass" ""
//"timeout" "0"
//"port" "0"
}
}
Install plugin:
- mysqlplayerlist.smx into ...addons\sourcemod\plugins folder.
Plugin: No commands
No cvars
No other settings
Secrects:
In plugin source code *.sp, you can include bots, change table name or change update delay from line
108-110
...and compile your edited plugin.
In-depth how plugin works
- This plugin automatically connect and disconnect to database, depends is there players in server.
Plugin load and player_connect event start database connection.
Disconnect when no players in server or unload plugin.
- Plugin update table every 10 seconds, when there are players in server.
Plugin keep track and update only necessary player slots, sending less queries to database.
- Plugin only updates playerlist table clientid rows. Not remove or insert values.
When player slot is empty in server, plugin set DEFAULT values to that clientid row in table.
- If you get later trouble with playerlist table, repeat those 3 steps (query codes at top of post)
- Player score is taken from entity *player_manager "m_iScore".
Most games have this entity, but I don't know is it supported in all games.
Thanks to:
AlliedModders devs, users, forum posts, API and wiki
Other forum users plugin source codes
Stack Overflow posts
Google and translation
YouTube
Valve
Gabe
Microsoft, GitHub
AMD, Intel, Nvidia
Free Programs from internet black hole
No thank you:
spambots
ads
This plugin is just for example to all who are interested, edit and make it to own version.
That is why it have few information stored into database table, it is not Rank plugin.
*edit
Dam, plugin source code not compile in this page.
Need compile yourself