database is not created
#1

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;
}
Reply
#2

bump
Reply
#3

bump!!!
Reply
#4

you should check your mysql_log file
you will find the answer there
Reply
#5

I am not using mysql. SQLite is implemented in sa-mp
Reply
#6

bump
Reply
#7

Try using this:
pawn Код:
db_query(rcon_attempts, "CREATE TABLE IF NOT EXISTS `Tabel` (IP varchar(24), Imput INTEGER DEFAULT 0 NOT NULL, Hour INTEGER DEFAULT 0 NOT NULL, Minute INTEGER DEFAULT 0 NOT NULL, Second INTEGER DEFAULT 0 NOT NULL)");
EDIT: I don't know what is 'Imput', is that an integer or a string?
Reply
#8

it's meant to be a string. It should record the password they tried to put.
Reply
#9

Stop bumping - you have been here more than long enough to know that the rules state that you may only bump topics after 24 hours!
Reply
#10

up until the last response I respected the rules. Now I am discussing the problem with another person. Am I supposed to wait 24 hours just to answer to him?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)