forward RemoveNoteFunc(playerid);
public RemoveNoteFunc(playerid)
{
new
rows,
fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
new madeby, thenoteid, query[128];
madeby = cache_get_row_int(0, 5);
thenoteid = cache_get_row_int(0, 0);
if(pInfo[playerid][Admin] < 6 && pInfo[playerid][ID] != madeby) return SendErrorMSG(playerid, "You cannot remove a note unless it's made by you.");
new string[128];
mysql_format(mysql, query, sizeof(query), "DELETE * FROM notes WHERE `ID` = %d", thenoteid);
mysql_tquery(mysql, query, "", "");
format(string, sizeof(string), "You have removed note ID %d.", thenoteid);
SendAdminMSG(playerid, string);
format(string, sizeof(string), "%s(%d) has removed note ID %d.", PlayerName(playerid), playerid, thenoteid);
SendALogMSG(string);
}
else
{
SendErrorMSG(playerid, "Invalid note ID.");
}
return 1;
}
https://sampwiki.blast.hk/wiki/MySQL/R33..._affected_rows
You can see how many rows were affected and if it is not 0, show the messages about removing note ID. I'm not entirely sure if there is only one row, if the function returns 0. The note box in wiki states a DELETE query without WHERE clause. I guess you execute a query to get the the note ID from another table, right? This can be done in one query. |
So if it's an invalid note ID, the "cache_affected_rows" will return 0?
|