Donation System Isn't Giving Ranks After Donation

Info:
Server IP: 206.221.191.179:27015
Donation System: Donation System 2
MySQLOO Version 8.1
Server GM: DarkRP

I have setup the ranks properly I think, but what I’m not sure of is whether or not I setup the mysql connections properly.
Pretty much, everything works except the giving the rank automatically part.

Things that say REMOVED are things I’m not showing for security reasons.

Any help would be GREATLY appreciated.

Donation System Config.php (Connects to website mysql):


<?php

define("DB_HOST", "localhost"); // MySQL Server
define("DB_USERNAME", "troublegaming"); // MySQL Username
define("DB_PASSWORD", "REMOVED"); // MySQL Password
define("DB_DATABASE", "troublegaming_darkrp"); // MySQL Database. Not recommended to use same database that your server(s) use, but if you want you can

/*
To test donation system, enable sandbox and during purchase use following sandbox account:
email: edgarasf123-buyer@gmail.com
password: testtest1

When done testing switch sandbox off, and replace "realemail@example.com" with your email
*/
define("PAYPAL_CURRENCY", "USD"); // Currency for your system
define("PAYPAL_SANDBOX", true); // Sandbox mode
define("PAYPAL_ID", PAYPAL_SANDBOX ? "edgarasf123-facilitator@gmail.com" : "REMOVED"); // Replace realemail@example.com with your paypal login


define("STEAM_API", "REMOVED"); // http://steamcommunity.com/dev/apikey
define("DONATE_URL", "http://troublegaming.site.nfoservers.com/Donate/"); // Address where the system is located


$GAMES = array( // All games
	"gmod" => array( // GameID
		"name" => "Garry's Mod", //Game name
		"icon" => "icons/gmod.png", //Game icon
		"display" => true, // Should display on front page
		"servers" => array("darkrp") // What servers does it have( defined in $SERVERS section), use ServerID
	)
);
$SERVERS = array( // All servers
	"darkrp" => array( // ServerID
		"name" => "DarkRP", // Server Name
		"icon" => "icons/gmod.png", // Server Icon
		"dbtable" => "darkrp_orders", // Server database
		"products" => array(1, 2) // What products does this server have( defined in $PRODUCTS section ), use ProductID
	)
);
$PRODUCTS = array( // All products
1 => array( // ProductID, must be numbers
		"title" => "Bronze VIP (One Month)", //Title that is displayed on third section(Products)
		"buytitle" => "DarkRP - Bronze VIP (One Month)", //Title that is displayed on fourth section(Checkout) and during PayPal purchase
				// Description is shown in third section when you select product, its in HTML
		"description" => " 
			<b>Price: <b style='color:green;'>$5</b></b>
			</br>
			<b>Features:</b><br/>
			<b>1.</b> $250,000 In-game Cash<br/>
			<b>2.</b> Bronze In-game Name<br/>
			<b>3.</b> Jobs Include: Access to SWAT, Military, Chinese Mob Boss, Italian Mob Boss, Crips Leader, Bloods Leader, & Many More!<br/><br/>
			<b style='color:red;'>This rank is valid for 30 days and if abused it will be taken away. Also, you must be online to receive your rank!</b>",
		"price" => 5, // Price of your product
		"servers" => array( // Servers that this product going to be activated on
			"darkrp" => array( // ServerID
				"offline" => false, // Should ran when player is not connected? Not recommended 
				"execute" => array( // Execute certain commands, please refer to readme.html
					"rank" => array( "group" => "vipbronze" , "duration" => 500000),
					"darkrp_money" => 250000,
					"pointshop_points" => 0,
					"print" => array( array(255,0,0) ,"You have bought one month of Bronze VIP!" ),
					"broadcast" => array( array(255,0,0) ,"%name% have bought one month of Bronze!" ),
					"lua" => "ServerLog(PLAYER:Nick() .. ' bought bronze one month\
')" // <- Dont put comma at the end of array
				)
			)
		)
	),
	2 => array( // ProductID, must be numbers
		"title" => "Bronze VIP (LifeTime)", //Title that is displayed on third section(Products)
		"buytitle" => "DarkRP - Bronze VIP (LifeTime)", //Title that is displayed on fourth section(Checkout) and during PayPal purchase
				// Description is shown in third section when you select product, its in HTML
		"description" => " 
			<b>Price: <b style='color:green;'>$10</b></b>
			</br>
			<b>Features:</b><br/>
			<b>1.</b> $250,000 In-game Cash<br/>
			<b>2.</b> Bronze In-game Name<br/>
			<b>3.</b> Jobs Include: Access to SWAT, Military, Chinese Mob Boss, Italian Mob Boss, Crips Leader, Bloods Leader, & Many More!<br/><br/>
			<b style='color:red;'>This rank is valid for 30 days and if abused it will be taken away. Also, you must be online to receive your rank!</b>",
		"price" => 10, // Price of your product
		"servers" => array( // Servers that this product going to be activated on
			"darkrp" => array( // ServerID
				"offline" => false, // Should ran when player is not connected? Not recommended 
				"execute" => array( // Execute certain commands, please refer to readme.html
					"rank" => array( "group" => "vipbronze" , "duration" => 500000),
					"darkrp_money" => 250000,
					"pointshop_points" => 0,
					"print" => array( array(255,0,0) ,"You have bought one month of Bronze VIP!" ),
					"broadcast" => array( array(255,0,0) ,"%name% have bought one month of Bronze!" ),
					"lua" => "ServerLog(PLAYER:Nick() .. ' bought bronze one month\
')" // <- Dont put comma at the end of array
				)
			)
		)
	)
);

// DONT TOUCH THIS
define("PAYPAL_URL", PAYPAL_SANDBOX ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr"   )
?>


Rank_system.lua (Connects to MySQLOO):


local DB_HOST = "REMOVED"
local DB_PORT = 3306
local DB_DATABASE = "CameronS"
local DB_USERNAME = "CameronS"
local DB_PASSWORD = "REMOVED"
local DB_TABLE = "darkrp_ranks"

require("mysqloo")
if not mysqloo then
	Error("[RankSystem] No mysqloo was found")
	return nil
end
RankSystem = {}
RankSystem.players = {}

local queue = {} 
local db = mysqloo.connect( DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT )

local function query( sql, callback ) -- If not connected, connect and repeat query
	local q = db:query( sql )
	if not q then	
		table.insert( queue, { sql, callback } )
		db:connect()
		return
	end
	function q:onSuccess( data )
		callback( data )
	end
	function q:onError( err )
		if db:status() == mysqloo.DATABASE_NOT_CONNECTED then
			table.insert( queue, { sql, callback } )
			db:connect()
			return
		end
		Error( "[RankSystem] Query Error:", err, " sql: ", sql, "
" )
	end
	q:start()
end

local function getSteamID( ply )
	if type(ply) == "Player" then
		return string.upper( ply:SteamID() )
	elseif type(ply) == "string" then
		return string.upper( ply )
	end
	return nil
end

function db:onConnected()	
	ServerLog("[RankSystem] Connected to database
")

	for k, v in pairs( queue ) do
		query( v[ 1 ], v[ 2 ] )
	end
	queue = {}
end
 
function db:onConnectionFailed( err )
    Error( "[RankSystem] Connection to database failed!
" )
    Error( "[RankSystem] Error:", err, "
" )
end
db:connect()


local function DatabaseLoad()
	query([[
	CREATE TABLE IF NOT EXISTS `]]..DB_TABLE..[[` (
	`steamid` varchar(40) NOT NULL,
	`rank` varchar(20) NOT NULL,
	`expire` INT UNSIGNED NOT NULL,
	UNIQUE KEY (`steamid`)) ]], function()	
		query("SELECT * FROM `"..DB_TABLE.."`", function(data)
			for _, plydata in pairs(data) do
				if type(plydata) == "table" then
					RankSystem.players[plydata.steamid] = {}
					RankSystem.players[plydata.steamid].rank = data.rank
					RankSystem.players[plydata.steamid].expire = tonumber(data.expire)
				end
			end
		end)
	end)
end
hook.Add( "Initialize", "RankSystemDatabaseLoad", DatabaseLoad )

function RankSystem.AddUser( ply, rank, duration )
	local steamid = getSteamID( ply )
	if steamid == nil then return end
	
	ULib.ucl.addUser( steamid, allows, denies, rank )

	RankSystem.players[steamid] = {}
	RankSystem.players[steamid].rank = rank
	if duration > 0 then
		RankSystem.players[steamid].expire = os.time()+duration
	else
		RankSystem.players[steamid].expire = 0
	end

	
	RankSystem.Save( steamid )
	
end
function RankSystem.RemoveUser( ply )
	local steamid = getSteamID( ply )
	if steamid == nil then return end
	if not RankSystem.players[steamid] then return end
	
	RankSystem.players[steamid] = nil
	ULib.ucl.removeUser( steamid )
	RankSystem.Save( steamid )
end
function RankSystem.Save( ply )
	local steamid = getSteamID( ply )
	if steamid == nil then return end
	
	if not RankSystem.players[steamid] then
		query("DELETE FROM `"..DB_TABLE.."` WHERE `steamid` = '" .. steamid .. "'",  function() end)
	else
		local plydata = RankSystem.players[steamid]
		query("INSERT INTO `"..DB_TABLE.."` VALUES (\"" ..steamid.. "\", \"" ..plydata.rank.. "\", " .. plydata.expire .. ") ON DUPLICATE KEY UPDATE `rank`=\""..plydata.rank.."\",`expire`="..plydata.expire.."", function() end)
	end
end


function RankSystem.AddTime( ply, t )
	local steamid = getSteamID( ply )
	if steamid == nil then return end
	if not RankSystem.players[steamid] then return end
	if type(t) != "number" then return end
	
	RankSystem.players[steamid].expire = RankSystem.players[steamid].expire + t
	RankSystem.Save( ply )
end
function RankSystem.SetTime( ply, t )
	local steamid = getSteamID( ply )
	if steamid == nil then return end
	if not RankSystem.players[steamid] then return end
	if type(t) != "number" then return end
	
	RankSystem.players[steamid].expire = os.time()+t
	RankSystem.Save( ply )
end
function RankSystem.GetExpireTime( ply )
	local steamid = getSteamID( ply )
	if steamid == nil then return end
	if not RankSystem.players[steamid] then return end
	
	return RankSystem.players[steamid].expire
end
function RankSystem.GetRank( ply )
	local steamid = getSteamID( ply )
	if steamid == nil then return end
	if not RankSystem.players[steamid] then return end
	
	return RankSystem.players[steamid].rank	
end


timer.Create( "RankSystemCheck", 60, 0, function()
	for steamid, plydata in pairs(RankSystem.players) do 
		if type(plydata) == "table" and type(plydata.expire) == "number" and plydata.expire > 0 and plydata.expire < os.time() then
			RankSystem.RemoveUser( steamid )
		end
	end
end)

Donation_system.lua (Also connects to MySQLOO):


local DB_HOST = "REMOVED"
local DB_PORT = 3306
local DB_DATABASE = "CameronS"
local DB_USERNAME = "CameronS"
local DB_PASSWORD = "REMOVED"
local DB_TABLE = "darkrp_orders"

require("mysqloo")
if not mysqloo then
	Error("[RankSystem] No mysqloo was found")
	return nil
end
DonationSystem = {}
util.AddNetworkString( "DonationSystemColorChat" )
util.AddNetworkString( "DonationSystemConCommand" )

DonationSystem.OnlineCommands = {
	["rank"] = function( ply, args )
		local group = args["group"]
		local duration = args["duration"] or 0
		RankSystem.AddUser( ply, group, duration )
	end,
	["darkrp_money"] = function( ply, args )
		local succ, err = pcall( function() ply:AddMoney(tonumber(args)) end )
		if not succ then
			Error("[DonationSystem] Error executing darkrp_money command, Error: "..err.."
")
		end	
	end,
	["pointshop_points"] = function( ply, args )
		local succ, err = pcall( function() ply:PS_GivePoints(tonumber(args)) end )
		if not succ then
			Error("[DonationSystem] Error executing pointshop_points command, Error: "..err.."
")
		end	
	end,
	["print"] = function( ply, args )
		if type(args) == "string" then
			args = string.Replace( args, "%name%", tostring(ply:Name()) )
			args = string.Replace( args, "%steamid%", tostring(ply:SteamID()) )
			args = string.Replace( args, "%steamid64%", tostring(ply:SteamID()) )
			args = string.Replace( args, "%uniqueid%", tostring(ply:UniqueID()) )
			args = string.Replace( args, "%userid%", tostring(ply:UserID()) )
			net.Start( "DonationSystemColorChat" )
				net.WriteTable( {args} )
			net.Send( ply )
		elseif type(args) == "table" then
			for i=1,#args do
				if type(args*) == "table" then
					args* = Color(args*[1],args*[2],args*[3])
				elseif type(args*) == "string" then
					args* = string.Replace( args*, "%name%", tostring(ply:Name()) )
					args* = string.Replace( args*, "%steamid%", tostring(ply:SteamID()) )
					args* = string.Replace( args*, "%steamid64%", tostring(ply:SteamID()) )
					args* = string.Replace( args*, "%uniqueid%", tostring(ply:UniqueID()) )
					args* = string.Replace( args*, "%userid%", tostring(ply:UserID()) )
				end
			end
			net.Start( "DonationSystemColorChat" )
				net.WriteTable( args )
			net.Send( ply )
		end
	end,
	["broadcast"] = function( ply, args )
		if type(args) == "string" then
			args = string.Replace( args, "%name%", tostring(ply:Name()) )
			args = string.Replace( args, "%steamid%", tostring(ply:SteamID()) )
			args = string.Replace( args, "%steamid64%", tostring(ply:SteamID()) )
			args = string.Replace( args, "%uniqueid%", tostring(ply:UniqueID()) )
			args = string.Replace( args, "%userid%", tostring(ply:UserID()) )
			net.Start( "DonationSystemColorChat" )
				net.WriteTable( {args} )
			net.Broadcast( )
		elseif type(args) == "table" then
			for i=1,#args do
				if type(args*) == "table" then
					args* = Color(args*[1],args*[2],args*[3])
				elseif type(args*) == "string" then
					args* = string.Replace( args*, "%name%", tostring(ply:Name()) )
					args* = string.Replace( args*, "%steamid%", tostring(ply:SteamID()) )
					args* = string.Replace( args*, "%steamid64%", tostring(ply:SteamID()) )
					args* = string.Replace( args*, "%uniqueid%", tostring(ply:UniqueID()) )
					args* = string.Replace( args*, "%userid%", tostring(ply:UserID()))
				end
			end
			net.Start( "DonationSystemColorChat" )
				net.WriteTable( args )
			net.Broadcast( )
		end
	end,
	["broadcast_omit"] = function( ply, args )
		if type(args) == "string" then
			args = string.Replace( args, "%name%", tostring(ply:Name()) )
			args = string.Replace( args, "%steamid%", tostring(ply:SteamID()) )
			args = string.Replace( args, "%steamid64%", tostring(ply:SteamID()) )
			args = string.Replace( args, "%uniqueid%", tostring(ply:UniqueID()) )
			args = string.Replace( args, "%userid%", tostring(ply:UserID()) )
			net.Start( "DonationSystemColorChat" )
				net.WriteTable( {args} )
			net.SendOmit( ply )
		elseif type(args) == "table" then
			for i=1,#args do
				if type(args*) == "table" then
					args* = Color(args*[1],args*[2],args*[3])
				elseif type(args*) == "string" then
					args* = string.Replace( args*, "%name%", tostring(ply:Name()) )
					args* = string.Replace( args*, "%steamid%", tostring(ply:SteamID()) )
					args* = string.Replace( args*, "%steamid64%", tostring(ply:SteamID()) )
					args* = string.Replace( args*, "%uniqueid%", tostring(ply:UniqueID()) )
					args* = string.Replace( args*, "%userid%", tostring(ply:UserID()) )
				end
			end
			net.Start( "DonationSystemColorChat" )
				net.WriteTable( args )
			net.SendOmit( ply )
		end
	end,
	["lua"] = function( ply, args )
		local oldPLAYER = PLAYER
		PLAYER =  ply
		RunStringEx( args, "[DonationSystem] Lua:")
		PLAYER = oldPLAYER
	end,
	["server_console"] = function( ply, args )
		for i=1,#args do
			args* = string.Replace( args*, "%name%", tostring(ply:Name()) )
			args* = string.Replace( args*, "%steamid%", tostring(ply:SteamID()) )
			args* = string.Replace( args*, "%steamid64%", tostring(ply:SteamID()) )
			args* = string.Replace( args*, "%uniqueid%", tostring(ply:UniqueID()) )
			args* = string.Replace( args*, "%userid%", tostring(ply:UserID()) )
		end
		RunConsoleCommand( unpack(args) )
	end,
	["client_console"] = function( ply, args )
		for i=1,#args do
			args* = string.Replace( args*, "%name%", tostring(ply:Name()) )
			args* = string.Replace( args*, "%steamid%", tostring(ply:SteamID()) )
			args* = string.Replace( args*, "%steamid64%", tostring(ply:SteamID()) )
			args* = string.Replace( args*, "%uniqueid%", tostring(ply:UniqueID()) )
			args* = string.Replace( args*, "%userid%", tostring(ply:UserID()) )
		end
		net.Start( "DonationSystemConCommand" )
			net.WriteTable( args )
		net.Send( ply )
	end
}
DonationSystem.OfflineCommands = {
	["rank"] = function( steamid, args )
		local group = args["group"]
		local duration = args["duration"] or 0
		RankSystem.AddUser( steamid, group, duration )
	end,
	["broadcast"] = function( steamid, args )
		if type(args) == "string" then
			args = string.Replace( args, "%steamid%", tostring(steamid) )
			net.Start( "DonationSystemColorChat" )
				net.WriteTable( {args} )
			net.Broadcast( )
		elseif type(args) == "table" then
			for i=1,#args do
				if type(args*) == "table" then
					args* = Color(args*[1],args*[2],args*[3])
				elseif type(args*) == "string" then
					args* = string.Replace( args*, "%steamid%", tostring(steamid) )
				end
			end
			net.Start( "DonationSystemColorChat" )
				net.WriteTable( args )
			net.Broadcast( )
		end
	end,
	["lua"] = function( steamid, args )
		local oldSTEAMID = STEAMID
		STEAMID =  steamid
		RunStringEx( args, "[DonationSystem] Lua:")
		STEAMID = oldSTEAMID
	end,
	["server_console"] = function( steamid, args )
		for i=1,#args do
			args* = string.Replace( args*, "%steamid%", tostring(steamid) )
		end
		RunConsoleCommand( unpack(args) )
	end
}


local queue = {} 
local db = mysqloo.connect( DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT )
local function query( sql, callback ) -- If not connected, connect and repeat query
	local q = db:query( sql )
	if not q then	
		table.insert( queue, { sql, callback } )
		db:connect()
		return
	end
	function q:onSuccess( data )
		callback( data )
	end
	function q:onError( err )
		if db:status() == mysqloo.DATABASE_NOT_CONNECTED then
			table.insert( queue, { sql, callback } )
			db:connect()
			return
		end
		Error( "[DonationSystem] Query Error: ", err, " sql: ", sql, "
" )
	end
	q:start()
end
function db:onConnected()	
	ServerLog("[DonationSystem] Connected to database
")

	for k, v in pairs( queue ) do
		query( v[ 1 ], v[ 2 ] )
	end
	queue = {}
end
 
function db:onConnectionFailed( err )
    Error( "[DonationSystem] Connection to database failed!
" )
    Error( "[DonationSystem] Error:", err, "
" )
end
db:connect()


function DonationSystem.DatabaseCheck()
	query([[
	CREATE TABLE IF NOT EXISTS `]]..DB_TABLE..[[` (
	`orderid` MEDIUMINT NOT NULL AUTO_INCREMENT,
	`transactionid` varchar(125) NOT NULL,
	`playerid` varchar(40) NOT NULL,
	`execute` TEXT NOT NULL,
	`offline` TINYINT(1) UNSIGNED NOT NULL,
	PRIMARY KEY (orderid))
	]], function() end)
end
hook.Add( "Initialize", "DonationSystemDatabaseCheck", DonationSystem.DatabaseCheck )

hook.Add( "PlayerInitialSpawn", "DonationSystemPlayerJoin", function(ply)
	ply:SendLua( [[ net.Receive( "DonationSystemColorChat", function( len ) chat.AddText( unpack( net.ReadTable() ) ) end ) ]] )
	ply:SendLua( [[ net.Receive( "DonationSystemConCommand", function( len ) RunConsoleCommand( unpack( net.ReadTable() ) ) end ) ]] )
end)

function DonationSystem.CheckOffline()
	query("SELECT * FROM `" .. DB_TABLE .. "` WHERE `offline` = 1", function(orders)
		for orderid, orderdata in pairs(orders) do
			local execs = util.JSONToTable(orderdata.execute)
			for command, args in pairs(execs) do
				local succ, err = pcall( function() DonationSystem.OnlineCommands[command](orderdata.playerid,args) end )
				if not succ then
					Error("[DonationSystem] Error running offline command '"..command.."'. Error: "..err.."
")
				end
			end		
			ServerLog("[DonationSystem] Activated offline order("..orderdata.orderid..") "..orderdata.transactionid.." for "..orderdata.playerid.."
")
			query("DELETE FROM `" .. DB_TABLE .. "` WHERE `orderid` = '" .. orderdata.orderid .. "'",  function() end)
		end
	end)
end
function DonationSystem.CheckPlayer(ply)
	query("SELECT * FROM `" .. DB_TABLE .. "` WHERE `playerid` = \""..ply:SteamID().."\" AND `offline` = 0", function(orders)
		for orderid, orderdata in pairs(orders) do
			local execs = util.JSONToTable(orderdata.execute)
			for command, args in pairs(execs) do
				local succ, err = pcall( function() DonationSystem.OnlineCommands[command](ply,args) end )
				if not succ then
					Error("[DonationSystem] Error running online command '"..command.."'. Error: "..err.."
")
				end
			end		
			ServerLog("[DonationSystem] Activated online order("..orderdata.orderid..") "..orderdata.transactionid.." for "..ply:Nick().."
")
			query("DELETE FROM `" .. DB_TABLE .. "` WHERE `orderid` = '" .. orderdata.orderid .. "'",  function() end)
		end
	end)
end

timer.Create( "DonationSystemCheck", 30, 0, function() 
	for k, ply in pairs(player.GetAll()) do
		DonationSystem.CheckPlayer(ply)
	end
	DonationSystem.CheckOffline()
end )
hook.Add("PlayerInitialSpawn", "Donations_MySQL_Load", DonationSystem.CheckPlayer)


Isn’t this a ScriptFodder/CoderHire script? If so, you can contact the author you brought it from