25.05.2018, 17:39
So as the title says? How should I make an ip ban thing? ipban and unban ip? And connect it to a current mysql database? Thanks! An example would be pretty helpful
#include <a_samp> first #include <a_mysql> second
#define MYSQL_HOST "localhost" //by default #define MYSQL_USER "root" //by default #define MYSQL_PASSWORD "" // default user does not has password #define MYSQL_DATABASE "test" // its allready set by default
new MySQL:g_SQL; //this is MySQL tag & variable to connect to your webserver mysql
public OnSomethingInit() // this is example
{
new MySQLOpt:Option_Id = mysql_init_options(); // that depends what option you will set it
mysql_set_option(Option_Id, SERVER_PORT, 3306); // lets say you set it for MySQL Default Port
g_SQL = mysql_connect(.....); // Here goes your defines MYSQL_1, 2, 3, 4
// than you check is your mysql open or closed by doing
if(mysql_errno() != 0)
{
//print failed
}
else
{
//print success
}
// here you can create your table for your banned Ips depending on what you want to store
return 1;
}
public OnSomeThingExit()
{
mysql_close(g_SQL); // make sure you close your connection on gamemode exit or filterscript exit
return 1;
}