database is not created -
HeLiOn_PrImE - 04.03.2014
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;
}
Re: database is not created -
HeLiOn_PrImE - 05.03.2014
bump
Re: database is not created -
HeLiOn_PrImE - 06.03.2014
bump!!!
Re: database is not created -
CutX - 06.03.2014
you should check your mysql_log file
you will find the answer there
Re: database is not created -
HeLiOn_PrImE - 06.03.2014
I am not using mysql. SQLite is implemented in sa-mp
Re: database is not created -
HeLiOn_PrImE - 07.03.2014
bump
Re: database is not created -
SyntaxQ - 07.03.2014
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?
Re: database is not created -
HeLiOn_PrImE - 07.03.2014
it's meant to be a string. It should record the password they tried to put.
Re: database is not created -
ColeMiner - 07.03.2014
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!
Re: database is not created -
HeLiOn_PrImE - 07.03.2014
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?