unban command not functioning properly(SQLite) -
DarkLored - 27.08.2015
I have created an unban command using SQLite but the command would not work, also sscanf isn't being called when I don't type the name of the player, also nothing is being printed into the console after doing the command.
pawn Код:
CMD:unban(playerid, params[])
{
new name[24], string[128], Query[500], DBResult:Result;
if(dAdmin[playerid][USER_ADMIN] == 3)
{
if(sscanf(params, "s[24]", name))
{
SendClientMessage(playerid, -1, "[USAGE]/unban (name)");
return 1;
}
format(Query, sizeof(Query), "SELECT banned FROM users WHERE username = '%s'", DB_Escape(name));
Result = db_query(Database, Query);
if(db_num_rows(Result))
{
format(Query, sizeof(Query), "UPDATE users SET banned = 0 WHERE username = '%s'", DB_Escape(name));
Result = db_query(Database, Query);
format(string, sizeof(string), "Player %s's ban was set to 0.", name);
print(string);
}
db_free_result(Result);
return 1;
}
return 1;
}
Re: unban command not functioning properly(SQLite) -
CadSives - 27.08.2015
I'm not 100% sure if this would work, as I have no knowledge of SQ lite, but I don't think those extra returns had to be there so it's worth a try
Код:
CMD:unban(playerid, params[])
{
new name[24], string[128], Query[500], DBResult:Result;
if(dAdmin[playerid][USER_ADMIN] == 3)
{
if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, -1, "[USAGE]/unban (name)");
else
{
format(Query, sizeof(Query), "SELECT banned FROM users WHERE username = '%s'", DB_Escape(name));
Result = db_query(Database, Query);
if(db_num_rows(Result))
{
format(Query, sizeof(Query), "UPDATE users SET banned = 0 WHERE username = '%s'", DB_Escape(name));
Result = db_query(Database, Query);
format(string, sizeof(string), "Player %s's ban was set to 0.", name);
print(string);
}
db_free_result(Result);
}
}
return 1;
}
Re: unban command not functioning properly(SQLite) -
Jefff - 27.08.2015
pawn Код:
CMD:unban(playerid, params[])
{
if(dAdmin[playerid][USER_ADMIN] != 3) return 0;
if(isnull(params)) SendClientMessage(playerid, -1, "[USAGE]/unban (name)");
else if(!(3 <= strlen(params) < MAX_PLAYER_NAME)) SendClientMessage(playerid, -1, "Player name must be between 3-24 characters");
else
{
new name[MAX_PLAYER_NAME], string[128], DBResult:Result;
format(string, sizeof(string), "SELECT banned FROM users WHERE username = '%e'",name); // %e is for samp 0.3.7
Result = db_query(Database, string);
new rows = db_num_rows(Result);
db_free_result(Result);
if(rows)
{
format(string, sizeof(string), "UPDATE users SET banned = 0 WHERE username = '%e'", name);
db_free_result(db_query(Database, string));
format(string, sizeof(string), "Player %s's ban was set to 0.", name);
print(string);
}
}
return 1;
}
Re: unban command not functioning properly(SQLite) -
DarkLored - 28.08.2015
It still doesn't work, and I think the command is not being called at all, but I tried a few ways and couldn't figure out how to update an offline users stats.