Style C4 Timer OciXCrom

Сообщения
282
Реакции
34
Помог
3 раз(а)
Ошибка
For some reason, plugin goes in new row like this:
[code]
[ - - - - - - - - - - - - - -
- - ]
[/code]
ОС
Linux
Amx Mod X
AMX Mod X 1.10.0.5453
C++
Билд
reHLDS 3.12.0.780-dev
C++
ReGamedll
5.21.0.556
C++
Версия Metamod
1.31
C++
Список метамодулей
[ 1] SafeNameAndChat  RUN   -    SafeNameAndChat.so          v1.1             ini  ANY   ANY  
 [ 2] Reunion          RUN   -    reunion_mm_i386.so          v0.1.0.137       ini  Start Never
 [ 3] AMX Mod X        RUN   -    amxmodx_mm_i386.so          v1.10.0.5453     ini  Start ANY  
 [ 4] ReAuthCheck      RUN   -    reauthcheck_mm_i386.so      v0.1.6           ini  Start Never
 [ 5] ReSemiclip       RUN   -    resemiclip_mm_i386.so       v2.3.9           ini  Chlvl ANY  
 [ 6] Rechecker        RUN   -    rechecker_mm_i386.so        v2.7             ini  Chlvl ANY  
 [ 7] WHBlocker        RUN   -    whblocker_mm_i386.so        v1.5.697         ini  Chlvl ANY  
 [ 8] ReSRDetector     RUN   -    resrdetector_mm_i386.so     v0.1.0           ini  Chlvl ANY  
 [ 9] Revoice          RUN   -    revoice_mm_i386.so          v0.1.0.34        ini  Start Never
 [10] HitBox Fix       RUN   -    hitbox_fix_mm_i386.so       v1.1.1           ini  Start ANY  
 [11] Admins Kit       RUN   -    adminskit_amxx_i386.so      v2.1.0           pl3  ANY   ANY  
 [12] FakeMeta         RUN   -    fakemeta_amxx_i386.so       v1.10.0.5453     pl3  ANY   ANY  
 [13] MySQL            RUN   -    mysql_amxx_i386.so          v1.10.0.5453     pl3  ANY   ANY  
 [14] Ham Sandwich     RUN   -    hamsandwich_amxx_i386.so    v1.10.0.5453     pl3  ANY   ANY  
 [15] Engine           RUN   -    engine_amxx_i386.so         v1.10.0.5453     pl3  ANY   ANY  
 [16] ReAPI            RUN   -    reapi_amxx_i386.so          v5.22.0.254-dev  pl3  ANY   Never
 [17] CStrike          RUN   -    cstrike_amxx_i386.so        v1.10.0.5453     pl3  ANY   ANY  
 [18] Fun              RUN   -    fun_amxx_i386.so            v1.10.0.5453     pl3  ANY   ANY  
 [19] GeoIP            RUN   -    geoip_amxx_i386.so          v1.10.0.5453     pl3  ANY   ANY  
 [20] ReAimDetector    RUN   -    reaimdetector_amxx_i386.so  v0.2.2           pl3  ANY   Never
20 plugins, 20 running
C++
Список плагинов
[  1] 0   FreshBans               1.4.6b      kanagava          unknown                          fresh_bans_  running  
 [  2] 1   ScreenMaker             1.1         neygomon                                           screen_make  running  
 [  3] 2   CSStatsX SQL            0.7.4+2     serfreeman1337    unknown                          csstatsx_sq  debug    
 [  4] 3   unknown                 unknown     unknown           unknown                          aes_statsx_  bad load 'dont worry this is going to be fixed in next map...
 [  5] 4   Admin Base              1.10.0.545  AMXX Dev Team                                      admin.amxx   running  
 [  6] 5   AdminListen             2.3x        /dev/ urandom /   unknown                          adminlisten  running  
 [  7] 6   Admin Commands          1.10.0.545  AMXX Dev Team                                      admincmd.am  running  
 [  8] 7   Admin Help              1.10.0.545  AMXX Dev Team                                      adminhelp.a  running  
 [  9] 8   Multi-Lingual System    1.10.0.545  AMXX Dev Team                                      multilingua  running  
 [ 10] 9   Menus Front-End         1.10.0.545  AMXX Dev Team                                      menufront.a  running  
 [ 11] 10  Commands Menu           1.10.0.545  AMXX Dev Team                                      cmdmenu.amx  running  
 [ 12] 11  Players Menu            1.10.0.545  AMXX Dev Team                                      plmenu.amxx  running  
 [ 13] 12  Pause Plugins           1.10.0.545  AMXX Dev Team                                      pausecfg.am  running  
 [ 14] 13  Maps Menu               1.10.0.545  AMXX Dev Team                                      mapsmenu.am  running  
 [ 15] 14  Plugin Menu             1.10.0.545  AMXX Dev Team                                      pluginmenu.  running  
 [ 16] 15  Anti Flood              1.10.0.545  AMXX Dev Team                                      antiflood.a  running  
 [ 17] 16  Scrolling Message       1.10.0.545  AMXX Dev Team                                      scrollmsg.a  running  
 [ 18] 17  Info. Messages          1.10.0.545  AMXX Dev Team                                      imessage.am  running  
 [ 19] 18  Admin Votes             1.10.0.545  AMXX Dev Team                                      adminvote.a  running  
 [ 20] 19  Map Manager: Core       3.1.5       Mistrick          unknown                          map_manager  running  
 [ 21] 20  Map Manager: Scheduler  0.1.10      Mistrick          unknown                          map_manager  running  
 [ 22] 21  Map Manager: Rtv        0.1.1       Mistrick          unknown                          map_manager  running  
 [ 23] 22  Map Manager: Nominatio  0.2.1       Mistrick          unknown                          map_manager  running  
 [ 24] 23  Map Manager: BlockList  0.0.4       Mistrick          unknown                          map_manager  running  
 [ 25] 24  Map Manager: Online so  0.0.4       Mistrick          unknown                          map_manager  running  
 [ 26] 25  Map Manager: Effects    0.1.1       Mistrick          unknown                          map_manager  running  
 [ 27] 26  Map Manager: Informer   0.0.5       Mistrick          unknown                          map_manager  running  
 [ 28] 27  Map Manager: Sounds     0.0.2       Mistrick          unknown                          map_manager  running  
 [ 29] 28  Map Manager: Advanced   0.1.0       Mistrick          unknown                          map_manager  running  
 [ 30] 29  Map Manager: Priority   0.0.2       Mistrick          unknown                          map_manager  running  
 [ 31] 30  Stats Configuration     1.10.0.545  AMXX Dev Team                                      statscfg.am  running  
 [ 32] 31  Unreal Cheater Cry      1.0.11      Karaulov          unknown                          unreal_chea  running  
 [ 33] 32  [Advanced Slot Reserva  2.2         Shadows Adi       unknown                          advanced_sl  running  
 [ 34] 33  Temporary Flags         1.0         drag1c            unknown                          temp_flags.  running  
 [ 35] 34  Restrict Weapons        1.10.0.545  AMXX Dev Team                                      restmenu.am  running  
 [ 36] 35  [ReAPI] Best player of  1.1.2       F@nt0M                                             best_player  running  
 [ 37] 36  Say me and Say hp       1.4         neygomon                                           sayme_reapi  running  
 [ 38] 37  Std Admin Color Chat    1.1.1       Van der Cal       unknown                          kgb_admin_c  running  
 [ 39] 38  Deluxe Admin Chat       1.7         Hell Phoenix/EJL  unknown                          amx_ejl_adm  running  
 [ 40] 39  Unreal Spawn Fixer      1.1         karaulov          unknown                          spawnfix.am  running  
 [ 41] 40  Task Scheduler          0.2         JustinHoMi        unknown                          task_schedu  running  
 [ 42] 41  Reset Score             1.0         Silenttt          unknown                          ressetscore  running  
 [ 43] 42  Autoresponder/Advertis  0.5         MaximusBrood      unknown                          ad_manager.  running  
 [ 44] 43  AFK Control ReNew       1.2(a)      neygomon          unknown                          afk_control  running  
 [ 45] 44  Bypass Guard            1.0.1       mx?!                                               bypass_guar  running  
 [ 46] 45  [BG] Provider: GeoIP    0.2         mx?!                                               bg_provider  running  
 [ 47] 46  Restrict Names          1.2a        Brad Jones        unknown                          restrictnam  running  
 [ 48] 47  Admin Commands Log      1.2.1       twisterniq        https://github.com/twisterniq/a  admin_comma  running  
 [ 49] 48  Exec                    1.0         ToXiC             unknown                          exec.amxx    running  
 [ 50] 49  Admin ESP               1.0         neygomon          unknown                          admin_esp.a  running  
 [ 51] 50  Models Replacement      0.0.2       ConnorMcLeod | V  unknown                          models_repl  running  
 [ 52] 51  [ReAPI] Slay Losers     1.0         drag1c            unknown                          reapi_slayl  running  
 [ 53] 52  AMXX Gag                1.5.0       xPaw & Exolent                                     amxgag.amxx  running  
 [ 54] 53  [ReAPI] No Team Flash   0.0.2       Vaqtincha         unknown                          no_team_fla  running  
 [ 55] 54  WalkGuard               1.3.2       mogel             unknown                          walkguard_t  running  
 [ 56] 55  Music Round End         1.2.7       Jumper            unknown                          MusicRoundE  running  
 [ 57] 56  ReAimDetector API       0.2.2       ReHLDS Team       unknown                          reaimdetect  running  
 [ 58] 57  Ping Checker            26.0.1 RC1  h1k3              unknown                          ping_checke  running  
 [ 59] 58  Frags Counter           1.0         CHEL74            unknown                          frags_count  running  
 [ 60] 59  GameName Wins           1.0.4       twisterniq        https://github.com/twisterniq/a  gamename_wi  running  
 [ 61] 60  Mode 2x2                2.5re       s1lent                                             mode.amxx    running  
 [ 62] 61  [ReAPI] AWPoff          1.4.3       PAffAEJIkA :3                                      awp_off.amx  running  
 [ 63] 62  Auto Team Balance Adva  1.5.1       Radius            unknown                          auto_team_b  running  
 [ 64] 63  [ReAPI] Block Fire in   3.1.0       F@nt0M            unknown                          reapi_block  running  
 [ 65] 64  Auto Set Steam Flag     1.0.0       drag1c            unknown                          steam_free_  running  
 [ 66] 65  Bullet Damage           1.0         drag1c                                             bullet_dama  running  
 [ 67] 66  Weapon skins            1.0         drag1c            unknown                          skins.amxx   running  
 [ 68] 67  VIP and SVIP            2.5.11      drag1c            unknown                          csgo_vip_sv  running  
 [ 69] 68  CS:GO Molotov           2.5.11      DynamicBits & O'  unknown                          csgo_moloto  running  
 [ 70] 69  Advanced Kill Assists   1.3c        Xelson                                             kill_assist  running  
 [ 71] 70  Custom Smoke            1.07        bionext                                            custom_smok  running  
 [ 72] 71  Snow WarmUp             0.3         bizon             unknown                          reapi_snow_  running  
 [ 73] 72  Quick Defuse Bomb       0.0.2       Albertio          unknown                          quick_defus  running  
 [ 74] 73  Style C4 Timer          3.1         OciXCrom          unknown                          crx_c4timer  running  
 [ 75] 74  Discord Connect         1.0         drag1c            unknown                          discord.amx  running  
 [ 76] 75  Advanced Experience Sy  0.5.9 [REA  serfreeman1337/s  unknown                          aes_main.am  running  
 [ 77] 76  AES: CStrike Addon      0.5.9 [REA  serfreeman1337/s  unknown                          aes_exp_cst  running  
 [ 78] 77  AES: Informer           0.5.9 [REA  serfreeman1337/s  unknown                          aes_informe  running  
 [ 79] 78  AES: Admin Tools        0.5.9 [REA  serfreeman1337/s  unknown                          aes_exp_edi  running  
 [ 80] 79  AES: Bonus System       0.5.9 Vega  serfreeman1337/s  unknown                          aes_bonus_s  running  
 [ 81] 80  AES: Bonus CSTRIKE      0.5.9.1 [R  serfreeman1337/s  unknown                          aes_bonus_c  running  
 [ 82] 81  AES: Status Info        0.1         serfreeman1337    unknown                          aes_status_  running  
 [ 83] 82  Revive Teammates: Core  0.11.0      ufame & Albertio  unknown                          rt_core.amx  running  
 [ 84] 83  Revive Teammates: Plan  0.11.0      ufame & Albertio  unknown                          rt_planting  running  
 [ 85] 84  Revive Teammates: Rest  0.11.0      ufame & Albertio  unknown                          rt_restrict  running  
 [ 86] 85  Revive Teammates: Time  0.11.0      ufame & Albertio  unknown                          rt_timer.am  running  
 [ 87] 86  Revive Teammates: Effe  0.11.0      ufame & Albertio  unknown                          rt_effects.  running  
 [ 88] 87  Revive Teammates: Soun  0.11.0      ufame & Albertio  unknown                          rt_sounds.a  running  
 [ 89] 88  Revive Teammates: Bonu  0.11.0      ufame & Albertio  unknown                          rt_bonus.am  running  
(  4) Load fails: Module/Library Class "xstats" required for plugin.  Check modules.ini. 'going to be fixed in next map 
89 plugins, 88 running
C++
Автор плагина
OciXCrom
Версия плагина
3.1
Исходный код
#include <amxmodx>
#include <amxmisc>
#include <engine>

#if AMXX_VERSION_NUM < 183 || !defined set_dhudmessage
	#tryinclude <dhudmessage>

	#if !defined _dhudmessage_included
		#error "dhudmessage.inc" is missing in your "scripting/include" folder. Download it from: "https://amxx-bg.info/inc/"
	#endif
#endif

new const PLUGIN_VERSION[] = "3.1"
new const SYM_NEWLINE[] = "%n%"

#if !defined MAX_NAME_LENGTH
	const MAX_NAME_LENGTH = 32
#endif

const Float:TIMER_THINK   = 1.0
const MAX_POSITION_VALUES = 2
const MAX_RGB_VALUES      = 3
const MAX_STYLE_LENGTH    = 64
const MAX_TIMER_LENGTH    = 256
const MAX_FILENAME_LENGTH = 256

enum _:RGBColors
{
	RED,
	GREEN,
	BLUE
}

enum _:Sections
{
	SECTION_NONE,
	SECTION_SETTINGS,
	SECTION_STYLES
}

enum _:MessageTypes
{
	MSGTYPE_HUD,
	MSGTYPE_DHUD,
	MSGTYPE_CENTER
}

enum _:StyleModes
{
	STYLEMODE_MANUAL,
	STYLEMODE_CONSECUTIVE,
	STYLEMODE_RANDOM
}

enum _:ColorModes
{
	COLORMODE_ONE_COLOR,
	COLORMODE_COLOR_CYCLE,
	COLORMODE_RANDOM
}

enum _:Settings
{
	STYLE_MODE,
	TIMER_STYLE,
	COLOR_MODE,
	STARTING_COLOR[MAX_RGB_VALUES],
	Float:STARTING_POSITION[MAX_POSITION_VALUES],
	bool:ENABLE_POSITION_CYCLE,
	MESSAGE_TYPE,
	bool:OVERWRITE_ROUND_TIMER,
	TIMER_SYNC,
	START_MESSAGE_AT,
	START_VOICE_AT,
	VOICE_SPEAKER[MAX_NAME_LENGTH]
}

enum _:Styles
{
	Begin[MAX_STYLE_LENGTH],
	Add[MAX_STYLE_LENGTH],
	End[MAX_STYLE_LENGTH],
	ReplaceSymbol[MAX_STYLE_LENGTH],
	ReplaceWith[MAX_STYLE_LENGTH],
	bool:DoReplace
}

new g_eSettings[Settings]
new g_eTimer[Styles]
new g_szTimer[MAX_TIMER_LENGTH]

new Array:g_aStyles
new Array:g_aPositionCycle
new Trie:g_tColorCycle
new Float:g_fTimerPosition[MAX_POSITION_VALUES]
new bool:g_bPlanted
new bool:g_bRefreshColors

new g_iTimerColor[MAX_RGB_VALUES]
new g_iCurrentStyle
new g_iCurrentTimer
new g_iCurrentPosition
new g_iMessage
new g_iMaxStyles
new g_iMaxTimer
new g_iMaxPositions
new g_iTimerEntity
new g_iShowTimer
new g_iRoundTime
new g_pC4Timer

public plugin_init()
{
	register_plugin("Style C4 Timer", PLUGIN_VERSION, "OciXCrom")
	register_cvar("StyleC4Timer", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)

	g_iTimerEntity = create_entity("info_target")

	if(!g_iTimerEntity)
	{
		set_fail_state("Unable to create timer entity")
	}

	new const TIMER_ENTITY_NAME[] = "stylec4timer_entity"
	entity_set_string(g_iTimerEntity, EV_SZ_classname, TIMER_ENTITY_NAME)
	register_think(TIMER_ENTITY_NAME, "timer_display")

	register_event("HLTV", "timer_adjust", "a", "1=0", "2=0")
	register_logevent("timer_create", 3, "2=Planted_The_Bomb")
	register_logevent("timer_remove", 3, "2=Defused_The_Bomb")
	register_logevent("timer_remove", 6, "3=Target_Saved")
	register_logevent("timer_remove", 6, "3=Target_Bombed")
	register_logevent("timer_remove", 2, "1=Round_Start")
	register_logevent("timer_remove", 2, "1=Round_End")
	register_logevent("timer_remove", 2, "1&Restart_Round_")

	g_pC4Timer = get_cvar_pointer("mp_c4timer")
	g_aStyles = ArrayCreate(Styles)

	ReadFile()
}

public plugin_cfg()
{
	timer_adjust()
}

public plugin_end()
{
	ArrayDestroy(g_aStyles)

	if(g_eSettings[COLOR_MODE] == COLORMODE_COLOR_CYCLE)
	{
		TrieDestroy(g_tColorCycle)
	}

	if(g_eSettings[ENABLE_POSITION_CYCLE])
	{
		ArrayDestroy(g_aPositionCycle)
	}
}

ReadFile()
{
	new szFilename[MAX_FILENAME_LENGTH]
	get_configsdir(szFilename, charsmax(szFilename))
	add(szFilename, charsmax(szFilename), "/StyleC4Timer.ini")

	new iFilePointer = fopen(szFilename, "rt")

	if(iFilePointer)
	{
		new szData[MAX_FILENAME_LENGTH], szKey[MAX_NAME_LENGTH], szValue[MAX_FILENAME_LENGTH - MAX_NAME_LENGTH], szMap[MAX_NAME_LENGTH]
		new eStyle[Styles], bool:bRead = true, iSection = SECTION_NONE, szTemp[4][5], iSize, i
		get_mapname(szMap, charsmax(szMap))

		while(!feof(iFilePointer))
		{
			fgets(iFilePointer, szData, charsmax(szData))
			trim(szData)

			switch(szData[0])
			{
				case EOS, ';': continue
				case '-':
				{
					iSize = strlen(szData)

					if(szData[iSize - 1] == '-')
					{
						szData[0] = ' '
						szData[iSize - 1] = ' '
						trim(szData)

						if(contain(szData, "*") != -1)
						{
							strtok(szData, szKey, charsmax(szKey), szValue, charsmax(szValue), '*')
							copy(szValue, strlen(szKey), szMap)
							bRead = equal(szValue, szKey) != 0
						}
						else
						{
							static const szAll[] = "#all"
							bRead = equal(szData, szAll) || equali(szData, szMap)
						}
					}
					else continue
				}
				case '[':
				{
					iSize = strlen(szData)

					if(szData[iSize - 1] == ']')
					{
						switch(szData[2])
						{
							case 'E', 'e': iSection = SECTION_SETTINGS
							case 'T', 't': iSection = SECTION_STYLES
							default: iSection = SECTION_NONE
						}
					}
					else continue
				}
				case '{':
				{
					if(iSection == SECTION_STYLES)
					{
						g_iMaxStyles++
					}
				}
				case '}':
				{
					if(iSection == SECTION_STYLES)
					{
						eStyle[DoReplace] = eStyle[ReplaceWith][0] != 0
						ArrayPushArray(g_aStyles, eStyle)

						eStyle[Begin][0] = EOS
						eStyle[Add][0] = EOS
						eStyle[End][0] = EOS
						eStyle[ReplaceSymbol][0] = EOS
						eStyle[ReplaceWith][0] = EOS
					}
				}
				default:
				{
					if(!bRead)
					{
						continue
					}

					switch(iSection)
					{
						case SECTION_SETTINGS:
						{
							strtok(szData, szKey, charsmax(szKey), szValue, charsmax(szValue), '=')
							trim(szKey); trim(szValue)

							if(equal(szKey, "STYLE_MODE"))
							{
								g_eSettings[STYLE_MODE] = clamp(str_to_num(szValue), STYLEMODE_MANUAL, STYLEMODE_RANDOM)
							}
							else if(equal(szKey, "TIMER_STYLE"))
							{
								g_eSettings[TIMER_STYLE] = str_to_num(szValue)
							}
							else if(equal(szKey, "COLOR_MODE"))
							{
								g_eSettings[COLOR_MODE] = clamp(str_to_num(szValue), COLORMODE_ONE_COLOR, COLORMODE_RANDOM)

								if(g_eSettings[COLOR_MODE] == COLORMODE_COLOR_CYCLE)
								{
									g_tColorCycle = TrieCreate()
								}
							}
							else if(equal(szKey, "STARTING_COLOR"))
							{
								parse(szValue, szTemp[0], charsmax(szTemp[]), szTemp[1], charsmax(szTemp[]), szTemp[2], charsmax(szTemp[]))

								for(i = 0; i < MAX_RGB_VALUES; i++)
								{
									g_eSettings[STARTING_COLOR][i] = clamp(str_to_num(szTemp[i]), -1, 255)
								}
							}
							else if(equal(szKey, "COLOR_CYCLE"))
							{
								if(g_eSettings[COLOR_MODE] != COLORMODE_COLOR_CYCLE)
								{
									continue
								}

								while(szValue[0] != 0 && strtok(szValue, szKey, charsmax(szKey), szValue, charsmax(szValue), ','))
								{
									trim(szKey); trim(szValue)
									strtok(szKey, szTemp[0], charsmax(szTemp[]), szKey, charsmax(szKey), ' ')
									TrieSetString(g_tColorCycle, szTemp[0], szKey)
								}
							}
							else if(equal(szKey, "STARTING_POSITION"))
							{
								parse(szValue, szTemp[0], charsmax(szTemp[]), szTemp[1], charsmax(szTemp[]))

								for(i = 0; i < MAX_POSITION_VALUES; i++)
								{
									g_eSettings[STARTING_POSITION][i] = _:floatclamp(str_to_float(szTemp[i]), -1.0, 1.0)
								}
							}
							else if(equal(szKey, "ENABLE_POSITION_CYCLE"))
							{
								g_eSettings[ENABLE_POSITION_CYCLE] = _:clamp(str_to_num(szValue), false, true)

								if(g_eSettings[ENABLE_POSITION_CYCLE])
								{
									g_aPositionCycle = ArrayCreate(MAX_POSITION_VALUES)
								}
							}
							else if(equal(szKey, "POSITION_CYCLE"))
							{
								if(!g_eSettings[ENABLE_POSITION_CYCLE])
								{
									continue
								}

								static Float:fPosition[MAX_POSITION_VALUES]

								while(szValue[0] != 0 && strtok(szValue, szKey, charsmax(szKey), szValue, charsmax(szValue), ','))
								{
									trim(szKey); trim(szValue)
									parse(szKey, szTemp[0], charsmax(szTemp[]), szTemp[1], charsmax(szTemp[]))

									for(new i; i < MAX_POSITION_VALUES; i++)
									{
										fPosition[i] = str_to_float(szTemp[i])
									}

									g_iMaxPositions++
									ArrayPushArray(g_aPositionCycle, fPosition)
								}
							}
							else if(equal(szKey, "MESSAGE_TYPE"))
							{
								g_eSettings[MESSAGE_TYPE] = clamp(str_to_num(szValue), MSGTYPE_HUD, MSGTYPE_CENTER)

								if(g_eSettings[MESSAGE_TYPE] == MSGTYPE_HUD)
								{
									g_iMessage = CreateHudSyncObj()
								}
							}
							else if(equal(szKey, "OVERWRITE_ROUND_TIMER"))
							{
								g_eSettings[OVERWRITE_ROUND_TIMER] = _:clamp(str_to_num(szValue), false, true)

								if(g_eSettings[OVERWRITE_ROUND_TIMER])
								{
									g_iShowTimer = get_user_msgid("ShowTimer")
									g_iRoundTime = get_user_msgid("RoundTime")
								}
							}
							else if(equal(szKey, "TIMER_SYNC"))
							{
								g_eSettings[TIMER_SYNC] = str_to_num(szValue)
							}
							else if(equal(szKey, "START_MESSAGE_AT"))
							{
								g_eSettings[START_MESSAGE_AT] = str_to_num(szValue)
							}
							else if(equal(szKey, "START_VOICE_AT"))
							{
								g_eSettings[START_VOICE_AT] = str_to_num(szValue)
							}
							else if(equal(szKey, "VOICE_SPEAKER"))
							{
								copy(g_eSettings[VOICE_SPEAKER], charsmax(g_eSettings[VOICE_SPEAKER]), szValue)
							}
						}
						case SECTION_STYLES:
						{
							replace_all(szData, charsmax(szData), SYM_NEWLINE, "^n")
							strtok(szData, szKey, charsmax(szKey), szValue, charsmax(szValue), ':')
							trim(szKey); trim(szValue)
							remove_quotes(szValue)

							if(equali(szKey, "begin"))
							{
								copy(eStyle[Begin], charsmax(eStyle[Begin]), szValue)
							}
							else if(equali(szKey, "add"))
							{
								copy(eStyle[Add], charsmax(eStyle[Add]), szValue)
							}
							else if(equali(szKey, "end"))
							{
								copy(eStyle[End], charsmax(eStyle[End]), szValue)
							}
							else if(equali(szKey, "replace symbol"))
							{
								copy(eStyle[ReplaceSymbol], charsmax(eStyle[ReplaceSymbol]), szValue)
							}
							else if(equali(szKey, "replace with"))
							{
								copy(eStyle[ReplaceWith], charsmax(eStyle[ReplaceWith]), szValue)
							}
						}
					}
				}
			}
		}

		fclose(iFilePointer)

		if(!g_iMaxStyles)
		{
			set_fail_state("No styles found in the configuration file")
		}

		g_eSettings[TIMER_STYLE] = clamp(g_eSettings[TIMER_STYLE], 0, g_iMaxStyles - 1)

		if(g_eSettings[STYLE_MODE] == STYLEMODE_MANUAL)
		{
			ArrayGetArray(g_aStyles, g_eSettings[TIMER_STYLE], g_eTimer)
		}

		if(g_eSettings[MESSAGE_TYPE] != MSGTYPE_CENTER)
		{
			if(g_eSettings[COLOR_MODE] != COLORMODE_RANDOM)
			{
				timer_refresh_colors()

				if(g_eSettings[COLOR_MODE] == COLORMODE_COLOR_CYCLE)
				{
					g_bRefreshColors = true
				}
			}

			if(!g_eSettings[ENABLE_POSITION_CYCLE])
			{
				for(new i; i < MAX_POSITION_VALUES; i++)
				{
					g_fTimerPosition[i] = g_eSettings[STARTING_POSITION][i]
				}
			}
		}
	}
	else
	{
		set_fail_state("Unable to locate or open configuration file")
	}
}

public timer_adjust()
{
	g_iMaxTimer = get_pcvar_num(g_pC4Timer) + g_eSettings[TIMER_SYNC]
}

public timer_create()
{
	if(g_bPlanted)
	{
		return
	}

	g_bPlanted = true
	g_szTimer[0] = EOS
	g_iCurrentTimer = g_iMaxTimer

	switch(g_eSettings[STYLE_MODE])
	{
		case STYLEMODE_CONSECUTIVE:
		{
			ArrayGetArray(g_aStyles, g_iCurrentStyle++, g_eTimer)

			if(g_iCurrentStyle == g_iMaxStyles)
			{
				g_iCurrentStyle = 0
			}
		}
		case STYLEMODE_RANDOM:
		{
			ArrayGetArray(g_aStyles, random(g_iMaxStyles), g_eTimer)
		}
	}

	if(g_bRefreshColors)
	{
		timer_refresh_colors()
	}

	if(g_eTimer[DoReplace])
	{
		timer_add(g_eTimer[Begin])

		for(new i; i < g_iCurrentTimer; i++)
		{
			timer_add(g_eTimer[Add])
		}

		timer_add(g_eTimer[End])
	}
	else
	{
		formatex(g_szTimer, charsmax(g_szTimer), g_eTimer[Begin], g_iCurrentTimer)
	}

	timer_display(g_iTimerEntity)
}

timer_add(const szString[])
{
	add(g_szTimer, charsmax(g_szTimer), szString)
}

public timer_display(iEnt)
{
	if(g_bPlanted)
	{
		if(g_iCurrentTimer >= 0)
		{
			if(g_eSettings[START_MESSAGE_AT] && g_eSettings[START_MESSAGE_AT] < g_iCurrentTimer)
			{
				goto @AFTER_MESSAGE
			}

			if(g_eSettings[MESSAGE_TYPE] != MSGTYPE_CENTER)
			{
				switch(g_eSettings[COLOR_MODE])
				{
					case COLORMODE_COLOR_CYCLE:
					{
						new szTimer[5]
						num_to_str(g_iCurrentTimer, szTimer, charsmax(szTimer))

						if(TrieKeyExists(g_tColorCycle, szTimer))
						{
							new szColor[12], szRGB[MAX_RGB_VALUES][4]
							TrieGetString(g_tColorCycle, szTimer, szColor, charsmax(szColor))
							parse(szColor, szRGB[0], charsmax(szRGB[]), szRGB[1], charsmax(szRGB[]), szRGB[2], charsmax(szRGB[]))

							for(new i; i < MAX_RGB_VALUES; i++)
							{
								g_iTimerColor[i] = str_to_num(szRGB[i])
							}
						}
					}
					case COLORMODE_RANDOM:
					{
						for(new i; i < MAX_RGB_VALUES; i++)
						{
							g_iTimerColor[i] = random(256)
						}
					}
				}

				if(g_eSettings[ENABLE_POSITION_CYCLE])
				{
					ArrayGetArray(g_aPositionCycle, g_iCurrentPosition++, g_fTimerPosition)

					if(g_iCurrentPosition == g_iMaxPositions)
					{
						g_iCurrentPosition = 0
					}
				}
			}

			switch(g_eSettings[MESSAGE_TYPE])
			{
				case MSGTYPE_HUD:
				{
					set_hudmessage(g_iTimerColor[0], g_iTimerColor[1], g_iTimerColor[2], g_fTimerPosition[0], g_fTimerPosition[1], 0, 1.0, 1.0, 0.01, 0.01)
					ShowSyncHudMsg(0, g_iMessage, g_szTimer, g_iCurrentTimer)
				}
				case MSGTYPE_DHUD:
				{
					set_dhudmessage(g_iTimerColor[0], g_iTimerColor[1], g_iTimerColor[2], g_fTimerPosition[0], g_fTimerPosition[1], 0, 1.0, 1.0, 0.01, 0.01)
					show_dhudmessage(0, g_szTimer, g_iCurrentTimer)
				}
				case MSGTYPE_CENTER:
				{
					client_print(0, print_center, g_szTimer, g_iCurrentTimer)
				}
			}

			@AFTER_MESSAGE:

			if(0 < g_iCurrentTimer <= g_eSettings[START_VOICE_AT])
			{
				new szSpeaker[MAX_NAME_LENGTH]
				num_to_word(g_iCurrentTimer, szSpeaker, charsmax(szSpeaker))
				client_cmd(0, "spk ^"%s/%s.wav", g_eSettings[VOICE_SPEAKER], szSpeaker)
			}

			if(g_eSettings[OVERWRITE_ROUND_TIMER])
			{
				message_begin(MSG_ALL, g_iShowTimer)
				message_end()

				message_begin(MSG_ALL, g_iRoundTime)
				write_short(g_iCurrentTimer + 1)
				message_end()
			}

			g_iCurrentTimer--

			if(g_eTimer[DoReplace])
			{
				replace(g_szTimer, charsmax(g_szTimer), g_eTimer[ReplaceSymbol], g_eTimer[ReplaceWith])
			}
			else
			{
				formatex(g_szTimer, charsmax(g_szTimer), g_eTimer[Begin], g_iCurrentTimer)
			}

			entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + TIMER_THINK)
		}
	}
}

public timer_remove()
{
	if(g_bPlanted)
	{
		g_bPlanted = false
		g_iCurrentTimer = -1
	}
}

timer_refresh_colors()
{
	for(new i; i < MAX_RGB_VALUES; i++)
	{
		g_iTimerColor[i] = g_eSettings[STARTING_COLOR][i]
	}
}
C++
Plugin goes in two rows on HUD whichever resolution is taken. It is the same for all players.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу