Report bug
#5

You're trying to fetch fields from the database without a select query, you'd have to run another query after inserting the new report which would select from the reportlog table ordered by id in a descending order with a limit of 1 to ensure you're selecting the latest entry to the database, it'd look something like this:

Код:
CMD:re(playerid,params[]) 
{ 
    new reason[250],reportstring[250],reportstring2[250], targetid; 
    if(sscanf(params, "s[80]",reason)) return SendClientMessage(playerid,-1,""chat" /(re)port [Reason]"); 
    if(pInfo[playerid][pReported] == 0) 
        { 
            format(jQuery, MAX_QUERY_LENGTH, "INSERT INTO `"#reportlog"` (Username, REPORT, DATA) VALUES ('%s', '%s', CURRENT_TIMESTAMP)",PlayerName(playerid), reason); 
            mysql_tquery(handle, jQuery, "", ""); 
			mysql_tquery(mysql, "SELECT * FROM `reportlog` ORDER BY ID DESC LIMIT 1", "OnPlayerReport", "uus[80]", playerid, targetid, reason);
        } 
        else { 
            SendClientMessage(playerid,-1,""COL_RED"Wait 1  minute"); 
        } 
    return 1; 
}  


forward OnPlayerReport(playerid, targetid, reason);
public OnPlayerReport(playerid, targetid, reason)
{
    new rows, fields; 
    cache_get_data(rows, fields, handle); 
    new  reportid; 
    new count = cache_num_rows();
    if(count > 0)
    {
    	  reportid = cache_get_field_content_int(0, "ID", handle); 
    	  format(reportstring2,sizeof(reportstring), ""chat""COL_YELLOW"[REF:#%d] Your report was sent.",reportid); 
      	SendClientMessage(playerid,-1,reportstring2); 
      	format(reportstring,sizeof(reportstring), ""chat""COL_YELLOW"[REF:#%d] Player has reported %s(ID:%d)"COL_WHITE" (Reason: %s)",reportid, PlayerName(playerid),playerid,reason); 
      	SendMessageToAllAdmins(reportstring,-1); 
      	pInfo[playerid][pReported] = 1; 
      	timeras[playerid] = SetTimerEx("Report", 60000, 0, "i", playerid); 
    }
}
Also you shouldn't be giving your reason string such a large size of 250 if you're only using 81 of those characters.
Reply


Messages In This Thread
Report bug - by Zeus666 - 21.10.2018, 22:05
Re: Report bug - by v1k1nG - 21.10.2018, 22:48
Re: Report bug - by Zeus666 - 21.10.2018, 22:51
Re: Report bug - by Jefff - 21.10.2018, 23:11
Re: Report bug - by Chyakka - 21.10.2018, 23:15
Re: Report bug - by Zeus666 - 21.10.2018, 23:30
Re: Report bug - by Zeus666 - 21.10.2018, 23:53
Re: Report bug - by Zeus666 - 22.10.2018, 09:09
Re: Report bug - by Calisthenics - 22.10.2018, 09:56
Re: Report bug - by Zeus666 - 22.10.2018, 11:37

Forum Jump:


Users browsing this thread: 1 Guest(s)