Very nice, I have been looking into some of the work. I would myself change this:
PHP Code:
CREATE TABLE IF NOT EXISTS `players` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`user` varchar(32) DEFAULT NULL,
`pass` varchar(32) DEFAULT NULL,
`money` int(10) DEFAULT NULL,
`xp` int(10) DEFAULT NULL,
`kills` int(10) DEFAULT NULL,
`headshots` int(10) DEFAULT NULL,
`melee_kills` int(10) DEFAULT NULL,
`longest_killstreak` int(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
to
PHP Code:
CREATE TABLE IF NOT EXISTS `players` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`user` varchar(32) DEFAULT NULL,
`pass` varchar(32) DEFAULT NULL,
`money` int(10) DEFAULT 0,
`xp` int(10) DEFAULT 0,
`kills` int(10) DEFAULT 0,
`headshots` int(10) DEFAULT 0,
`melee_kills` int(10) DEFAULT 0,
`longest_killstreak` int(10) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Now you don't need to set the value for money, xp etc.. Also you don't need to use the function IFNULL to check if the value is null. Like is done here:
PHP Code:
CREATE FUNCTION statsDeltaMoney (id_ INT, money_ INT)
RETURNS INT
DETERMINISTIC
BEGIN
DECLARE ret INT;
SET ret = NULL;
UPDATE players SET money=IFNULL(money,0)+money_ WHERE id = id_;
SELECT money FROM players WHERE id = id_ INTO ret;
RETURN ret;
END