Определенная карта в определенное время суток

  • Автор темы bigbrain911
  • Дата начала
B

bigbrain911

Подскажите есть ли плагин позволяющий ставить определенную карту на сервере в определенное время суток, допустим с 24-00 до 6-00 de_dust2, когда то вроде бы попадался плагин, но не нашел.
 

Hejter

xor ebx, ebx
Сообщения
1,759
Реакции
393
Подскажите есть ли плагин позволяющий ставить определенную карту на сервере в определенное время суток, допустим с 24-00 до 6-00 de_dust2, когда то вроде бы попадался плагин, но не нашел.

Перепишешь под себя.

PHP:
#include <sourcemod> 
#include <sdktools>

//----------------------------------------------------------------------------------------------------------------------
public Plugin:myinfo = {
	name = "latenightmayhem",
	author = "roker + PRAY&SPRAY = oh SHIT",
	description = "Changes settings at different times",
	version = "1.0.0",
	url = "www.reflex-gamers.com"
};

new Handle:sm_latehour;
new c_latehour;
new Handle:sm_earlyhour;
new c_earlyhour; 
new Handle:mp_timelimit;
new old_timelimit; 
new setting ;

enum {
	NULLMODE,
	NIGHTMODE,
	DAYMODE
};

//-------------------------------------------------------------------------------------------------
RecacheConvars() {
	c_latehour = GetConVarInt( sm_latehour );
	c_earlyhour = GetConVarInt( sm_earlyhour ); 
}

//-------------------------------------------------------------------------------------------------
public OnConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[]) {
	// RECACHE CONVARS WHEN THEY CHANGE
	RecacheConvars();
	// now they are in HOT MEMORY ready to be ACCESSED.
}

CacheTimeLimit() {
	old_timelimit = GetConVarInt( mp_timelimit );
}
 
//-------------------------------------------------------------------------------------------------
public OnPluginStart() {	
	sm_latehour = CreateConVar( "sm_latehour", "00", "Hour late settings should kick in.", FCVAR_PLUGIN );
	sm_earlyhour = CreateConVar( "sm_earlyhour", "10", "Hour default settings should kick in.", FCVAR_PLUGIN );
	HookConVarChange( sm_latehour, OnConVarChanged );
	HookConVarChange( sm_earlyhour, OnConVarChanged ); 
	RecacheConvars(); // you see this clean ass shit man? this is how you make convars.
	
	//c_defaultmaptime = CreateConVar( "sm_defaultmaptime", "30.0", "Default map time.", FCVAR_PLUGIN );
	
	mp_timelimit = FindConVar( "mp_timelimit" ); 
	CacheTimeLimit();
	
	CreateTimer(300.0, CheckTime, _, TIMER_REPEAT); // CHECK EVERY 5 MINUTES
}

//-------------------------------------------------------------------------------------------------
public OnConfigsExecuted() {	
	setting = NULLMODE;
	CacheTimeLimit(); // THIS PROBABLY ISN'T NECESSARY but.
	Update();
}

//-------------------------------------------------------------------------------------------------
public Action:CheckTime(Handle:timer){ 
	Update();
	return Plugin_Continue;
}

//-------------------------------------------------------------------------------------------------
public Update(){

	decl String:time[30];	
	new hour;
	FormatTime(time, sizeof(time), "%H", GetTime());
	hour = StringToInt(time); 
	if( c_latehour < c_earlyhour ){
		if( hour >= c_latehour && hour < c_earlyhour ){
			ChangeSetting( NIGHTMODE );
		} else {
			ChangeSetting( DAYMODE );
		}
	} else {
		if(hour >= c_latehour || hour < c_earlyhour ){
			ChangeSetting( NIGHTMODE );
		} else {
			ChangeSetting( DAYMODE );
		}
	} 
}

//-------------------------------------------------------------------------------------------------
ChangeSetting( newsetting ) {
	if( setting == newsetting ) return;
	setting = newsetting;
	
	decl String:map[30];
	GetCurrentMap(map,sizeof(map));
	//PrintToServer("test%i",StrContains(map,"plr_hightower",false));
	if( setting == NIGHTMODE ){
		if( StrContains(map,"plr_hightower",false) != 0 ){
			SetConVarString( FindConVar("sm_nextmap"), "plr_hightower");
		} else {
			SetConVarInt( mp_timelimit, 0 );
		}
		ServerCommand( "sm plugins unload rockthevote" );
	} else {
		ServerCommand( "sm plugins load rockthevote" );
		SetConVarInt( mp_timelimit, old_timelimit );
	}
}

Вот еще версия от этого же автора, она более понятна.


PHP:
/* /////////////////////////////////
// ______________  ___________ 
// \______   \   \/  /  _____/ 
//  |       _/\     /   \  ___ 
//  |    |   \/     \    \_\  \
//  |____|_  /___/\  \______  /
//         \/      \_/      \/
//     R E F L E X  -  G A M E R S
*/

#include <sourcemod>
#include <sdktools>

//----------------------------------------------------------------------------------------------------------------------
public Plugin:myinfo = {
	name = "night mode",
	author = "REFLEX-GAMERS",
	description = "Nighttime Special Mode",
	version = "1.0.0",
	url = "www.reflex-gamers.com"
};

// set this plugin's lifetime to "global" !

//----------------------------------------------------------------------------------------------------------------------
new Handle:nm_time_start; // what time range to check for server death and switch gamemodes
new Handle:nm_time_end; // format for each is HH:MM
//new Handle:nm_hostname_normal; //
new Handle:nm_hostname; // 
new Handle:nm_clients_threshold;

new c_time_start;
new c_time_end;
new c_clients_threshold;

new current_mode;
new transitioning;

new bool:game_active;

enum {
	MODE_REGULAR,
	MODE_NIGHT,
	
	MODE_DEFAULT = MODE_REGULAR
};

//----------------------------------------------------------------------------------------------------------------------
ParseTime( String:time[] ) {
	time[2] = 0;
	return StringToInt( time ) * 60 + StringToInt( time[3] );
}

//----------------------------------------------------------------------------------------------------------------------
CacheTimes() {
	decl String:timestring[64];
	GetConVarString( nm_time_start, timestring, sizeof timestring );
	timestring[5] = 0;
	c_time_start = ParseTime( timestring );
	
	GetConVarString( nm_time_end, timestring, sizeof timestring );
	timestring[5] = 0;
	c_time_end = ParseTime( timestring );
}

//----------------------------------------------------------------------------------------------------------------------
public OnConVarChanged( Handle:cvar, const String:oldval[], const String:newval[] ) {
	if( cvar == nm_time_start || cvar == nm_time_end ) {
		CacheTimes();
	} else if( cvar == nm_clients_threshold ) {
		c_clients_threshold = GetConVarInt( nm_clients_threshold );
	}
}

//----------------------------------------------------------------------------------------------------------------------
public OnPluginStart() {
	
	current_mode = MODE_DEFAULT;
	
	nm_time_start = CreateConVar( "nm_time_start", "03:00", "HH:MM, time of potential nightmode start", FCVAR_PLUGIN );
	nm_time_end = CreateConVar( "nm_time_end", "07:00", "HH:MM, time of nightmode end", FCVAR_PLUGIN );
	//nm_hostname_normal = CreateConVar( "nm_hostname_normal", "<test>", "normal hostname of server, copied from hostname", FCVAR_PLUGIN );
	nm_hostname = CreateConVar( "nm_hostname", "<night mode>", "nightmode hostname of server", FCVAR_PLUGIN );
	nm_clients_threshold = CreateConVar( "nm_clients_threshold", "14", "wait until clients are under this amount before starting nightmode", FCVAR_PLUGIN );
	
	HookConVarChange( nm_time_start, OnConVarChanged );
	HookConVarChange( nm_time_end, OnConVarChanged );
	HookConVarChange( nm_clients_threshold, OnConVarChanged );
	
	CacheTimes();
	c_clients_threshold = GetConVarInt( nm_clients_threshold );
	
	CreateTimer( 120.0, OnTimeUpdate, _, TIMER_REPEAT );
//	CreateTimer( 6.0, OnTimeUpdate, _, TIMER_REPEAT ); // DEBUG
	
	HookEvent( "cs_intermission", Event_Intermission, EventHookMode_PostNoCopy  );
	HookEvent( "cs_match_end_restart", Event_Newmatch, EventHookMode_PostNoCopy  );
	
}

//----------------------------------------------------------------------------------------------------------------------
public OnConfigsExecuted() {
	
	CreateTimer( 3.0, TimerChangeHostname );
}

//----------------------------------------------------------------------------------------------------------------------
public Action:TimerChangeHostname( Handle:timer ) {
	
	//GetConVarString( FindConVar( "hostname" ), buffer, sizeof buffer );
	//SetConVarString( nm_hostname_normal, buffer );
	
	if( current_mode == MODE_NIGHT ) {
		decl String:buffer[256];
		GetConVarString( nm_hostname, buffer, sizeof buffer );
		ServerCommand( "hostname \"%s\"", buffer );
	}
	return Plugin_Handled;
}

//----------------------------------------------------------------------------------------------------------------------
TimeUpdate() {
	if( !game_active ) return;
	if( transitioning ) return;
	
	decl String:timestring[64];
	FormatTime( timestring, sizeof timestring, "%H:%M" );
	
	new minutes = ParseTime( timestring );
	
	if( current_mode == MODE_REGULAR ) {
		
		if( minutes < c_time_start || minutes > c_time_end ) return; // daytime
		
		new active_clients = GetTeamClientCount(2)+GetTeamClientCount(3);
		if( active_clients < c_clients_threshold ) {
			
			StartNightMode();
		}
	} else if( current_mode == MODE_NIGHT ) {
		if( minutes >= c_time_start && minutes <= c_time_end ) return; // nighttime
		StartDayMode();
		
	}
}

//----------------------------------------------------------------------------------------------------------------------
StartNightMode() {
	SetConVarInt( FindConVar( "mp_timelimit" ), 1 ); // end match
	SetConVarInt( FindConVar( "mp_match_end_restart" ), 0 ); // 
	SetConVarInt( FindConVar( "mp_match_end_changelevel" ), 1 ); //
	transitioning = 1;
	
	CreateTimer( 300.0, TimerForceEnd, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE );
	
	current_mode = MODE_NIGHT;
}

//----------------------------------------------------------------------------------------------------------------------
StartDayMode() {
	SetConVarInt( FindConVar( "mp_match_end_restart" ), 0 ); // 
	SetConVarInt( FindConVar( "mp_match_end_changelevel" ), 1 ); //
	transitioning = 1;
	
	CreateTimer( 6000.0, TimerForceEnd, _, TIMER_FLAG_NO_MAPCHANGE );
	
	current_mode = MODE_REGULAR;
}

//----------------------------------------------------------------------------------------------------------------------
public Action:TimerForceEnd( Handle:timer ) {
	new active_clients = GetTeamClientCount(2)+GetTeamClientCount(3);
	if( active_clients > 8 ) { //magic numborrrrrrrrr
		return Plugin_Continue;
	}
	decl String:map[64];
	GetCurrentMap( map, sizeof map );
	ForceChangeLevel( map, "Switching Game Mode" );
	return Plugin_Stop;
}

//----------------------------------------------------------------------------------------------------------------------
public Action:OnTimeUpdate( Handle:timer ) {
	TimeUpdate();
	return Plugin_Handled;
}

//----------------------------------------------------------------------------------------------------------------------
public OnMapStart() {
	game_active = true;
}

//----------------------------------------------------------------------------------------------------------------------
public OnMapEnd() {
	game_active = false;
	
	if( transitioning ) {	
		if( current_mode == MODE_NIGHT ) {
			SetConVarInt( FindConVar( "game_type" ), 1 ); // gungame
			SetConVarInt( FindConVar( "game_mode" ), 2 ); // deathmatch
		} else {
			SetConVarInt( FindConVar( "game_type" ), 0 ); // gungame
			SetConVarInt( FindConVar( "game_mode" ), 0 ); // deathmatch
		}
	}
	
	transitioning = 0;
}

//----------------------------------------------------------------------------------------------------------------------
public Event_Intermission( Handle:event, const String:name[], bool:db ) {
	game_active = false;
	if( transitioning ) {
		if( current_mode == MODE_NIGHT ) {
			PrintToChatAll( "\x01 >> \x0ESwitching to night mode..." );
		} else if( current_mode == MODE_REGULAR ) {
			PrintToChatAll( "\x01 >> \x0ESwitching to day mode..." );
		}
	}
	
}

//----------------------------------------------------------------------------------------------------------------------
public Event_Newmatch( Handle:event, const String:name[], bool:db ) {
	game_active = true;
}
//----------------------------------------------------------------------------------------------------------------------

Возможно подойдет. https://forums.alliedmods.net/showthread.php?t=84720
 
B

bigbrain911

Hejter 2-й код более похож на правду, но вот знаний не хватит довести до ума.
 
Сверху Снизу