63 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			SourcePawn
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			SourcePawn
		
	
	
	
	
	
#include <sourcemod>
 | 
						|
#include <sdktools>
 | 
						|
 | 
						|
int map_switches_count = -1;
 | 
						|
char g_cMaps[500][256];
 | 
						|
 | 
						|
//----------------------------------------------------------------------------------------------------
 | 
						|
// Purpose:
 | 
						|
//----------------------------------------------------------------------------------------------------
 | 
						|
public Plugin myinfo =
 | 
						|
{
 | 
						|
	name = "spam map restarts and counting each time",
 | 
						|
	author = "jenz",
 | 
						|
	description = "spam map restarts",
 | 
						|
	version = "2.0.0",
 | 
						|
	url = "www.unloze.com"
 | 
						|
};
 | 
						|
 | 
						|
//----------------------------------------------------------------------------------------------------
 | 
						|
// Purpose:
 | 
						|
//----------------------------------------------------------------------------------------------------
 | 
						|
public void OnPluginStart()
 | 
						|
{
 | 
						|
    RegAdminCmd("sm_restartmaps_test", cmd_restart_the_map, ADMFLAG_GENERIC);
 | 
						|
 | 
						|
    new Handle:fileHandle = OpenFile("wtf.txt", "r" );
 | 
						|
    char lineBuffer[256];
 | 
						|
    int count = 0;
 | 
						|
    while( !IsEndOfFile( fileHandle ) && ReadFileLine( fileHandle, lineBuffer, sizeof( lineBuffer ) ) )
 | 
						|
    {
 | 
						|
        TrimString( lineBuffer );
 | 
						|
        Format(g_cMaps[count], sizeof(g_cMaps[]), lineBuffer);
 | 
						|
        count++;
 | 
						|
    }
 | 
						|
    CloseHandle( fileHandle );
 | 
						|
    map_switches_count = -1;
 | 
						|
}
 | 
						|
 | 
						|
public Action cmd_restart_the_map(int client, int args)
 | 
						|
{
 | 
						|
    map_switches_count = 0;
 | 
						|
    OnMapStart();
 | 
						|
    return Plugin_Handled;
 | 
						|
}
 | 
						|
 | 
						|
public void OnMapStart()
 | 
						|
{
 | 
						|
    if (map_switches_count != -1 && map_switches_count < 400)
 | 
						|
    {
 | 
						|
        CreateTimer(5.0, time_query_activity);
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
public Action time_query_activity(Handle timer, any data)
 | 
						|
{
 | 
						|
    LogError("restart count reached: %i", map_switches_count);
 | 
						|
    int local = map_switches_count;
 | 
						|
    map_switches_count++;
 | 
						|
    ForceChangeLevel(g_cMaps[local], "");
 | 
						|
    return Plugin_Handled;
 | 
						|
}
 | 
						|
 |