@AlexLS95: Thank you the QUERY_NONE and mysql_free_result was indeed fixing it
I have another question: now I know I needed these functions how can I give a format for each founded row:
I want to make a punishments commando where you can check the punishments from someone or from yourself with the following command:
pawn Код:
COMMAND:punishments(playerid, params[]) {// needs to be fixed
if(CheckARank(playerid, 2, 4)) {
new targetid;
if(!sscanf(params, "U(-1)", targetid)) {
if(targetid == -1) {
new query[500], string[128], variable[960], reason[500];
format(query, sizeof(query), "SELECT * FROM warnings WHERE warning_userid = '%d'", playersInfo[playerid][pID]);
new Result:Warnings = mysql_query(mysql, query, QUERY_NONE);
new rows = mysql_num_rows(Warnings);
mysql_free_result(Warnings);
mysql_get_field_assoc(Result:Warnings, "warning_reason", reason, sizeof(reason));
format(string, sizeof(string), "\n%s", reason);
strcat(variable, string);
if(rows == 0) return SendClientMessage(playerid, COLOR_RED, "(Error!) No warnings found!");
if(rows == 1) { format(string, sizeof(string), "%d Punishment in your file", rows); }
if(rows > 1) { format(string, sizeof(string), "%d Punishments in your file", rows); }
ShowPlayerDialog(playerid, DIALOG_PUNISHMENTS, DIALOG_STYLE_LIST, string, variable, "Close", "");
} else {
new query[500], string[128], variable[960], reason[500];
format(query, sizeof(query), "SELECT * FROM warnings WHERE warning_userid = '%d'", playersInfo[targetid][pID]);
new Result:Warnings = mysql_query(mysql, query, QUERY_NONE);
new rows = mysql_num_rows(Warnings);
mysql_free_result(Warnings);
mysql_get_field_assoc(Result:Warnings, "warning_reason", reason, sizeof(reason));
format(string, sizeof(string), "\n%s", reason);
strcat(variable, string);
if(rows == 0) return SendClientMessage(playerid, COLOR_RED, "(Error!) No warnings found!");
if(rows == 1) { format(string, sizeof(string), "%d Punishment in %s's file", rows, playersInfo[targetid][pUsername]); }
if(rows > 1) { format(string, sizeof(string), "%d Punishments in %s's file", rows, playersInfo[targetid][pUsername]); }
ShowPlayerDialog(playerid, DIALOG_PUNISHMENTS, DIALOG_STYLE_LIST, string, variable, "Close", "");
}
}
}
return 1;
}
The rows are founded are counted and the dialog is perfect but for some reason the reasons won't display? any idea