Hello everyone, so I was searching if there is any tutorial about the same thing i'm posting about, and saw a thread about the same thing by DIS, but the user who posted it, is banned, so he can't help people anymore, so I decided to post this thread for 2 main reasons:
- The user who posted about the same thing is banned
- I'm gonna explain better, with pictures, and easier to read and understand
- After selecting your Operating System, scroll down to the bottom of the page, and download the Installer version of XAMPP like the picture describes.
- When you finished downloading, open the Installer, and click the "Next" button
- Then, make sure everything is marked to install, and then click "Next"
- Then, select your location you want to install to, and continue to extract the files and install them.
- Now, installer will unpack and install the needed files
After installing is finished, open XAMPP Control Panel
Install services of 3 top options (click on
X button), and start those services
- After enabling those services, go to http://localhost/ , and select your language (English in my case).
- Select Status, it should look like the Picture (better if everything is activated, but I just need SQL Database)
Then, you have installed your SQL Database.
- Now, go to localhost/phpmyadmin/ , and go to "Database" tab, and create a new Database, as you can see in the picture
After creating your Database, let's start: How to connect my plugin to SQL Database.
Okay so here, there is 2 type of connection (for Amx Mod X) in order to connect to SQL Database (depends on the plugin):
It is installed by Amx Mod X install package, and it is used by some default AMXX Plugins like admin_sql.amxx and some other Plugins, which should be configured in a cfg file located in addons\amxmodx\configs\, sql.cfg file.
- SQL connection by the Plugin itself:
This type of connection, means the Plugin connects itself to the SQL Database, and it doesn't need to configure sql.cfg file instead, you should edit the source file itself.
Here I will show you both ways:
SQLX: Go to addons\amxmodx\configs\ and open sql.cfg, it will look like this:
PHP Code:
// SQL configuration file
// File location: $moddir/addons/amxmodx/configs/sql.cfg
// *NOTE* Linux users may encounter problems if they specify "localhost" instead of "127.0.0.1"
// We recommend using your server IP address instead of its name
// *NOTE* amx_sql_type specifies the DEFAULT database type which admin.sma will use.
amx_sql_host "127.0.0.1"
amx_sql_user "root"
amx_sql_pass ""
amx_sql_db "amx"
amx_sql_table "admins"
amx_sql_type "mysql"
Okay so here I will describe each option for you (although it is easy to understand, but I should explain for making a "complete" tutorial).
amx_sql_host: This is the host address (your SQL Database address) which is always 127.0.0.1 if it is located on you PC.
amx_sql_user: Your SQL Database username, if you have followed the steps to install SQL Database exactly like mine, it is root by default.
amx_sql_pass: This is your SQL password, if you have followed the steps to install SQL Database exactly like mine, it is empty ("") by default.
amx_sql_db: This is your Database name you want to save to, as I described before how to make a new one (Database).
amx_sql_table: This is the table which it will be created, it is not important, just leave this option.
amx_sql_type: This is your SQL type (it is MySQL which you have installed with XAMPP), this option is not much important, too.
Okay now I will teach you how to configure a plugin when it has SQL connection by the Plugin itself:
**First of all, the Author of the plugin should have mentioned where to edit, now, I am going to show you a plugin as an example:
Played-Time: Extended
Now, the author pokemonmaster, he said where to configure the SQL option:
PHP Code:
new const gsz_SQLINFO[][] = {
{ "127.0.0.1" }, // HOST
{ "root" }, // USER
{ "" }, // User's password
{ "amxx" } // Database Name
}
Okay, now as he described, you should configure this part of the Plugin.
As we did in the sql.cfg, it is the same way, just the difference is which you have to configure in the Source File.
127.0.0.1 - This is the host (as I said before, it is 127.0.0.1 if it is located on your PC)
root - This is the SQL username (same as I described for the SQLX)
{ "" }, // User's password - This one is also the same as I described for the SQLX
amxx - It is your Database Name which you created
-------------------------------------------------------------------------------------------------
Was it hard? Especially the difference from the SQLX and the SQL connection by the Plugin itself?
It is very easy to setup, just ask any question if you didn't understand something.
Hope you enjoy it when you are done, and don't forget to rate the thread