12.11.2015, 12:59
(
Последний раз редактировалось jlalt; 12.11.2015 в 14:24.
)
this have to work well cause it tested
new /reports command this gonna show last 10 reports
now i'll fix the dreport :c, also i hope this both gonna work :d
and here we go delete report:
PHP код:
CMD:report(playerid,params[])
{
new reason[60],pid,Query[120];
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);
new day1,month1,year1,Date1[128]; getdate(year1, month1, day1);
format(Date1,sizeof Date1,"%d-%d-%d",year1,month1,day1);
mysql_format(mysql, Query, sizeof(Query), "INSERT INTO `reports` (`Name`, `Reason`, `Date`) VALUES ('%s', '%s', '%s')",GPN(pid),reason,Date1);
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;
}
PHP код:
CMD:reports(playerid,params[]) {
if(IsPlayerAdmin(playerid)) {
new Query[250];
mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM `reports`"); // read player account
mysql_tquery(mysql, Query, "Reports1", "i", playerid); // to read if player account exist
return 1;
} else return SendClientMessage(playerid,-1,"ERROR:You should be rcon to use this command");
}
forward Reports1(playerid);
public Reports1(playerid) {
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows) {
new string[128],handle[1000];
new Name1[MAX_PLAYER_NAME+1],Reason[128],Date[128];
strcat(handle,"Name\tReason\tDate");
if(cache_get_row_count(mysql) >= 10) {
cache_get_row(cache_get_row_count()-1, 0, Name1); cache_get_row(cache_get_row_count()-1, 2, Reason); cache_get_row(cache_get_row_count()-1, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
cache_get_row(cache_get_row_count()-2, 0, Name1); cache_get_row(cache_get_row_count()-2, 2, Reason); cache_get_row(cache_get_row_count()-2, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
cache_get_row(cache_get_row_count()-3, 0, Name1); cache_get_row(cache_get_row_count()-3, 2, Reason); cache_get_row(cache_get_row_count()-3, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
cache_get_row(cache_get_row_count()-4, 0, Name1); cache_get_row(cache_get_row_count()-4, 2, Reason); cache_get_row(cache_get_row_count()-4, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
cache_get_row(cache_get_row_count()-5, 0, Name1); cache_get_row(cache_get_row_count()-5, 2, Reason); cache_get_row(cache_get_row_count()-5, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
cache_get_row(cache_get_row_count()-6, 0, Name1); cache_get_row(cache_get_row_count()-6, 2, Reason); cache_get_row(cache_get_row_count()-6, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
cache_get_row(cache_get_row_count()-7, 0, Name1); cache_get_row(cache_get_row_count()-7, 2, Reason); cache_get_row(cache_get_row_count()-7, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
cache_get_row(cache_get_row_count()-8, 0, Name1); cache_get_row(cache_get_row_count()-8, 2, Reason); cache_get_row(cache_get_row_count()-8, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
cache_get_row(cache_get_row_count()-9, 0, Name1); cache_get_row(cache_get_row_count()-9, 2, Reason); cache_get_row(cache_get_row_count()-9, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
cache_get_row(cache_get_row_count()-10, 0, Name1); cache_get_row(cache_get_row_count()-10, 2, Reason); cache_get_row(cache_get_row_count()-10, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
return ShowPlayerDialog(playerid, 3654, DIALOG_STYLE_TABLIST_HEADERS, "Reports",handle,"Exit", "");
}
if(cache_get_row_count() >= 10) {
cache_get_row(10, 0, Name1); cache_get_row(10, 2, Reason); cache_get_row(10, 3, Date);
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
strcat(handle,string);}
if(cache_get_row_count() >= 9) {
cache_get_row(8, 0, Name1); cache_get_row(8, 2, Reason); cache_get_row(8, 3, Date);
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
strcat(handle,string);}
if(cache_get_row_count() >= 8) {
cache_get_row(7, 0, Name1); cache_get_row(7, 2, Reason); cache_get_row(7, 3, Date);
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
strcat(handle,string);}
if(cache_get_row_count() >= 7) {
cache_get_row(6, 0, Name1); cache_get_row(6, 2, Reason); cache_get_row(6, 3, Date);
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
strcat(handle,string);}
if(cache_get_row_count() >= 6) {
cache_get_row(5, 0, Name1); cache_get_row(5, 2, Reason); cache_get_row(5, 3, Date);
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
strcat(handle,string);}
if(cache_get_row_count() >= 5) {
cache_get_row(4, 0, Name1); cache_get_row(4, 2, Reason); cache_get_row(4, 3, Date);
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
strcat(handle,string);}
if(cache_get_row_count() >= 4) {
cache_get_row(3, 0, Name1); cache_get_row(3, 2, Reason); cache_get_row(3, 3, Date);
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
strcat(handle,string);}
if(cache_get_row_count() >= 3) {
cache_get_row(2, 0, Name1); cache_get_row(2, 2, Reason); cache_get_row(2, 3, Date);
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
strcat(handle,string);}
if(cache_get_row_count() >= 2) {
cache_get_row(1, 0, Name1);cache_get_row(1, 2, Reason); cache_get_row(1, 3, Date);
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
strcat(handle,string);}
if(cache_get_row_count() >= 1) {
cache_get_row(0, 0, Name1); cache_get_row(0, 2, Reason); cache_get_row(0, 3, Date);
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date);
strcat(handle,string);}
ShowPlayerDialog(playerid, 3654, DIALOG_STYLE_TABLIST_HEADERS, "Reports",handle,"Exit", "");
}
if(!rows) {
SendClientMessage(playerid,-1,"There Are no Reports at this moment");
}
return 1;
}
and here we go delete report:
PHP код:
CMD:dreport(playerid,params[]) {
if(IsPlayerAdmin(playerid)) {
if(isnull(params)) return SendClientMessage(playerid,-1,"usage /dreport [name]");
new Query[250];
mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM `reports` WHERE `Name` = '%e'",params); // read player account
mysql_tquery(mysql, Query, "DeleteReport", "i", playerid); // to read if player account exist
} else return SendClientMessage(playerid,-1,"ERROR:You should be rcon to use this command");
return 1;
}
forward DeleteReport(playerid);
public DeleteReport(playerid){
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
new Query[250],Name1[MAX_PLAYER_NAME+1];
cache_get_field_content(0, "Name", Name1, mysql, sizeof(Name1));
format(Query, 100, "DELETE FROM `reports` WHERE `Name` = '%s'", Name1);
mysql_tquery(mysql, Query, "", "");
SendClientMessage(playerid,-1,"Report Successfully Deleted");
} if(!rows) {
return SendClientMessage(playerid,-1,"Name Not Exist on database");
}
return 1;
}