Здравствуйте, гость Вход | Регистрация
Наши новости:
|
| Дата поста: | В теме: | За сообщение: | Спасибо сказали: | ||
|---|---|---|---|---|---|
| 17.11.2012, 17:57 | HostnameTimeleft | Здравствуйте, аноны;3 помоги с плагином hostnametimeleft, надо сделать чтобы каждые к примеру 5 секунд, название сервер менялось, есть исходник... Плагин Где требуется Помощь #include <amxmodx> #include <engine> #pragma semicolon 1 #define UPDATE_TIME 1.0 #define ENTITY_CLASS "env_host_timeleft" new bool:g_timerRunning = false; new g_MsgServerName; new g_szHostname[ 64 ]; new g_pointerTimelimit; new g_pointerHostname; new g_cvarEnabled; new g_cvarStyle; public plugin_init() { register_plugin( "Hostname Timeleft", "1.0", "xPaw" ); g_cvarEnabled = register_cvar( "sv_hostname_timeleft", "1" ); g_cvarStyle = register_cvar( "sv_hostname_style", "3" ); g_pointerTimelimit = get_cvar_pointer( "mp_timelimit" ); g_pointerHostname = get_cvar_pointer( "hostname" ); g_MsgServerName = get_user_msgid( "ServerName" ); // Give delay to load configs... set_task( 2.5, "checkTimeleft" ); } public plugin_end( ) if( g_timerRunning ) if( strlen( g_szHostname ) ) set_pcvar_string( g_pointerHostname, g_szHostname ); public checkTimeleft( ) { get_pcvar_string( g_pointerHostname, g_szHostname, 63 ); if( get_pcvar_num( g_cvarEnabled ) != 1 ) { g_timerRunning = false; return; } else register_think( ENTITY_CLASS, "fwdThink_Updater" ); g_timerRunning = true; // initialize thinking entity... new iEntityTimer = create_entity( "info_target" ); entity_set_string( iEntityTimer, EV_SZ_classname, ENTITY_CLASS ); entity_set_float( iEntityTimer, EV_FL_nextthink, get_gametime() + UPDATE_TIME ); } public fwdThink_Updater( iEntity ) { static szHostname[ 64 ], iStyle; iStyle = get_pcvar_num( g_cvarStyle ); if( get_pcvar_float( g_pointerTimelimit ) ) { static iHours, iMinutes, iSeconds; iSeconds = get_timeleft( ); iMinutes = iSeconds / 60; iHours = iMinutes / 60; iSeconds = iSeconds - iMinutes * 60; iMinutes = iMinutes - iHours * 60; if( iHours ) { switch( iStyle ) { case 1: formatex( szHostname, 63, "%s (Timeleft %d:%02d:%02d)", g_szHostname, iHours, iMinutes, iSeconds ); case 2, 4: formatex( szHostname, 63, "%s (%d:%02d:%02d)", g_szHostname, iHours, iMinutes, iSeconds ); case 3, 5: formatex( szHostname, 63, "(%d:%02d:%02d) %s", iHours, iMinutes, iSeconds, g_szHostname ); } } else { switch( iStyle ) { case 1: formatex( szHostname, 63, "%s (Timeleft %d:%02d)", g_szHostname, iMinutes, iSeconds ); case 2, 4: formatex( szHostname, 63, "%s (%d:%02d)", g_szHostname, iMinutes, iSeconds ); case 3, 5: formatex( szHostname, 63, "(%d:%02d) %s", iMinutes, iSeconds, g_szHostname ); } } } else { switch( iStyle ) { case 1: formatex( szHostname, 63, "%s (No time limit)", g_szHostname ); case 2, 4: formatex( szHostname, 63, "%s (--:--)", g_szHostname ); case 3, 5: formatex( szHostname, 63, "(--:--) %s", g_szHostname ); } } if( iStyle < 4 ) set_pcvar_string( g_pointerHostname, szHostname ); message_begin( MSG_BROADCAST, g_MsgServerName ); write_string( szHostname ); message_end( ); entity_set_float( iEntity, EV_FL_nextthink, get_gametime() + UPDATE_TIME ); return PLUGIN_CONTINUE; } |
abc-cba, sweet | ||