20.03.2018, 19:32
Thanks for the reply.
Can you tell me why threaded query is better than normal query and how can I know which to use and when?
Server still crashes.
I deleted MySQL log files before using the command in case there were old ones so I can know, but it doesn't re-create.
However, take a look at server log:
I had to modify your code a bit because some variables should be in the command and vice versa, here's how it looks now:
+ printf in a callback is giving a warning: warning 202: number of arguments does not match definition, so i marked it as a comment
Can you tell me why threaded query is better than normal query and how can I know which to use and when?
Server still crashes.
I deleted MySQL log files before using the command in case there were old ones so I can know, but it doesn't re-create.
However, take a look at server log:
PHP Code:
[20:19:42] Number of vehicle models: 15
[20:19:43] [debug] Run time error 4: "Array index out of bounds"
[20:19:43] [debug] Attempted to read/write array element at index 65535 in array of size 1000
[20:19:43] [debug] AMX backtrace:
[20:19:43] [debug] #0 00024304 in public OnPlayerTakeDamage (0, 65535, 1079194420, 54, 3) from LSCnR.amx
[20:19:54] Query formatted: -> 'SELECT * FROM BanData WHERE IPAddress LIKE '%87.%' ORDER BY BannedOn DESC LIMIT 5;'
[20:19:54] [debug] Server crashed while executing LSCnR.amx
[20:19:54] [debug] AMX backtrace:
[20:19:54] [debug] #0 0000002e in ?? () from LSCnR.amx
[20:19:54] [debug] #1 0000002e in public cmd_searchbanip () from LSCnR.amx
[20:19:54] [debug] #2 native CallLocalFunction () from sampsvr-port_1956
[20:19:54] [debug] #3 000006b0 in public OnPlayerCommandText (0, 2082852) from LSCnR.amx
+ printf in a callback is giving a warning: warning 202: number of arguments does not match definition, so i marked it as a comment
PHP Code:
CMD:searchbanip(playerid, params[])
{
if(LoggedIn[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must be logged in.");
if(PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_RED, "ERROR: Admin level 2+ command.");
new targetip;
if(sscanf(params, "s[24]", targetip)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /searchbanip [IP range]");
new achat[128], query[256];
mysql_format(Database, query, sizeof(query), "SELECT * FROM BanData WHERE IPAddress LIKE '%%%e%%' ORDER BY BannedOn DESC LIMIT 5;", targetip);
printf("Query formatted: -> '%s'", query);
mysql_tquery(Database, query, "DisplayingBanPerIP");
format(achat, sizeof(achat), "%s has searched bans under IP range '%s'.", GetName(playerid), targetip);
addChatMessage(achat, "blue");
return 1;
}
forward DisplayingBanPerIP(playerid);
public DisplayingBanPerIP(playerid)
{
//print("Beginning 'DisplayingBanPerIP' - Rows: %i", cache_num_rows());
new info[128], string[700], User[24], BannedBy[24], BanReason[40], BannedOn[30], ExpiresOn[30], IPAddress[30], GPCI[130];
if(cache_num_rows() != 0)
{
format(info, sizeof(info), "{FF0000}There are bans found under the IP range you provided!{FFFFFF}\n{FEFE22}Displaying 5 latest:{FFFFFF}\n\n");
strcat(string, info);
for(new i = 0; i < cache_num_rows(); i++)
{
cache_get_value_name(i, "User", User, MAX_PLAYER_NAME);
cache_get_value_name(i, "BannedBy", BannedBy, MAX_PLAYER_NAME);
cache_get_value_name(i, "BanReason", BanReason, 40);
cache_get_value_name(i, "IPAddress", IPAddress, 16);
cache_get_value_name(i, "BannedOn", BannedOn, 30);
cache_get_value_name(i, "ExpiresOn", ExpiresOn, 30);
cache_get_value_name(i, "GPCI", GPCI, 130);
format(info, sizeof(info), "{FF0000}User: {FFFFFF}%s\n{FF0000}Banned by: {FFFFFF}%s\n{FF0000}Ban reason: {FFFFFF}%s\n{FF0000}IP Address: {FFFFFF}%s\n{FF0000}Banned on: {FFFFFF}%s\n{FF0000}Expires on: {FFFFFF}%s\n{FF0000}GPCI: {FFFFFF}%s\n\n", User, BannedBy, BanReason, IPAddress, BannedOn, ExpiresOn, GPCI);
strcat(string, info);
}
}
else
{
format(info, sizeof(info), "There are no bans found under the IP range you specified.");
strcat(string, info);
}
ShowPlayerDialog(playerid, DIALOG_SEARCH_BAN_IP, DIALOG_STYLE_MSGBOX, "Ban lookup", string, "Close","");
return 1;
}