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;
}