Rcon + sql problem
#1

Alright so for some reason this code wont log any RCON commands and also wont log in any rcon login attemps.

pawn Код:
public OnRconCommand(cmd[]) {
    new string[128];
    format(string,sizeof(string),"%s", cmd);
    writeServerLog("public OnRconCommand()", string);
    return 1;
}

stock writeServerLog(callback[], params[]) {
    new query[512]; //512 since some queries I do are quite long such as OnCommandExecute etc.
    mysql_format(mysql,query,sizeof(query),"INSERT server_logs (`callback`,`params`,`time`) VALUES ('%e','%e',%i) ",callback, params, gettime());
    mysql_tquery(mysql, query, "");
}
And as it goes for RconLogin attempt, it gets called but IP and password wont be display in the SQL. It just sends empty parameter to the SQL.

pawn Код:
public OnRconLoginAttempt(ip[], password[], success) {
    new string[128];
    if(!success) {
        format(string,sizeof(string),"IP: %s || Pass: %s || Success: FAILED", ip, password);
    } else {
        format(string,sizeof(string),"IP: %s || Pass: %s || Success: SUCCESS",ip, password);
    }
    writeServerLog("public OnRconLoginAttempt()", string);
    return 1;
}

This is the row from the SQL
Quote:

public OnRconLoginAttempt() PARAM_EMPTY 147941258

As you can see the parameters are empty (param_empty is the default I've set)


EDIT: I fixed the login atempt, for some reason it had permission problems that were not part of the script itself but the samp.exe. I've ran the server exe as an admin and it works now.

NOTE: Still not loggin in the rcon commands
Reply
#2

Hey, just a little suggestion:
Instead of doing
Код:
if(!success) 
{
    format(string, sizeof(string), "IP: %s || Pass: %s || Success: FAILED", ip, password);
} 
else 
{
    format(string, sizeof(string), "IP: %s || Pass: %s || Success: SUCCESS", ip, password);
}
you could use a ternary operator and do
Код:
format(string, sizeof(string), "IP: %s || Pass: %s || Success: %s", (success) ? ("SUCCESS") : ("FAILED"), ip, password);
That's not necessary, but I think that would be better.
Reply
#3

Woah been scripting SA:MP for many years now, didnt realize you can use ternary operators lmfao. Thanks bro but yeah, the problem still remains with the commands.
Reply
#4

Ternary operators are pretty cool, but they are actually slower than if-thens.

------

I wonder since when the INSERT clause was just INSERT?

INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...);
Reply
#5

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Ternary operators are pretty cool, but they are actually slower than if-thens.

------

I wonder since when the INSERT clause was just INSERT?

INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...);
Oh fucking hell.. Damn, sometimes... Thanks bro, I cant believe I didnt even see that lol
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)