Connect database with gamemode
#2

https://sampwiki.blast.hk/wiki/MySQL#mysql_connect

You should define at the top of your script your mysql credentials

pawn Код:
#define MYSQL_HOST "127.0.0.1c
#define MYSQL_USERNAME "root"
#define MYSQL_PASSWORD "password"
#define MYSQL_DATABASE "yourdatabase"

new MySQL:database;


public OnGamemodeModeInit()
{
     database = mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);
     return 1;
}
You'll have to change these credentials to your mysql database's ones



pawn Код:
new MySQL:database;
This is needed to store the mysql handle. you need it to use mysql_tquery and etc..


After that you simply use mysql_connect function

pawn Код:
database = mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);
Here we get the mysql handle and put it inside database variable
Reply


Messages In This Thread
Connect database with gamemode - by Wesmokady - 21.12.2017, 16:56
Re: Connect database with gamemode - by Lucases - 21.12.2017, 19:31

Forum Jump:


Users browsing this thread: 1 Guest(s)