Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- /* ================================================================================================
- Vars, Defines, Const
- ================================================================================================*/
- #define MIN_CARACTERES 10
- new const ReportFile[ ] = "reports.txt";
- new const CommandMessageMode[ ] = "Details";
- new const Commands[ ][ ] = { "say /report" , "say /dokladvai" };
- new const ReportOptions[ ][ ] = { "Verbal Abuse" , "Cheating" , "Hiding", "Running", "Other" };
- new const banMinutes[] = { 0, 5, 10, 15, 20, 30, 60, 120, 600 };
- new MaxPlayers;
- new inMessageMode[ 33 ], OptionSelected[ 33 ] , PlayerIDSelected[ 33 ] , UserIDSelected[ 33 ],
- PlayerDetails[ 33 ][ 128 ], PlayerMinutesBan[ 33 ], Reportes[ 33 ], Name[ 33 ][ 32 ], Authid[ 33 ][ 35 ];
- /* ================================================================================================
- Main Forwards
- ================================================================================================*/
- public plugin_init()
- {
- register_plugin( "Reports", "1.0", "trans" );
- static k;
- for( k = 0 ; k < sizeof Commands ; ++k )
- register_clcmd( Commands[ k ] , "clcmdReport" );
- register_clcmd( CommandMessageMode , "cmdDetails" );
- register_clcmd( "say /rewrite", "cmdRewrite" );
- register_clcmd( "say /players", "cmdPlayers" );
- MaxPlayers = get_maxplayers();
- }
- public client_putinserver( index )
- {
- get_user_name( index, Name[index], 31 );
- get_user_authid( index, Authid[index], 34 );
- ResetVars( index );
- }
- public client_infochanged( index )
- {
- get_user_info( index, "name", Name[index], 31 );
- }
- /* ================================================================================================
- Clcmds
- ================================================================================================*/
- public clcmdReport( index )
- {
- if( Reportes[ index ] )
- {
- client_print( index, print_center, "*** Only one report per map is allowed ***" );
- return PLUGIN_HANDLED;
- }
- static menu, k;
- menu = menu_create( " \wSelect option:", "menu_report" );
- for( k = 0 ; k < sizeof ReportOptions ; ++k )
- menu_additem( menu , ReportOptions[k] , "" );
- menu_display( index , menu );
- return PLUGIN_HANDLED;
- }
- public menu_report( index , menu , item )
- {
- if( item == MENU_EXIT )
- {
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- OptionSelected[ index ] = item;
- cmdPlayers( index );
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- public cmdRewrite( index )
- {
- if( !inMessageMode[ index ] )
- {
- client_print( index, print_chat, "You have not completed the report!" );
- client_print( index, print_chat, "To redo the report, type, /report " );
- return PLUGIN_HANDLED;
- }
- client_cmd( index , "messagemode ^"%s^"", CommandMessageMode );
- return PLUGIN_HANDLED;
- }
- public cmdDetails( index )
- {
- if( !inMessageMode[ index ] )
- {
- client_print( index, print_center, "*** NO PERMISSION ***" );
- return PLUGIN_HANDLED;
- }
- read_args( PlayerDetails[ index ], 127 );
- remove_quotes( PlayerDetails[ index ] ) ;
- trim( PlayerDetails[ index ] );
- if( !is_valid_msg(index) )
- {
- client_print( index , print_chat , " Your message contains errors" );
- client_print( index , print_chat , " If you want to rewrite, type / rewrite" );
- PlayerDetails[ index ] = "^0";
- return PLUGIN_HANDLED;
- }
- SendReport(index);
- return PLUGIN_HANDLED;
- }
- /* ================================================================================================
- Menus
- ================================================================================================*/
- /*
- Players Menu
- */
- public cmdPlayers( index )
- {
- static IDS[20], menu, i;
- menu = menu_create(" \wSelect who you want to report:", "menu_players" );
- for( i = 1 ; i <= MaxPlayers ; ++i )
- {
- if( !is_user_connected(i) || i == index ) continue;
- formatex( IDS , charsmax(IDS) , "%d %d" , i , get_user_userid(i) )
- menu_additem( menu , Name[i] , IDS );
- }
- menu_display( index , menu );
- }
- public menu_players( index , menu , item )
- {
- if( item == MENU_EXIT )
- {
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- static varsinuso, buffer[12], szid[3], szuserid[9];
- menu_item_getinfo(menu, item, varsinuso, buffer, charsmax(buffer), _, _, varsinuso);
- parse(buffer, szid, charsmax(szid), szuserid, charsmax(szuserid));
- PlayerIDSelected[ index ] = str_to_num(szid);
- UserIDSelected[ index ] = str_to_num(szuserid);
- if( !is_user_connected( PlayerIDSelected[ index ] )
- || UserIDSelected[ index ] != get_user_userid( PlayerIDSelected[index]) )
- {
- client_print( index , print_chat, " The player has disconnected. (%d)", PlayerIDSelected[ index ] );
- return PLUGIN_HANDLED;
- }
- inMessageMode[ index ] = true;
- client_cmd( index , "messagemode ^"%s^"", CommandMessageMode );
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- /*
- Send Report to admin ( Menu )
- */
- SendReport(index)
- {
- static i, menu, String[ 300 ], ASD[ 20 ];
- formatex( String, charsmax( String ), " \y%s \whas reported \y%s^n\wReason:\y %s", Name[index], Name[ PlayerIDSelected[index] ], ReportOptions[ OptionSelected[index] ] );
- menu = menu_create( String , "menu_adm" );
- formatex( ASD, 19, "%d %d", index, get_user_userid(index) );
- menu_additem( menu , "\wSee Details" , ASD );
- menu_additem( menu , "\rTake actions" , ASD );
- menu_additem( menu , "\yIgnore^n", "3" );
- for( i = 1 ; i <= MaxPlayers ; ++i )
- {
- if( !is_user_connected(i) || !is_user_admin(i) ) continue;
- menu_display( i , menu );
- }
- CreateLog( index );
- Reportes[ index ] = true;
- }
- public menu_adm( index , menu , item )
- {
- if( item == MENU_EXIT || item == 2 )
- {
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- static varsinuso, buffer[12], szid[3], szuserid[9], playerid, userid;
- menu_item_getinfo(menu, item, varsinuso, buffer, charsmax(buffer), _, _, varsinuso);
- parse(buffer, szid, charsmax(szid), szuserid, charsmax(szuserid));
- playerid = str_to_num(szid);
- userid = str_to_num(szuserid);
- if( !is_user_connected( playerid )
- || userid != get_user_userid( playerid ) )
- {
- client_print( index , print_chat, "The player who made the report has disconnected. (%d)", playerid );
- return PLUGIN_HANDLED;
- }
- PlayerIDSelected[ index ] = PlayerIDSelected[ playerid ];
- UserIDSelected[ index ] = UserIDSelected[ playerid ];
- OptionSelected[ index ] = OptionSelected[ playerid ];
- switch( item )
- {
- case 0:
- {
- static String[ 3500 ], Ip[2][20], len; len = 0
- get_user_ip( playerid , Ip[0], 19, 1 );
- get_user_ip( PlayerIDSelected[index] , Ip[1], 19, 1 );
- len += formatex( String[len], sizeof String-len, "<!doctype html>\
- <html>\
- <head>\
- <title>Reports</title>\
- </head>\
- <body bgcolor=^"000000^">\
- <h1><span style=^"color:#00FF00;^">Report</span></h1>\
- <p><span style=^"color:#FF0000;^"><strong>====================================================</strong></span></p>\
- <p> </p>" );
- len += formatex( String[len], sizeof String-len, "<p><span style=^"color:#40E0D0;^">%s</span>\
- <span style=^"color:#FFF0F5;^">(</span><span style=^"color:#40E0D0;^">%s</span>\
- <span style=^"color:#FFF0F5;^">)(</span><span style=^"color:#40E0D0;^">%s</span>", Name[playerid], Ip[0], Authid[playerid] );
- len += formatex( String[len], sizeof String-len,"<span style=^"color:#FFF0F5;^">)</span><span style=^"color:#00FF00;^">Ha reportado a </span>\
- <span style=^"color:#40E0D0;^">%s</span>\
- <span style=^"color:#FFF0F5;^">(</span><span style=^"color:#40E0D0;^">%s</span>", Name[PlayerIDSelected[index]], Ip[1] );
- len += formatex( String[len], sizeof String-len,"<span style=^"color:#FFF0F5;^">)(</span><span style=^"color:#40E0D0;^">%s</span>\
- <span style=^"color:#FFF0F5;^">)</span></p>",
- Authid[PlayerIDSelected[index]] );
- len += formatex(String[len], sizeof String-len, "<p> </p>\
- <p><span style=^"color:#00FF00;^">Reason</span>:\
- <span style=^"color:#40E0D0;^">%s</span></p>", ReportOptions[ OptionSelected[ index ] ] );
- len += formatex(String[len], sizeof String-len, "<p><span style=^"color:#00FF00;^">More Info:</span></p><p> </p>\
- <p><span style=^"color:#FF0000;^"><strong>============================\
- ========================</strong></span></p><p> </p>" );
- len += formatex(String[len], sizeof String-len, "<p><span style=^"color:#00FF00;^">%s</span></p><p> </p>\
- <p><span style=^"color:#FF0000;^"><strong>====================================================</strong></span></p>",
- PlayerDetails[ index ]);
- len += formatex( String[len], sizeof String-len, "</body></html>" );
- show_motd( index, String, "Report" );
- showMenuBan( index );
- }
- case 1: showMenuBan( index );
- }
- ResetVars( playerid );
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- /*
- Menu Sancion
- */
- showMenuBan( index )
- {
- static menu, String[128];
- formatex( String, 127, "\wChoose the option to apply to:^n^t^t^t^t\y%s", Name[ PlayerIDSelected[index] ] );
- menu = menu_create( String , "menu_handler" );
- menu_additem( menu , "Send warning^n^t^t\dA MOTD opens with the warning^n", "1" );
- menu_additem( menu , "Ban^n^t^t\dYou set the minutes for the ban length^n^n", "2" );
- menu_additem( menu , "Kick", "3" );
- menu_display( index , menu );
- }
- public menu_handler( index , menu , item )
- {
- switch( item )
- {
- case 0:
- {
- SendAdvert( index );
- client_print( index, print_chat, "A warning was sent to %s", Name[PlayerIDSelected[index]] );
- }
- case 1: ShowMenuMinutes( index );
- case 2: client_cmd( index, "amx_kick ^"%s^" ^"%s^"", Name[PlayerIDSelected[index]], ReportOptions[ OptionSelected[index] ]);
- case MENU_EXIT: { menu_destroy( menu ); return PLUGIN_HANDLED; }
- }
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- /*
- Choose Minutes Ban
- */
- ShowMenuMinutes( index )
- {
- static i, String[128], menuban; menuban = menu_create( "\wBan length?", "menu_ban" );
- for( i = 0; i < sizeof banMinutes; ++i)
- {
- if( i == 0 )
- formatex( String, charsmax( String ), "\rPermanent" );
- else
- formatex( String, charsmax( String ), "%d minutes", banMinutes[i] );
- menu_additem( menuban, String, "" );
- }
- menu_display( index , menuban );
- }
- public menu_ban( index, menu, item )
- {
- if( item != MENU_EXIT )
- {
- PlayerMinutesBan[ index ] = banMinutes[item];
- ShowConfirmMenu( index );
- }
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- /*
- Ban Confirm Menu
- */
- ShowConfirmMenu( index )
- {
- static menu, String[128], minutes[50];
- if( PlayerMinutesBan[index] == 0 )
- formatex( minutes, charsmax(minutes), "\rPermanent" );
- else
- formatex( minutes, charsmax(minutes), "\r%d minutes", PlayerMinutesBan[index] );
- formatex( String, charsmax( String ), " \wAre you sure?^n\y\dBan \y%s %s", Name[ PlayerIDSelected[index] ], minutes );
- menu = menu_create( String, "menu_confirm" );
- menu_additem( menu, "Yes, I'm sure^n", "1" );
- menu_additem( menu, "No, change ban time", "2" );
- menu_additem( menu, "No, just warn him", "3" );
- menu_display( index, menu );
- }
- public menu_confirm( index , menu , item )
- {
- switch( item )
- {
- case 0:
- {
- client_cmd( index, "amx_banip ^"%s^" ^"%d^" ^"%s^"",
- Name[ PlayerIDSelected[index] ], PlayerMinutesBan[ index ], ReportOptions[ OptionSelected[index] ] );
- ResetVars( index );
- }
- case 1: ShowMenuMinutes( index );
- case 2:
- {
- SendAdvert( index );
- client_print( index, print_chat, "A warning was sent to %s", Name[PlayerIDSelected[index]] );
- ResetVars(index);
- }
- case MENU_EXIT:
- {
- menu_destroy( menu );
- ResetVars(index);
- return PLUGIN_HANDLED;
- }
- }
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- /*
- Stocks 'N Internal Functions
- */
- SendAdvert( index )
- {
- static String[ 2500 ], len; len = 0;
- len += formatex( String[len], sizeof String-len, "<!doctype html><html><head>\
- <title>Warning</title></head><body bgcolor=^"#000000^">\
- <h1 style=^"text-align: center;^"><span style=^"color:#FF0000;^">Warning</span></h1>");
- len += formatex( String[len], sizeof String-len, "<p><span style=^"color:#00FF00;^">====================================================</span></p>\
- <p><span style=^"color:#FFF0F5;^">The admin</span><span style=^"color:#00FF00;^"> </span><span style=^"color:#FF0000;^">%s</span><span style=^"color:#00FF00;^">", Name[index] );
- len += formatex( String[len], sizeof String-len, "</span><span style=^"color:#FFF0F5;^">has sent you a</span><span style=^"color:#00FF00;^"> </span><span style=^"color:#B22222;^">warning</span>\
- <span style=^"color:#FFF0F5;^">, because there has been a report </span></p><p><span style=^"color:#FFF0F5;^">on you.</span></p>");
- len += formatex( String[len], sizeof String-len, "<p> </p><p><span style=^"color:#FFF0F5;^">Reason:</span><span style=^"color:#00FF00;^">\
- </span><span style=^"color:#FF0000;^">%s</span></p>\
- <p><span style=^"color:#00FF00;^">====================================================</span></p>"
- , ReportOptions[ OptionSelected[index] ] );
- len += formatex( String[len], sizeof String-len, "</body></html>");
- show_motd( PlayerIDSelected[index], String, "Advertencia" );
- }
- CreateLog( index )
- {
- static String[ 512 ], Name[2][32], Ip[2][20], authid[2][35];
- get_user_name( index , Name[0], 31 );
- get_user_name( PlayerIDSelected[index] , Name[1], 31 );
- get_user_ip( index , Ip[0], 19, 1 );
- get_user_ip( PlayerIDSelected[index] , Ip[1], 19, 1 );
- get_user_authid( index, authid[0], 34 );
- get_user_authid( PlayerIDSelected[index], authid[1], 34 );
- formatex( String, charsmax(String), "^n^n%s <%s><%s> You have reported %s <%s><%s> Reason: %s^nMore info:^n%s^n==========================",
- Name[0], Ip[0], authid[0], Name[1], Ip[1], authid[1], ReportOptions[ OptionSelected[index] ], PlayerDetails[index] );
- log_to_file( ReportFile, String );
- }
- ResetVars( index )
- {
- inMessageMode[ index ] = Reportes[ index ] = false;
- OptionSelected[ index ] = -1;
- PlayerIDSelected[ index ] = UserIDSelected[ index ] = PlayerMinutesBan[index] = 0;
- PlayerDetails[ index ][0] = EOS;
- }
- stock is_valid_msg(index)
- {
- if ( strlen( PlayerDetails[index] ) < MIN_CARACTERES )
- return false;
- if( containi( PlayerDetails[index], "%" ) != -1 )
- return false;
- if( !is_user_connected(PlayerIDSelected[index]) || UserIDSelected[ index ] != get_user_userid( PlayerIDSelected[index]) )
- return false;
- return true;
- }
- /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
- *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement