12.11.2015, 11:22
function for server reports
report command
PHP код:
function ServerReports(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows) {
new string[500];
new gName[MAX_PLAYER_NAME+1],Reason[128],Date[128];
cache_get_field_content(0, "Name", gName, sizeof(gName));
cache_get_field_content(0, "Reason", Reason, sizeof(Reason));
cache_get_field_content(0, "Date", Date, sizeof(Date));
format(string,sizeof string,"Name\tReason\tDate\n\%s\t%s\t%s",gName,Reason,Date);
ShowPlayerDialog(playerid, -1, DIALOG_STYLE_TABLIST_HEADERS, "Reports",string,"Exit", "");
}
return 1;
}
PHP код:
CMD:report(playerid,params[])
{
new reason[60],pid,Query[120],date,month,year;
getdate(year,month,date);
new ReportDate = getdate();
if(sscanf(params,"us[60]",pid,reason)) return SendClientMessage(playerid,COLOR_RED," SERVER : /report [id] [ reason ]");
if(pid == INVALID_PLAYER_ID || !IsPlayerConnected(pid)) return ErrorMessages(playerid,2);
SendFM(playerid,COLOR_LIGHTRED,"You have reported player %s(%d) Reason: %s",GPN(pid),pid,reason);
mysql_format(mysql, Query, sizeof(Query), "INSERT INTO `reports` (`Name`, `Reason`, `Date`) VALUES ('%s', '%s', '%s')",GPN(pid),reason,ReportDate);
mysql_tquery(mysql,Query);
printf(Query);
foreach(new i: Player)
{
if(pinfo[i][Admin] >= 1)
SendFM(i,COLOR_WHITE,""COL_RED"PLAYER"COL_WHITE": %s(%d) "COL_RED"REPORTED"COL_WHITE":%s(%d) "COL_RED"REASON"COL_WHITE":%s(%d)",GPN(playerid),playerid,GPN(pid),pid,reason);
}
return 1;
}
CMD:reports(playerid,params[])
{
if(pinfo[playerid][Admin] < 1) return 0;
new Query[250];
mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM `reports` LIMIT 10"); // read player account
mysql_tquery(mysql, Query, "ServerReports", "i", playerid); // to read if player account exist
return 1;
}