04.03.2014, 15:54
hey there! I am trying to make a simple log with bad rcon attempts, but I want it to be in a database form. My problem is that with the following code, the database is not created. Can you tell me what's wrong?
Код:
#define FILTERSCRIPT #include <a_samp> #include <junkbuster> #if defined FILTERSCRIPT new DB:rcon_attempts; public OnFilterScriptInit() { print("\n--------------------------------------"); print(" ----rcon security by HeLiOn PrImE----"); print("--------------------------------------\n"); rcon_attempts = db_open("/ladmin/logs/rcon_attempts.db"); db_free_result(db_query(rcon_attempts, "CREATE TABLE IF NOT EXISTS `Tabel` (`IP`, `Imput`, `Hour`, `Minute`, `Second`)")); return 1; } public OnFilterScriptExit() { return 1; } #else #endif public OnRconLoginAttempt(ip[], password[], success) { new hour, minute, second; new Query1[129]; new Query2[129]; new Query3[129]; new Query4[129]; new Query5[129]; gettime(hour, minute, second); if(!success) //If the password was incorrect { format(Query1, sizeof(Query1), "INSERT INTO `Tabel` (`IP`) VALUES('%s')", (ip)); db_query(rcon_attempts, Query1); db_free_result(db_query(rcon_attempts, Query1)); format(Query2, sizeof(Query2), "INSERT INTO `Tabel` (`Imput`) VALUES('%s')", (password)); db_query(rcon_attempts, Query2); db_free_result(db_query(rcon_attempts, Query2)); format(Query3, sizeof(Query3), "INSERT INTO `Tabel` (`Hour`) VALUES('%d')", (hour)); db_query(rcon_attempts, Query3); db_free_result(db_query(rcon_attempts, Query3)); format(Query3, sizeof(Query4), "INSERT INTO `Tabel` (`Minute`) VALUES('%d')", (minute)); db_query(rcon_attempts, Query4); db_free_result(db_query(rcon_attempts, Query4)); format(Query3, sizeof(Query5), "INSERT INTO `Tabel` (`Second`) VALUES('%d')", (second)); db_query(rcon_attempts, Query5); db_free_result(db_query(rcon_attempts, Query5)); new Command[50]; format(Command, sizeof(Command), "banip %s", ip); SendRconCommand(Command); } return 1; }