Raised This Month: $39 Target: $400
 9% 

Separate plugin only for the Roundtimer fix after change map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 06-09-2022 , 02:06   Separate plugin only for the Roundtimer fix after change map
Reply With Quote #1

I want to extract the code for the fix that makes the roundtimer not disappear when changing map to a cs_ map if the bomb was still planted in a de_ map.
And make it a separate plugin.

Can anyone take this please?


Code:

HTML Code:
/**
 *
 * Grenade/C4 Fixes & Hud Enhancement
 *  by Numb
 *
 *
 * Description:
 *  This plugin is designed to fix variety of grenade and c4 related bugs, while introducing
 *  some amount of hud improvements and editions.
 *  Bomb Fixes:
 *   + When bomb is planted in water it will explode if not defused, instead of resulting in
 *    an infinite round.
 *   + Bomb cannot be moved by movable objects any longer.
 *   + Bomb cannot explode and be defused at the same time anymore.
 *   + Silent defuse by pressing use key twice, or using knife secondary attack, or
 *    activating flashlight is no longer possible.
 *   + Defuse cannot be started from air - log stays clean.
 *   + Bomb cannot squeeze itself through objects, to be planted outside the map.
 *   + "Counter-Terrorists win" sound doesn't overwrite "Bomb has been defused" one.
 *   + At new round reload isn't canceled if you have the bomb.
 *   + When dropped from large distance, bomb location on radar is accurate.
 *   + Secondary attack cancels the defuse.
 *  Grenade Fixes:
 *   + Grenades have reasonable velocities when breaking glass.
 *   + Flash grenades exploded underwater can blind players on land, and the opposed way
 *    around.
 *   + Underwater explosions have ability to damage players who are on land.
 *   + Grenades cannot squeeze themselves out of map.
 *  Other Fixes:
 *   + When disconnecting from a server where bomb was planted, and connecting into your
 *    non-bomb objective server, round timer is present anyway.
 *   + After playing a map with built-in echo system, echo glitch is fixed (however client
 *    must have s_eax set to 0 for it to work).
 *   + BarTime (loading bar) is canceled for spectators when planter or defuser dies.
 *   + BarTime (loading bar) is canceled when switching weapons during defuse or bomb plant.
 *  HUD Changes:
 *   + If bomb is planted, round timer shows seconds remaining until detonation.
 *   + Condition-Zero style c4 scenario icon near round timer when bomb is planted.
 *   + Silver defuse kit icon when bomb isn't planted, when planted - green.
 *   + Defuse kit icon is blinking in red and green when defusing without a kit.
 *   + Red defuse kit icon when defusing with a kit.
 *   + While planting the bomb, c4 icon is red.
 *   + Silver buyzone icon when buytime passed.
 *  Other Features:
 *   + Angle of planted bomb is the same as planter had when planting.
 *   + Flashbangs and he-grenades have a light effect when exploding.
 *
 *
 * Requires:
 *  FakeMeta
 *  HamSandWich
 *
 *
 * Additional info:
 *  Tested in Counter-Strike 1.6 with amxmodx 1.8.2 (dev build hg21). Should also work in
 *  Condition-Zero.
 *
 *
 * Credits:
 *  Special thanks to Arkshine ( http://forums.alliedmods.net/member.php?u=7779 ) for
 *  Counter-Strike SDK ( https://github.com/Arkshine/CSSDK/ ), and for providing other
 *  useful information! Thanks to xPaw ( http://forums.alliedmods.net/member.php?u=39377 )
 *  for method of fixing "bomb has been defused" sound as well - method taken from his
 *  "The bomb has been defused" ( http://forums.alliedmods.net/showthread.php?p=883102 )
 *  plugin. Also thanks to FOUTA ( http://forums.alliedmods.net/member.php?u=96050 )
 *  for providing help by testing the plugin on live public server.
 *
 *
 * Change-Log:
 *
 *  + 1.2
 *  - Fixed: Crash when stopping the defuse.
 *  - Fixed: Error log due to client message.
 *  - Fixed: Custom team switching will now remove defuser kit icon at player hud update.
 *  - Fixed: Freezetime was not added to buytime - grey buy icon earlier than it should be.
 *  - Added: Compatibility with mission scenario plugin. Basically just auto-changes the cvar.
 *
 *  + 1.1
 *  - Added: Secondary attack now cancels the defuse.
 *  - Added: BarTime (loading bar) is canceled when switching weapons during defuse or bomb plant.
 *  - Fixed: Pausing the plugin is now more friendly. 
 *
 *  + 1.0
 *  - First release.
 *
 *
 * Downloads:
 *  Amx Mod X forums: http://forums.alliedmods.net/showthread.php?p=1594580#post1594580
 *
**/

// ----------------------------------------- CONFIG START -----------------------------------------

// Light effect data for flashbangs
#define FLASH_RADIUS     50
#define FLASH_RED        255
#define FLASH_GREEN      255
#define FLASH_BLUE       255
#define FLASH_LIFE_MS    8
#define FLASH_DECAY_RATE 60

// Light effect data for he-grenades
#define HE_RADIUS     30
#define HE_RED        255
#define HE_GREEN      191
#define HE_BLUE       31
#define HE_LIFE_MS    12
#define HE_DECAY_RATE 20

// ------------------------------------------ CONFIG END ------------------------------------------


#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN_NAME	"Grenade/C4 Fixes & Hud Enhancement"
#define PLUGIN_VERSION	"1.2"
#define PLUGIN_AUTHOR	"Numb"

#define SetPlayerBit(%1,%2)    ( %1 |=  ( 1 << ( %2 & 31 ) ) )
#define ClearPlayerBit(%1,%2)  ( %1 &= ~( 1 << ( %2 & 31 ) ) )
#define CheckPlayerBit(%1,%2)  ( %1 &   ( 1 << ( %2 & 31 ) ) )

#define m_pPlayer 41
#define m_iId 43
#define m_flNextSecondaryAttack 47

#define m_fHasDefuseKit 193
#define HAS_DEFUSE_KIT (1<<16)
#define m_iTeam 114
#define CS_TEAM_UNASSIGNED 0
#define CS_TEAM_T 1
#define CS_TEAM_CT 2
#define CS_TEAM_SPECTATOR 3
#define m_fBombDefusing 232
#define BombStatus_BeingDefusing (1<<8)
#define m_iMapZone 235
#define CS_MAPZONE_BUY (1<<0)
#define CS_MAPZONE_BOMBTARGET (1<<1)
#define CS_MAPZONE_HOSTAGE_RESCUE (1<<2)
#define CS_MAPZONE_ESCAPE (1<<3)
#define CS_MAPZONE_VIP_SAFETY (1<<4)
#define m_pActiveItem 373
#define m_flProgressBarStartTime 605
#define m_flProgressBarEndTime 606

#define m_fBombStatus 96
#define BOMB_DEFUSING (1<<0) // m_fStartDefuse
#define BOMB_PLANTED (1<<8) // m_fPlantedC4
//#define m_hDefuser 97 // doesn't work - get_pdata_ent() doesn't return the expected value
#define m_flDefuseCountDown 99
#define m_flC4Blow 100
#define m_flNextBeep 102
#define m_flNextFreq 103
#define m_flNextBlink 106
#define m_flNextDefuseTime 107
#define m_bJustBlew 108
#define m_iC4Beep 110
#define m_usEvent 114

new g_iMsgId_StatusIcon;
new g_iMsgId_Scenario;
new g_iMsgId_SendAudio;
new g_iMsgId_BombDrop;
new g_iMsgId_BombPickup;
new g_iMsgId_ShowTimer;
new g_iMsgId_RoundTime;
new g_iMsgId_BarTime;
new g_iMsgId_TextMsg;

new bool:g_bIsCzero;
new bool:g_bPlanted;
new g_iMaxPlayers;

new Float:g_fOldSpeed;
new g_iIgnoreTimerFix;
new g_iConnected;
new g_iAlive;

new Float:g_fRoundStartedAt;
new Float:g_fFreezeTime;
new g_iCvar_buytime;
new g_iCvar_freezetime;
new g_iModifiedBuyZone;

new Float:g_fPlantedAt;
new g_iCvar_c4Timer;
new g_iCvar_MissionScenario
new g_iC4Timer;
new bool:g_bCheckTxtMsg;

new HamHook:g_hh_Think_grenade_Post;

new g_iBackupInfo[32][2];
new g_iBackupPlayerNum;

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
	
	register_logevent("LogEvent_Defused_The_Bomb", 3, "1=triggered", "2=Defused_The_Bomb");
	
	register_event("HLTV",      "Event_NewRound",  "a", "1=0", "2=0");
	register_event("ShowTimer", "Event_ShowTimer", "b");
	register_event("SendAudio", "Event_SendAudio", "a", "1=0", "2=%!MRAD_BOMBDEF");
	register_event("BombDrop",  "Event_BombPlant", "a", "4=1");
	register_event("ResetHUD",  "Event_ResetHUD",  "b");
	register_event("BarTime",   "Event_BarTime",   "b");
	register_event("BarTime2",  "Event_BarTime2",  "b");
	register_event("CurWeapon", "Event_CurWeapon", "be");
	
	g_iMsgId_SendAudio  = get_user_msgid("SendAudio");
	g_iMsgId_BombDrop   = get_user_msgid("BombDrop");
	g_iMsgId_BombPickup = get_user_msgid("BombPickup");
	g_iMsgId_StatusIcon = get_user_msgid("StatusIcon");
	g_iMsgId_BarTime    = get_user_msgid("BarTime");
	g_iMsgId_Scenario   = get_user_msgid("Scenario");
	g_iMsgId_ShowTimer  = get_user_msgid("ShowTimer");
	g_iMsgId_RoundTime  = get_user_msgid("RoundTime");
	g_iMsgId_TextMsg    = get_user_msgid("TextMsg");
	
	register_message(g_iMsgId_StatusIcon, "Message_StatusIcon");
	register_message(g_iMsgId_BombDrop,   "Message_BombDrop");
	register_message(g_iMsgId_RoundTime,  "Message_RoundTime");
	register_message(g_iMsgId_TextMsg,    "Message_TextMsg");
	
	set_task(0.5, "find_c4", 33, "", 0, "b");
	
	register_forward(FM_EmitSound, "FM_EmitSound_Pre", 0);
	register_forward(FM_SetModel,  "FM_SetModel_Pre",  0);
	
	new iGameMod[8];
	get_modname(iGameMod, 7);
	if( equali(iGameMod, "czero") )
		g_bIsCzero = true;
	
	RegisterHam(Ham_Spawn,                  "player",       "Ham_Spawn_player_Post",  1);
	RegisterHam(Ham_Killed,                 "player",       "Ham_Killed_player_Post", 1);
	RegisterHam(Ham_Spawn,                  "grenade",      "Ham_Spawn_grenade_Post", 1);
	RegisterHam(Ham_Use,                    "grenade",      "Ham_Use_grenade_Pre",    0);
	RegisterHam(Ham_Touch,                  "grenade",      "Ham_Touch_grenade_Pre",  0);
	RegisterHam(Ham_Touch,                  "grenade",      "Ham_Touch_grenade_Post", 1);
	RegisterHam(Ham_Think,                  "grenade",      "Ham_Think_grenade_Pre",  0);
	RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "Ham_Wpn_SecAttack_Post", 1);
	RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_awp",   "Ham_Wpn_SecAttack_Post", 1);
	RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_scout", "Ham_Wpn_SecAttack_Post", 1);
	RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_g3sg1", "Ham_Wpn_SecAttack_Post", 1);
	RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_sg550", "Ham_Wpn_SecAttack_Post", 1);
	RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_sg552", "Ham_Wpn_SecAttack_Post", 1);
	RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_aug",   "Ham_Wpn_SecAttack_Post", 1);
	
	g_hh_Think_grenade_Post = RegisterHam(Ham_Think, "grenade", "Ham_Think_grenade_Post", 1);
	DisableHamForward(g_hh_Think_grenade_Post);
	
	register_clcmd("say /hud", "Event_ResetHUD");
}

public plugin_cfg()
{
	if( !g_iCvar_MissionScenario )
		g_iCvar_MissionScenario = get_cvar_pointer("mp_mission_scenario");
}

public plugin_precache()
{
	g_iCvar_buytime = get_cvar_pointer("mp_buytime");
	g_iCvar_freezetime = get_cvar_pointer("mp_freezetime");
	g_iCvar_c4Timer = get_cvar_pointer("mp_c4timer");
	g_iC4Timer = clamp(get_pcvar_num(g_iCvar_c4Timer), 10, 90);
	
	g_iMaxPlayers = clamp(get_maxplayers(), 1, 32);
}

public plugin_pause()
{
	new iEnt, iPlayer;
	while( (iEnt=engfunc(EngFunc_FindEntityByString, iEnt, "classname", "grenade"))>0 )
	{
		if( pev_valid(iEnt) )
		{
			if( fm_cs_get_grenade_type(iEnt)==CSW_C4 && pev(iEnt, pev_movetype)!=MOVETYPE_NONE )
			{
				engfunc(EngFunc_SetSize, iEnt, Float:{-0.021, -0.021, -0.021}, Float:{0.021, 0.021, 0.021});
				set_pev(iEnt, pev_solid, SOLID_NOT);
				
				set_pev(iEnt, pev_effects, (pev(iEnt, pev_effects)&~EF_NODRAW));
				
				iPlayer = pev(iEnt, pev_owner);
				if( 0<iPlayer<=g_iMaxPlayers )
				{
					if( CheckPlayerBit(g_iConnected, iPlayer) )
					{
						new Float:fAngles[3], Float:fAngle;
						pev(iPlayer, pev_v_angle, fAngles);
						fAngle = (fAngles[1]+90.0);
						pev(iEnt, pev_angles, fAngles);
						fAngles[1] = fAngle;
						set_pev(iEnt, pev_angles, fAngles);
					}
				}
				
				g_iBackupPlayerNum = 0;
				for( iPlayer=1; iPlayer<=g_iMaxPlayers; iPlayer++ )
				{
					if( CheckPlayerBit(g_iConnected, iPlayer) )
					{
						g_iBackupInfo[g_iBackupPlayerNum][0] = iPlayer;
						g_iBackupInfo[g_iBackupPlayerNum][1] = pev(iPlayer, pev_solid);
						set_pev(iPlayer, pev_solid, SOLID_NOT);
						g_iBackupPlayerNum++;
					}
				}
				engfunc(EngFunc_DropToFloor, iEnt);
				for( iPlayer=0; iPlayer<g_iBackupPlayerNum; iPlayer++ )
					set_pev(g_iBackupInfo[iPlayer][0], pev_solid, g_iBackupInfo[iPlayer][1]);
				g_iBackupPlayerNum = 0;
				
				set_pev(iEnt, pev_movetype, MOVETYPE_NONE);
			}
		}
	}
	
	for( iPlayer=1; iPlayer<=g_iMaxPlayers; iPlayer++ )
	{
		if( CheckPlayerBit(g_iConnected, iPlayer) )
		{
			if( CheckPlayerBit(g_iAlive, iPlayer) )
			{
				iEnt = get_pdata_int(iPlayer, m_iMapZone, 5);
				if( iEnt&CS_MAPZONE_BUY && CheckPlayerBit(g_iModifiedBuyZone, iPlayer) )
				{
					message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlayer);
					write_byte(1);
					write_string("buyzone");
					write_byte(0);
					write_byte(160);
					write_byte(0);
					message_end();
				}
				
				switch( get_pdata_int(iPlayer, m_iTeam, 5) )
				{
					case CS_TEAM_T:
					{
						if( get_user_weapon(iPlayer)==CSW_C4 )
						{
							message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlayer);
							write_byte(((iEnt&CS_MAPZONE_BOMBTARGET)?2:1));
							write_string("c4");
							write_byte(0);
							write_byte(160);
							write_byte(0);
							message_end();
						}
					}
					case CS_TEAM_CT:
					{
						if( get_pdata_int(iPlayer, m_fHasDefuseKit, 5)&HAS_DEFUSE_KIT )
						{
							message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlayer);
							write_byte(1);
							write_string("defuser");
							write_byte(0);
							write_byte(160);
							write_byte(0);
							message_end();
						}
						else
						{
							message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlayer);
							write_byte(0);
							write_string("defuser");
							//write_byte(0);
							//write_byte(0);
							//write_byte(0);
							message_end();
						}
					}
				}
			}
			else if( pev(iPlayer, pev_iuser1)==4 )
			{
				if( 0<(iEnt=pev(iPlayer, pev_iuser2))<=g_iMaxPlayers )
				{
					if( CheckPlayerBit(g_iAlive, iEnt) )
					{
						switch( get_pdata_int(iEnt, m_iTeam, 5) )
						{
							case CS_TEAM_T:
							{
								if( get_user_weapon(iEnt)==CSW_C4 )
								{
									message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlayer);
									write_byte(((get_pdata_int(iEnt, m_iMapZone, 5)&CS_MAPZONE_BOMBTARGET)?2:1));
									write_string("c4");
									write_byte(0);
									write_byte(160);
									write_byte(0);
									message_end();
								}
							}
							case CS_TEAM_CT:
							{
								if( get_pdata_int(iEnt, m_fHasDefuseKit, 5)&HAS_DEFUSE_KIT )
								{
									message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlayer);
									write_byte(1);
									write_string("defuser");
									write_byte(0);
									write_byte(160);
									write_byte(0);
									message_end();
								}
								else
								{
									message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlayer);
									write_byte(0);
									write_string("defuser");
									//write_byte(0);
									//write_byte(0);
									//write_byte(0);
									message_end();
								}
							}
						}
					}
				}
			}
		}
	}
}

public plugin_unpause()
{
	g_iIgnoreTimerFix = 0;
	g_iConnected = 0;
	g_iAlive = 0;
	
	new iPlayers[32], iPlayerNum;
	get_players(iPlayers, iPlayerNum);
	
	for( new iPlayer; iPlayer<iPlayerNum; iPlayer++ )
	{
		SetPlayerBit(g_iConnected, iPlayers[iPlayer]);
		
		if( is_user_alive(iPlayers[iPlayer]) )
			SetPlayerBit(g_iAlive, iPlayers[iPlayer]);
	}
	
	DisableHamForward(g_hh_Think_grenade_Post);
	g_bCheckTxtMsg = false;
	
	new iEnt;
	while( (iEnt=engfunc(EngFunc_FindEntityByString, iEnt, "classname", "grenade"))>0 )
	{
		if( pev_valid(iEnt) )
		{
			if( fm_cs_get_grenade_type(iEnt)==CSW_C4 )
			{
				g_bPlanted = true;
				
				if( !get_pdata_int(iEnt, m_bJustBlew, 5) )
				{
					message_begin(MSG_ALL, g_iMsgId_Scenario);
					write_byte(1);
					write_string("bombticking");
					write_byte(255);
					switch( clamp((get_pdata_int(iEnt, m_iC4Beep, 5)-1), 0, 4) )
					{
						case 0: write_short(140);
						case 1: write_short(70);
						case 2: write_short(40);
						case 3: write_short(30);
						default: write_short(20);
					}
					write_short(0);
					message_end();
				}
				
				g_fPlantedAt = get_gametime();
				g_iC4Timer = (floatround(get_pdata_float(iEnt, m_flC4Blow, 5)-g_fPlantedAt));
				
				if( g_iC4Timer<0 )
					g_iC4Timer = 0;
				
				message_begin(MSG_ALL, g_iMsgId_ShowTimer);
				message_end();
				
				message_begin(MSG_ALL, g_iMsgId_RoundTime);
				if( g_iC4Timer>0 )
					write_short(g_iC4Timer);
				else
					write_short(1);
				message_end();
				
				break;
			}
		}
	}
	if( iEnt<=0 )
	{
		g_bPlanted = false;
		g_iC4Timer = clamp(get_pcvar_num(g_iCvar_c4Timer), 10, 90);
	}
	
	g_iBackupPlayerNum = 0;
	g_fRoundStartedAt = -1.0;
	g_iModifiedBuyZone = 0;
}

public client_connect(iPlrId)
{
	ClearPlayerBit(g_iIgnoreTimerFix, iPlrId);
	ClearPlayerBit(g_iConnected, iPlrId);
	ClearPlayerBit(g_iAlive, iPlrId);
	ClearPlayerBit(g_iModifiedBuyZone, iPlrId);
	
	client_cmd(iPlrId, "room_type 0"); // note: this fix works only if client had s_eax 0 when game was launched
}

public client_putinserver(iPlrId)
{
	ClearPlayerBit(g_iIgnoreTimerFix, iPlrId);
	SetPlayerBit(g_iConnected, iPlrId);
	ClearPlayerBit(g_iModifiedBuyZone, iPlrId);
		
	if( g_bPlanted )
	{
		new iTimerLeft = (g_iC4Timer-floatround((get_gametime()-g_fPlantedAt)));
		
		if( iTimerLeft<1 )
			iTimerLeft = 1;
		
		message_begin(MSG_ONE, g_iMsgId_ShowTimer, _, iPlrId);
		message_end();
		
		message_begin(MSG_ONE, g_iMsgId_RoundTime, _, iPlrId);
		write_short(iTimerLeft);
		message_end();
	}
}

public client_disconnect(iPlrId)
{
	ClearPlayerBit(g_iIgnoreTimerFix, iPlrId);
	ClearPlayerBit(g_iConnected, iPlrId);
	ClearPlayerBit(g_iAlive, iPlrId);
	ClearPlayerBit(g_iModifiedBuyZone, iPlrId);
}

public LogEvent_Defused_The_Bomb()
{
	new iArg[64], iName[32];
	read_logargv(0, iArg, 63);
	parse_loguser(iArg, iName, 31);
	new iDefuser = find_player("a", iName);
	
	if( 0<iDefuser<=g_iMaxPlayers )
	{
		if( CheckPlayerBit(g_iAlive, iDefuser) )
		{
			new bool:bHasKit = ((get_pdata_int(iDefuser, m_fHasDefuseKit, 5)&HAS_DEFUSE_KIT)?true:false);
			
			for( new iPlrId=1; iPlrId<=g_iMaxPlayers; iPlrId++ )
			{
				if( CheckPlayerBit(g_iConnected, iPlrId) )
				{
					if( (iDefuser==iPlrId) || (!CheckPlayerBit(g_iAlive, iPlrId) && pev(iPlrId, pev_iuser1)==4 && pev(iPlrId, pev_iuser2)==iDefuser) )
					{
						if( bHasKit )
						{
							message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
							write_byte(1);
							write_string("defuser");
							write_byte(0);
							write_byte(160);
							write_byte(0);
							message_end();
						}
						else
						{
							message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
							write_byte(0);
							write_string("defuser");
							//write_byte(0);
							//write_byte(0);
							//write_byte(0);
							message_end();
						}
					}
				}
			}
		}
	}
}

public Event_NewRound()
{
	g_fFreezeTime = floatclamp(get_pcvar_float(g_iCvar_freezetime), 0.0, 30.0);
	
	if( g_iCvar_MissionScenario )
	{
		new iMissionScenarioCvarNum = clamp(get_pcvar_num(g_iCvar_MissionScenario), 0, 3);
		if( iMissionScenarioCvarNum>1 && iMissionScenarioCvarNum!=2 )
			set_pcvar_num(g_iCvar_MissionScenario, 2);
	}
	
	new iEnt, iUserWeapons;
	
	for( new iPlrId=1; iPlrId<g_iMaxPlayers; iPlrId++ )
	{
		if( CheckPlayerBit(g_iAlive, iPlrId) )
		{
			if( (iUserWeapons=pev(iPlrId, pev_weapons))&(1<<CSW_C4) && get_user_weapon(iPlrId)!=CSW_C4 )
			{
				iEnt = 0;
				while( (iEnt=engfunc(EngFunc_FindEntityByString, iEnt, "classname", "weapon_c4"))>0 )
				{
					if( pev_valid(iEnt) )
					{
						if( pev(iEnt, pev_owner)==iPlrId && get_pdata_cbase(iEnt, m_pPlayer, 4)==iPlrId )
							break;
					}
				}
				if( iEnt<=g_iMaxPlayers )
					continue;
				
				if( !ExecuteHamB(Ham_RemovePlayerItem, iPlrId, iEnt) )
					continue;
				
				ExecuteHamB(Ham_Item_Kill, iEnt);
				
				set_pev(iPlrId, pev_weapons, (iUserWeapons&~(1<<CSW_C4)));
			}
		}
	}
	
	g_iC4Timer = clamp(get_pcvar_num(g_iCvar_c4Timer), 10, 90);
	g_bPlanted = false;
	g_fRoundStartedAt = get_gametime();
	g_iModifiedBuyZone = 0;
	
	remove_task(33);
	set_task(0.5, "find_c4", 33, "", 0, "b");
}

public Event_ShowTimer(iPlrId)
	SetPlayerBit(g_iIgnoreTimerFix, iPlrId);

public Event_SendAudio()
{
	if( get_msg_block(g_iMsgId_SendAudio)==BLOCK_NOT )
		set_msg_block(g_iMsgId_SendAudio, BLOCK_ONCE);
	
	g_fPlantedAt = (get_gametime()-float(g_iC4Timer));
	
	message_begin(MSG_ALL, g_iMsgId_ShowTimer);
	message_end();
	
	message_begin(MSG_ALL, g_iMsgId_RoundTime);
	write_short(1);
	message_end();
}

public Event_BombPlant()
{
	if( g_bPlanted )
	{
		message_begin(MSG_ALL, g_iMsgId_ShowTimer);
		message_end();
		
		message_begin(MSG_ALL, g_iMsgId_RoundTime);
		if( g_iC4Timer>0 )
			write_short(g_iC4Timer);
		else
			write_short(1);
		message_end();
	}
}

public Event_ResetHUD(iPlrId)
{
	if( g_bPlanted )
	{
		new iTimerLeft = (g_iC4Timer-floatround((get_gametime()-g_fPlantedAt)));
		
		if( iTimerLeft<1 )
			iTimerLeft = 1;
		
		message_begin(MSG_ONE, g_iMsgId_ShowTimer, _, iPlrId);
		message_end();
		
		message_begin(MSG_ONE, g_iMsgId_RoundTime, _, iPlrId);
		write_short(iTimerLeft);
		message_end();
	}
	
	if( get_pdata_int(iPlrId, m_iTeam, 5)==CS_TEAM_T )
	{
		static s_iKitInfo;
		s_iKitInfo = get_pdata_int(iPlrId, m_fHasDefuseKit, 5);
		if( s_iKitInfo&HAS_DEFUSE_KIT )
		{
			set_pdata_int(iPlrId, m_fHasDefuseKit, (s_iKitInfo&~HAS_DEFUSE_KIT), 5);
			
			message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
			write_byte(0);
			write_string("defuser");
			message_end();
		}
	}
}

public Event_BarTime(iPlrId)
{
	if( CheckPlayerBit(g_iAlive, iPlrId) )
	{
		switch( read_data(1) )
		{
			case 10: write_statusicon(iPlrId, 2, "defuser", 0, 160, 0);
			case 5: write_statusicon(iPlrId, 1, "defuser", 255, 0, 0);
			case 3: write_statusicon(iPlrId, 1, "c4", 255, 0, 0);
			case 0:
			{
				switch( get_pdata_int(iPlrId, m_iTeam, 5) )
				{
					case CS_TEAM_T:
					{
						if( pev(iPlrId, pev_weapons)&(1<<CSW_C4) )
						{
							if( g_bPlanted )
								write_statusicon(iPlrId, ((get_pdata_int(iPlrId, m_iMapZone, 5)&CS_MAPZONE_BOMBTARGET)?2:1), "c4", 160, 160, 160, true);
							else
								write_statusicon(iPlrId, ((get_pdata_int(iPlrId, m_iMapZone, 5)&CS_MAPZONE_BOMBTARGET)?2:1), "c4", 0, 160, 0, true);
						}
						else
							write_statusicon(iPlrId, -1, "", 0, 0, 0, true);
					}
					case CS_TEAM_CT:
					{
						if( get_pdata_int(iPlrId, m_fHasDefuseKit, 5)&HAS_DEFUSE_KIT )
							write_statusicon(iPlrId, 1, "defuser", 0, 160, 0, true);
						else
							write_statusicon(iPlrId, 0, "defuser", 0, 0, 0, true);
					}
				}
			}
		}
	}
	else if( !read_data(1) )
	{
		if( pev(iPlrId, pev_iuser1)==4 )
		{
			static s_iSpectated;
			if( 0<(s_iSpectated=pev(iPlrId, pev_iuser2))<=g_iMaxPlayers )
			{
				if( CheckPlayerBit(g_iAlive, s_iSpectated) )
				{
					switch( get_pdata_int(s_iSpectated, m_iTeam, 5) )
					{
						case CS_TEAM_T:
						{
							message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
							write_byte(0);
							write_string("defuser");
							//write_byte(0);
							//write_byte(0);
							//write_byte(0);
							message_end();
							
							if( pev(s_iSpectated, pev_weapons)&(1<<CSW_C4) )
							{
								message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
								write_byte(((get_pdata_int(s_iSpectated, m_iMapZone, 5)&CS_MAPZONE_BOMBTARGET)?2:1));
								write_string("c4");
								if( g_bPlanted )
								{
									write_byte(160);
									write_byte(160);
									write_byte(160);
								}
								else
								{
									write_byte(0);
									write_byte(160);
									write_byte(0);
								}
								message_end();
							}
							else
							{
								message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
								write_byte(0);
								write_string("c4");
								//write_byte(0);
								//write_byte(0);
								//write_byte(0);
								message_end();
							}
						}
						case CS_TEAM_CT:
						{
							message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
							write_byte(0);
							write_string("c4");
							//write_byte(0);
							//write_byte(0);
							//write_byte(0);
							message_end();
							
							if( get_pdata_int(s_iSpectated, m_fHasDefuseKit, 5)&HAS_DEFUSE_KIT )
							{
								message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
								write_byte(1);
								write_string("defuser");
								if( g_bPlanted )
								{
									write_byte(0);
									write_byte(160);
									write_byte(0);
								}
								else
								{
									write_byte(160);
									write_byte(160);
									write_byte(160);
								}
								message_end();
							}
							else
							{
								message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
								write_byte(0);
								write_string("defuser");
								//write_byte(0);
								//write_byte(0);
								//write_byte(0);
								message_end();
							}
						}
						default:
						{
							message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
							write_byte(0);
							write_string("defuser");
							//write_byte(0);
							//write_byte(0);
							//write_byte(0);
							message_end();
							
							message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
							write_byte(0);
							write_string("c4");
							//write_byte(0);
							//write_byte(0);
							//write_byte(0);
							message_end();
						}
					}
					return;
				}
			}
		}
		
		message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
		write_byte(0);
		write_string("defuser");
		message_end();
		
		message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
		write_byte(0);
		write_string("c4");
		message_end();
	}
}

public Event_BarTime2(iPlrId)
{
	if( !CheckPlayerBit(g_iAlive, iPlrId) )
	{
		if( pev(iPlrId, pev_iuser1)==4 )
		{
			static s_iSpectated;
			if( 0<(s_iSpectated=pev(iPlrId, pev_iuser2))<=g_iMaxPlayers )
			{
				if( CheckPlayerBit(g_iAlive, s_iSpectated) )
				{
					switch( get_pdata_int(s_iSpectated, m_iTeam, 5) )
					{
						case CS_TEAM_T:
						{
							if( pev(s_iSpectated, pev_weapons)&(1<<CSW_C4) && get_pdata_int(s_iSpectated, m_iMapZone, 5)&CS_MAPZONE_BOMBTARGET )
							{
								message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
								write_byte(1);
								write_string("c4");
								write_byte(255);
								write_byte(0);
								write_byte(0);
								message_end();
							}
						}
						case CS_TEAM_CT:
						{
							if( get_pdata_int(s_iSpectated, m_fHasDefuseKit, 5)&HAS_DEFUSE_KIT )
							{
								message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
								write_byte(1);
								write_string("defuser");
								write_byte(255);
								write_byte(0);
								write_byte(0);
								message_end();
							}
							else
							{
								message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
								write_byte(2);
								write_string("defuser");
								write_byte(0);
								write_byte(160);
								write_byte(0);
								message_end();
							}
						}
					}
				}
			}
		}
	}
}

public Event_CurWeapon(iPlrId)
{
	static Float:s_fGameTime;
	s_fGameTime = get_gametime();
	
	if( get_pdata_float(iPlrId, m_flProgressBarEndTime, 5)>s_fGameTime )
	{
		switch( get_pdata_int(iPlrId, m_iTeam, 5) )
		{
			case CS_TEAM_T:
			{
				set_pdata_float(iPlrId, m_flProgressBarEndTime, s_fGameTime, 5);
				
				message_begin(MSG_ONE, g_iMsgId_BarTime, _, iPlrId);
				write_short(0);
				message_end();
				
				if( pev(iPlrId, pev_weapons)&(1<<CSW_C4) )
				{
					if( g_bPlanted )
						write_statusicon(iPlrId, ((get_pdata_int(iPlrId, m_iMapZone, 5)&CS_MAPZONE_BOMBTARGET)?2:1), "c4", 160, 160, 160, true);
					else
						write_statusicon(iPlrId, ((get_pdata_int(iPlrId, m_iMapZone, 5)&CS_MAPZONE_BOMBTARGET)?2:1), "c4", 0, 160, 0, true);
				}
				else
					write_statusicon(iPlrId, -1, "", 0, 0, 0, true);
			}
			case CS_TEAM_CT:
			{
				// We don't need to disable the bar and reset defuser icon, cause we execute C4Think, and eventually it should execute Event_BarTime(), where I'm configurating everything anyway.
				//if( get_pdata_int(iPlrId, m_fHasDefuseKit, 5)&HAS_DEFUSE_KIT )
				//	write_statusicon(iPlrId, 1, "defuser", 0, 160, 0, true);
				//else
				//	write_statusicon(iPlrId, 0, "defuser", 0, 0, 0, true);
				
				if( g_bPlanted && get_pdata_int(iPlrId, m_fBombDefusing, 5)&BombStatus_BeingDefusing )
					cancel_defuse_now(iPlrId, (s_fGameTime+1.0));
			}
		}
		
		//set_pdata_float(iPlrId, m_flProgressBarEndTime, s_fGameTime, 5);
		
		//message_begin(MSG_ONE, g_iMsgId_BarTime, _, iPlrId);
		//write_short(0);
		//message_end();
	}
}

public Message_StatusIcon(iMsgId, iMsgType, iPlrId)
{
	if( CheckPlayerBit(g_iAlive, iPlrId) )
	{
		static s_iSprite[9];
		get_msg_arg_string(2, s_iSprite, 8);
		
		if( equal(s_iSprite, "buyzone") ) 
		{
			if( !get_msg_arg_int(1) )
				ClearPlayerBit(g_iModifiedBuyZone, iPlrId);
			else if( g_fRoundStartedAt>=0.0 )
			{
				static Float:s_fBuyTime;
				s_fBuyTime = (get_pcvar_float(g_iCvar_buytime)*60.0);
				if( s_fBuyTime<15.0 )
					s_fBuyTime = 15.0;
				s_fBuyTime += g_fFreezeTime;
				
				if( (get_gametime()-g_fRoundStartedAt)>s_fBuyTime )
				{
					SetPlayerBit(g_iModifiedBuyZone, iPlrId);
					set_msg_arg_int(3, ARG_BYTE, 160);
					set_msg_arg_int(4, ARG_BYTE, 160);
					set_msg_arg_int(5, ARG_BYTE, 160);
				}
				else
					ClearPlayerBit(g_iModifiedBuyZone, iPlrId);
			}
			
		}
		else if( get_msg_arg_int(1) )
		{
			if( g_bPlanted )
			{
				if( equal(s_iSprite, "c4") )
				{
					set_msg_arg_int(1, ARG_BYTE, 1);
					set_msg_arg_int(3, ARG_BYTE, 160);
					set_msg_arg_int(4, ARG_BYTE, 160);
					set_msg_arg_int(5, ARG_BYTE, 160);
				}
			}
			else if( equal(s_iSprite, "defuser") )
			{
				set_msg_arg_int(3, ARG_BYTE, 160);
				set_msg_arg_int(4, ARG_BYTE, 160);
				set_msg_arg_int(5, ARG_BYTE, 160);
			}
		}
	}
	else if( pev(iPlrId, pev_iuser1)==4 )
	{
		static s_iSpectated;
		if( 0<(s_iSpectated=pev(iPlrId, pev_iuser2))<=g_iMaxPlayers )
		{
			if( CheckPlayerBit(g_iAlive, s_iSpectated) )
			{
				static s_iSprite[9];
				get_msg_arg_string(2, s_iSprite, 8);
				
				if( g_bPlanted )
				{
					if( equal(s_iSprite, "c4") )
					{
						if( get_msg_arg_int(1) )
						{
							set_msg_arg_int(1, ARG_BYTE, 1);
							set_msg_arg_int(3, ARG_BYTE, 160);
							set_msg_arg_int(4, ARG_BYTE, 160);
							set_msg_arg_int(5, ARG_BYTE, 160);
						}
					}
					else if( equal(s_iSprite, "defuser") )
					{
						switch( get_msg_arg_int(1) )
						{
							case 1:
							{
								if( get_pdata_int(s_iSpectated, m_fBombDefusing, 5)&BombStatus_BeingDefusing )
								{
									set_msg_arg_int(3, ARG_BYTE, 255);
									set_msg_arg_int(4, ARG_BYTE, 0);
									set_msg_arg_int(5, ARG_BYTE, 0);
								}
							}
							case 0:
							{
								if( get_pdata_int(s_iSpectated, m_fBombDefusing, 5)&BombStatus_BeingDefusing )
								{
									//set_msg_arg_int(1, ARG_BYTE, 2);
									//set_msg_arg_int(3, ARG_BYTE, 0); // it appears that color code isn't sent when status is 0
									//set_msg_arg_int(4, ARG_BYTE, 160);
									//set_msg_arg_int(5, ARG_BYTE, 0);
									
									message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
									write_byte(2);
									write_string("defuser");
									write_byte(0);
									write_byte(160);
									write_byte(0);
									message_end();
									
									return PLUGIN_HANDLED;
								}
							}
						}
					}
				}
				else if( equal(s_iSprite, "defuser") )
				{
					if( get_msg_arg_int(1) )
					{
						set_msg_arg_int(3, ARG_BYTE, 160);
						set_msg_arg_int(4, ARG_BYTE, 160);
						set_msg_arg_int(5, ARG_BYTE, 160);
					}
				}
				else if( equal(s_iSprite, "c4") )
				{
					if( get_msg_arg_int(1)==2 )
					{
						static Float:s_fGameTime;
						s_fGameTime = get_gametime();
						
						if( s_fGameTime<get_pdata_float(s_iSpectated, m_flProgressBarEndTime, 5) )
						{
							if( pev(s_iSpectated, pev_weapons)&(1<<CSW_C4) && get_user_weapon(s_iSpectated)==CSW_C4 )
							{
								set_msg_arg_int(1, ARG_BYTE, 1);
								set_msg_arg_int(3, ARG_BYTE, 255);
								set_msg_arg_int(4, ARG_BYTE, 0);
								set_msg_arg_int(5, ARG_BYTE, 0);
							}
						}
					}
				}
			}
		}
	}
	
	return PLUGIN_CONTINUE;
}

public Message_BombDrop(iMsgId, iMsgType, iPlrId)
{
	if( get_msg_arg_int(4) )
	{
		message_begin(MSG_ALL, g_iMsgId_BombPickup, _, _)
		message_end();
		
		if( !g_bPlanted )
		{
			g_bPlanted = true;
			g_fPlantedAt = get_gametime();
			
			new iSpectated;
			for( new iPlrId=1; iPlrId<=g_iMaxPlayers; iPlrId++ )
			{
				if( CheckPlayerBit(g_iConnected, iPlrId) )
				{
					if( CheckPlayerBit(g_iAlive, iPlrId) )
						check_status_icon_at_planted(iPlrId, iPlrId);
					else
					{
						if( pev(iPlrId, pev_iuser1)==4 )
						{
							if( 0<(iSpectated=pev(iPlrId, pev_iuser2))<=g_iMaxPlayers )
							{
								if( CheckPlayerBit(g_iAlive, iSpectated) )
									check_status_icon_at_planted(iSpectated, iPlrId);
							}
						}
					}
				}
			}
		}
	}
	else if( g_bPlanted )
		return PLUGIN_HANDLED;
	
	return PLUGIN_CONTINUE;
}

public Message_RoundTime(iMsgId, iMsgType, iPlrId)
{
	if( g_bPlanted )
	{
		SetPlayerBit(g_iIgnoreTimerFix, iPlrId);
		message_begin(iMsgType, g_iMsgId_ShowTimer, _, iPlrId);
		message_end();
		
		new iTimerLeft = (g_iC4Timer-floatround((get_gametime()-g_fPlantedAt)));
		
		if( iTimerLeft<1 )
			iTimerLeft = 1;
		
		set_msg_arg_int(1, ARG_SHORT, iTimerLeft);
	}
	else
	{
		if( get_msg_arg_int(1)<=0 )
			set_msg_arg_int(1, ARG_SHORT, 1);
		
		if( !CheckPlayerBit(g_iIgnoreTimerFix, iPlrId) )
		{
			SetPlayerBit(g_iIgnoreTimerFix, iPlrId);
			message_begin(iMsgType, g_iMsgId_ShowTimer, _, iPlrId);
			message_end();
		}
	}
	
	return PLUGIN_CONTINUE;
}

public Message_TextMsg(iMsgId, iMsgType, iPlrId)
{
	if( g_bCheckTxtMsg )
	{
		if( iMsgType==MSG_ONE && get_msg_arg_int(1)==print_center )
		{
			g_iBackupPlayerNum *= -1;
			if( CheckPlayerBit(g_iBackupPlayerNum, iPlrId) )
			{
				new iText[32];
				get_msg_arg_string(2, iText, 31);
				
				if( equal(iText, "#C4_Defuse_Must_Be_On_Ground") )
				{
					set_pev(iPlrId, pev_flags, (pev(iPlrId, pev_flags)|FL_ONGROUND));
					
					ClearPlayerBit(g_iBackupPlayerNum, iPlrId);
					if( g_iBackupPlayerNum )
						g_iBackupPlayerNum *= -1;
					else
					{
						DisableHamForward(g_hh_Think_grenade_Post);
						g_bCheckTxtMsg = false;
					}
					
					return PLUGIN_HANDLED;
				}
			}
			g_iBackupPlayerNum *= -1;
		}
	}
	
	return PLUGIN_CONTINUE;
}

public FM_EmitSound_Pre(iEnt, iChannel, iSample[], Float:fVolume, Float:fAttenuation, iFlags, iPitch)
{
	if( g_bPlanted && iChannel==CHAN_ITEM && 0<iEnt<=g_iMaxPlayers )
	{
		if( CheckPlayerBit(g_iAlive, iEnt) )
		{
			if( equal(iSample, "weapons/c4_disarm.wav") )
				return FMRES_SUPERCEDE;
		}
		
		return FMRES_IGNORED;
	}
	
	static s_iClassName[9];
	pev(iEnt, pev_classname, s_iClassName, 8);
	if( s_iClassName[0]=='g' && s_iClassName[1]=='r' && s_iClassName[2]=='e' && s_iClassName[3]=='n' && s_iClassName[4]=='a' && s_iClassName[5]=='d' && s_iClassName[6]=='e' && !s_iClassName[7] )
	{
		switch( fm_cs_get_grenade_type(iEnt) )
		{
			case CSW_FLASHBANG:
			{
				if( equal(iSample, "weapons/flashbang-1.wav") || equal(iSample, "weapons/flashbang-2.wav") )
				{
					new Float:fOrigin[3];
					pev(iEnt, pev_origin, fOrigin);
					
					message_begin(MSG_ALL, SVC_TEMPENTITY);
					write_byte(TE_DLIGHT);
					engfunc(EngFunc_WriteCoord, fOrigin[0]);
					engfunc(EngFunc_WriteCoord, fOrigin[1]);
					engfunc(EngFunc_WriteCoord, fOrigin[2]);
					write_byte(FLASH_RADIUS);
					write_byte(FLASH_RED);
					write_byte(FLASH_GREEN);
					write_byte(FLASH_BLUE);
					write_byte(FLASH_LIFE_MS);
					write_byte(FLASH_DECAY_RATE);
					message_end();
				}
			}
			case CSW_HEGRENADE:
			{
				if( equal(iSample, "weapons/debris1.wav") || equal(iSample, "weapons/debris2.wav") || equal(iSample, "weapons/debris3.wav") )
				{
					new Float:fOrigin[3];
					pev(iEnt, pev_origin, fOrigin);
					
					message_begin(MSG_ALL, SVC_TEMPENTITY);
					write_byte(TE_DLIGHT);
					engfunc(EngFunc_WriteCoord, fOrigin[0]);
					engfunc(EngFunc_WriteCoord, fOrigin[1]);
					engfunc(EngFunc_WriteCoord, fOrigin[2]);
					write_byte(HE_RADIUS);
					write_byte(HE_RED);
					write_byte(HE_GREEN);
					write_byte(HE_BLUE);
					write_byte(HE_LIFE_MS);
					write_byte(HE_DECAY_RATE);
					message_end();
				}
			}
		}
	}
	
	return FMRES_IGNORED;
}

public FM_SetModel_Pre(iEnt, iModel[])
{
	if( equal(iModel, "models/w_c4.mdl") )
	{
		static s_iClassName[9];
		pev(iEnt, pev_classname, s_iClassName, 8);
		
		if( equal(s_iClassName, "grenade") )
			set_pev(iEnt, pev_effects, (pev(iEnt, pev_effects)|EF_NODRAW));
	}
}

public Ham_Spawn_player_Post(iPlrId)
{
	if( CheckPlayerBit(g_iConnected, iPlrId) )
	{
		if( is_user_alive(iPlrId) )
			SetPlayerBit(g_iAlive, iPlrId);
		else
			ClearPlayerBit(g_iAlive, iPlrId);
	}
	else
		ClearPlayerBit(g_iAlive, iPlrId);
}

public Ham_Killed_player_Post(iPlrId, iAttackerId, iShouldGib)
{
	if( CheckPlayerBit(g_iConnected, iPlrId) )
	{
		if( is_user_alive(iPlrId) )
			SetPlayerBit(g_iAlive, iPlrId);
		else
		{
			ClearPlayerBit(g_iAlive, iPlrId);
			ClearPlayerBit(g_iModifiedBuyZone, iPlrId);
		}
	}
	else
		ClearPlayerBit(g_iAlive, iPlrId);
	
	message_begin(MSG_ONE, g_iMsgId_BarTime, _, iPlrId);
	write_short(0);
	message_end();
	
	write_statusicon(iPlrId, 0, "defuser", 0, 0, 0, true);
}

public Ham_Spawn_grenade_Post(iEnt)
{
	if( pev_valid(iEnt) )
		engfunc(EngFunc_SetSize, iEnt, Float:{-0.021, -0.021, -0.021}, Float:{0.021, 0.021, 0.021});
}

public Ham_Use_grenade_Pre(iEnt, iCallerId, iActivatorId, iUseType, Float:fValue)
{
	static s_iBombStatus;
	s_iBombStatus = get_pdata_int(iEnt, m_fBombStatus, 5);
	
	if( (~s_iBombStatus&BOMB_PLANTED) || (s_iBombStatus&BOMB_DEFUSING) || get_pdata_int(iEnt, m_bJustBlew, 5) )
		return HAM_IGNORED;
	
	if( 0<iCallerId<=g_iMaxPlayers )
	{
		if( CheckPlayerBit(g_iAlive, iCallerId) )
		{
			if( get_pdata_int(iCallerId, m_iTeam, 5)==CS_TEAM_CT )
			{
				if( pev(iCallerId, pev_flags)&FL_ONGROUND )
				{
					if( is_user_in_secondary_attack(iCallerId, true) )
						return HAM_SUPERCEDE;
					
					emit_sound(iEnt, CHAN_WEAPON, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
				}
				else if( is_user_in_secondary_attack(iCallerId, true) )
					return HAM_SUPERCEDE;
				else
				{
					static Float:s_fGameTime;
					s_fGameTime = get_gametime();
					if( (get_pdata_float(iCallerId, m_flProgressBarEndTime, 5)+0.5)<s_fGameTime )
					{
						set_pdata_float(iCallerId, m_flProgressBarEndTime, s_fGameTime, 5);
						
						message_begin(MSG_ONE, g_iMsgId_TextMsg, _, iCallerId);
						write_byte(print_center);
						write_string("#C4_Defuse_Must_Be_On_Ground");
						message_end();
					}
					
					return HAM_SUPERCEDE;
				}
			}
		}
	}
	
	return HAM_IGNORED;
}

public Ham_Think_grenade_Pre(iEnt)
{
	switch( fm_cs_get_grenade_type(iEnt) )
	{
		case CSW_FLASHBANG: check_grenade_pre_explosion(iEnt);
		case CSW_HEGRENADE:
		{
			if( pev(iEnt, pev_waterlevel) )
				check_grenade_pre_explosion(iEnt);
		}
		case CSW_C4:
		{
			if( pev(iEnt, pev_movetype)!=MOVETYPE_NONE )
			{
				engfunc(EngFunc_SetSize, iEnt, Float:{-0.021, -0.021, -0.021}, Float:{0.021, 0.021, 0.021});
				set_pev(iEnt, pev_solid, SOLID_NOT);
				
				set_pev(iEnt, pev_effects, (pev(iEnt, pev_effects)&~EF_NODRAW));
				
				new iPlayer = pev(iEnt, pev_owner);
				if( 0<iPlayer<=g_iMaxPlayers )
				{
					if( CheckPlayerBit(g_iConnected, iPlayer) )
					{
						new Float:fAngles[3], Float:fAngle;
						pev(iPlayer, pev_v_angle, fAngles);
						fAngle = (fAngles[1]+90.0);
						pev(iEnt, pev_angles, fAngles);
						fAngles[1] = fAngle;
						set_pev(iEnt, pev_angles, fAngles);
					}
				}
				
				g_iBackupPlayerNum = 0;
				for( iPlayer=1; iPlayer<=g_iMaxPlayers; iPlayer++ )
				{
					if( CheckPlayerBit(g_iConnected, iPlayer) )
					{
						g_iBackupInfo[g_iBackupPlayerNum][0] = iPlayer;
						g_iBackupInfo[g_iBackupPlayerNum][1] = pev(iPlayer, pev_solid);
						set_pev(iPlayer, pev_solid, SOLID_NOT);
						g_iBackupPlayerNum++;
					}
				}
				engfunc(EngFunc_DropToFloor, iEnt);
				for( iPlayer=0; iPlayer<g_iBackupPlayerNum; iPlayer++ )
					set_pev(g_iBackupInfo[iPlayer][0], pev_solid, g_iBackupInfo[iPlayer][1]);
				g_iBackupPlayerNum = 0;
				
				set_pev(iEnt, pev_movetype, MOVETYPE_NONE);
			}
			
			static Float:s_fGameTime;
			s_fGameTime = get_gametime();
			if( get_pdata_float(iEnt, m_flC4Blow, 5)<=s_fGameTime )
			{
				if( pev(iEnt, pev_waterlevel) )
				{
					set_pev(iEnt, pev_waterlevel, 0);
					set_pev(iEnt, pev_flags, (pev(iEnt, pev_flags)|FL_INWATER));
				}
				else if( pev(iEnt, pev_flags)&FL_INWATER )
					grenade_pre_explosion();
				set_pdata_float(iEnt, m_flDefuseCountDown, (s_fGameTime+0.5), 5); // prevent defuse and explosion at the same time
			}
			else
			{
				if( !g_bIsCzero )
				{
					if( get_pdata_float(iEnt, m_flNextFreq, 5)<=s_fGameTime )
					{
						message_begin(MSG_ALL, g_iMsgId_Scenario);
						write_byte(1);
						write_string("bombticking");
						write_byte(255);
						switch( get_pdata_int(iEnt, m_iC4Beep, 5) )
						{
							case 0: write_short(140);
							case 1: write_short(70);
							case 2: write_short(40);
							case 3: write_short(30);
							default: write_short(20);
						}
						write_short(0);
						message_end();
					}
				}
				
				if( get_pdata_int(iEnt, m_fBombStatus, 5)&BOMB_DEFUSING )
				{
					/*static s_iDefuser;
					s_iDefuser = get_pdata_ent(iEnt, m_hDefuser, 5); // this doesn't work - get_pdata_ent() doesn't work for this
					
					if( 0<s_iDefuser<=g_iMaxPlayers )
					{
						if( CheckPlayerBit(g_iAlive, s_iDefuser) )
						{
							if( get_pdata_int(s_iDefuser, m_fBombDefusing, 5)&BombStatus_BeingDefusing && (get_pdata_float(s_iDefuser, m_flProgressBarStartTime, 5)+0.5)<=s_fGameTime && ~pev(s_iDefuser, pev_button)&IN_USE )
								set_pdata_float(iEnt, m_flNextDefuseTime, 1.0, 5);
						}
					}*/
					
					g_iBackupPlayerNum = 0;
					static s_iPlayer, s_iFlags;
					for( s_iPlayer=1; s_iPlayer<=g_iMaxPlayers; s_iPlayer++ )
					{
						if( CheckPlayerBit(g_iAlive, s_iPlayer) )
						{
							if( get_pdata_int(s_iPlayer, m_fBombDefusing, 5)&BombStatus_BeingDefusing
							 && (((get_pdata_float(s_iPlayer, m_flProgressBarStartTime, 5)+0.5)<=s_fGameTime
							 && ~pev(s_iPlayer, pev_button)&IN_USE) || is_user_in_secondary_attack(s_iPlayer)) )
							{
								if( (s_iFlags=pev(s_iPlayer, pev_flags))&FL_ONGROUND )
								{
									SetPlayerBit(g_iBackupPlayerNum, s_iPlayer);
									set_pev(s_iPlayer, pev_flags, (s_iFlags&~FL_ONGROUND));
								}
							}
						}
					}
					
					if( g_iBackupPlayerNum )
					{
						g_iBackupPlayerNum *= -1;
						g_bCheckTxtMsg = true;
						EnableHamForward(g_hh_Think_grenade_Post);
					}
				}
			}
		}
	}
}

public Ham_Think_grenade_Post(iEnt)
{
	if( g_iBackupPlayerNum>0 )
	{
		for( new iLoop; iLoop<g_iBackupPlayerNum; iLoop++ )
			set_pev(g_iBackupInfo[iLoop][0], pev_waterlevel, g_iBackupInfo[iLoop][1]);
	}
	else if( g_iBackupPlayerNum<0 )
	{
		g_iBackupPlayerNum *= -1;
		for( new iPlrId=1; iPlrId<=g_iMaxPlayers; iPlrId++ )
		{
			if( CheckPlayerBit(g_iBackupPlayerNum, iPlrId) && CheckPlayerBit(g_iAlive, iPlrId) )
				set_pev(iPlrId, pev_flags, (pev(iPlrId, pev_flags)|FL_ONGROUND));
		}
		g_bCheckTxtMsg = false;	
	}
	
	g_iBackupPlayerNum = 0;
	
	DisableHamForward(g_hh_Think_grenade_Post);
}

public Ham_Touch_grenade_Pre(iGrenEnt, iEnt)
{
	if( pev_valid(iGrenEnt) && pev_valid(iEnt) )
	{
		static s_iClassName[16];
		pev(iEnt, pev_classname, s_iClassName, 15);
		
		if( equal(s_iClassName, "func_breakable") && pev(iEnt, pev_rendermode) )
		{
			static Float:s_fVelocity[3];
			pev(iGrenEnt, pev_velocity, s_fVelocity);
			g_fOldSpeed = vector_length(s_fVelocity);
		}
		else
			g_fOldSpeed = 0.0;
	}
	else
		g_fOldSpeed = 0.0;
}

public Ham_Touch_grenade_Post(iGrenEnt, iEnt)
{
	if( g_fOldSpeed )
	{
		if( pev_valid(iGrenEnt) )
		{
			static Float:s_fVelocity[3], Float:s_fFraction;
			pev(iGrenEnt, pev_velocity, s_fVelocity);
			
			s_fFraction = (vector_length(s_fVelocity)/g_fOldSpeed);
			
			if( s_fFraction>1.0 )
			{
				s_fVelocity[0] /= s_fFraction;
				s_fVelocity[1] /= s_fFraction;
				s_fVelocity[2] /= s_fFraction;
			}
			
			if( s_fFraction>0.5 )
			{
				s_fVelocity[0] *= 0.5;
				s_fVelocity[1] *= 0.5;
				s_fVelocity[2] *= 0.5;
			}
			
			set_pev(iGrenEnt, pev_velocity, s_fVelocity);
		}
	}
}

public Ham_Wpn_SecAttack_Post(iWpnEnt)
{
	if( g_bPlanted && pev_valid(iWpnEnt) )
	{
		if( get_pdata_float(iWpnEnt, m_flNextSecondaryAttack, 4)>0.0 )
		{
			static s_iPlrId;
			if( 0<(s_iPlrId=get_pdata_cbase(iWpnEnt, m_pPlayer, 4))<=g_iMaxPlayers )
			{
				if( CheckPlayerBit(g_iAlive, s_iPlrId) )
				{
					if( get_pdata_int(s_iPlrId, m_fBombDefusing, 5)&BombStatus_BeingDefusing )
						cancel_defuse_now(s_iPlrId, (get_gametime()+1.0));
				}
			}
		}
	}
}

public find_c4()
{
	if( g_fRoundStartedAt>=0.0 )
	{
		new Float:fBuyTime = (get_pcvar_float(g_iCvar_buytime)*60.0);
		if( fBuyTime<15.0 )
			fBuyTime = 15.0;
		fBuyTime += g_fFreezeTime;
		new bool:bBuyTimePassed = (((get_gametime()-g_fRoundStartedAt)>fBuyTime)?true:false);
		
		for( new iPlrId=1; iPlrId<=g_iMaxPlayers; iPlrId++ )
		{
			if( CheckPlayerBit(g_iAlive, iPlrId) )
			{
				if( get_pdata_int(iPlrId, m_iMapZone, 5)&CS_MAPZONE_BUY )
				{
					if( CheckPlayerBit(g_iModifiedBuyZone, iPlrId) )
					{
						if( !bBuyTimePassed )
						{
							message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
							write_byte(1);
							write_string("buyzone");
							write_byte(0);
							write_byte(160);
							write_byte(0);
							message_end();
							
							ClearPlayerBit(g_iModifiedBuyZone, iPlrId);
						}
					}
					else if( bBuyTimePassed )
					{
						message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iPlrId);
						write_byte(1);
						write_string("buyzone");
						write_byte(160);
						write_byte(160);
						write_byte(160);
						message_end();
						
						SetPlayerBit(g_iModifiedBuyZone, iPlrId);
					}
				}
			}
		}
	}
	
	if( !g_bPlanted )
	{
		new iEnt, iOwner;
		while( (iEnt=engfunc(EngFunc_FindEntityByString, iEnt, "classname", "weapon_c4"))>0 )
		{
			if( pev_valid(iEnt) )
			{
				iOwner = pev(iEnt, pev_owner);
				if( iOwner>g_iMaxPlayers && pev_valid(iOwner) )
				{
					message_begin(MSG_ALL, g_iMsgId_BombPickup);
					message_end();
					
					new Float:fOrigin[3];
					pev(iOwner, pev_origin, fOrigin);
					
					message_begin(MSG_ALL, g_iMsgId_BombDrop);
					engfunc(EngFunc_WriteCoord, fOrigin[0]);
					engfunc(EngFunc_WriteCoord, fOrigin[1]);
					engfunc(EngFunc_WriteCoord, fOrigin[2]);
					write_byte(0);
					message_end();
					
					break;
				}
			}
		}
	}
}

write_statusicon(iPlrId, iEffect, iSprite[], iRed, iGreen, iBlue, bool:bRemoveBarTime=false)
{
	for( new iSpectator=1; iSpectator<=g_iMaxPlayers; iSpectator++ )
	{
		if( iPlrId==iSpectator )
		{
			if( iEffect>=0 )
			{
				message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iSpectator);
				write_byte(iEffect);
				write_string(iSprite);
				if( iEffect )
				{
					write_byte(iRed);
					write_byte(iGreen);
					write_byte(iBlue);
				}
				message_end();
			}
		}
		else if( CheckPlayerBit(g_iConnected, iSpectator) && !CheckPlayerBit(g_iAlive, iSpectator) )
		{
			if( pev(iSpectator, pev_iuser2)==iPlrId && pev(iSpectator, pev_iuser1)==4 )
			{
				if( iEffect>=0 )
				{
					message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iSpectator);
					write_byte(iEffect);
					write_string(iSprite);
					if( iEffect )
					{
						write_byte(iRed);
						write_byte(iGreen);
						write_byte(iBlue);
					}
					message_end();
				}
				
				if( bRemoveBarTime )
				{
					message_begin(MSG_ONE, g_iMsgId_BarTime, _, iSpectator);
					write_short(0);
					message_end();
				}
			}
		}
	}
}

check_status_icon_at_planted(iSpectated, iSpectator)
{
	switch( get_pdata_int(iSpectated, m_iTeam, 5) )
	{
		case CS_TEAM_CT:
		{
			if( get_pdata_int(iSpectated, m_fHasDefuseKit, 5)&HAS_DEFUSE_KIT )
			{
				message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iSpectator);
				write_byte(1);
				write_string("defuser");
				write_byte(0);
				write_byte(160);
				write_byte(0);
				message_end();
			}
		}
		case CS_TEAM_T:
		{
			if( pev(iSpectated, pev_weapons)&(1<<CSW_C4) )
			{
				message_begin(MSG_ONE, g_iMsgId_StatusIcon, _, iSpectator);
				write_byte(1);
				write_string("c4");
				write_byte(160);
				write_byte(160);
				write_byte(160);
				message_end();
			}
		}
	}
}

check_grenade_pre_explosion(iEnt)
{
	static Float:s_fDmgTime;
	pev(iEnt, pev_dmgtime, s_fDmgTime);
	
	if( s_fDmgTime<=get_gametime() )
		grenade_pre_explosion();
}

grenade_pre_explosion()
{
	g_iBackupPlayerNum = 0;
	for( new iPlayer=1; iPlayer<=g_iMaxPlayers; iPlayer++ )
	{
		if( CheckPlayerBit(g_iAlive, iPlayer) )
		{
			g_iBackupInfo[g_iBackupPlayerNum][0] = iPlayer;
			g_iBackupInfo[g_iBackupPlayerNum][1] = pev(iPlayer, pev_waterlevel);
			set_pev(iPlayer, pev_waterlevel, 1);
			g_iBackupPlayerNum++;
		}
	}
	if( g_iBackupPlayerNum )
		EnableHamForward(g_hh_Think_grenade_Post);
}

bool:is_user_in_secondary_attack(iPlrId, bool:bCheckPreAttack=false)
{
	new iWpnEnt = get_pdata_cbase(iPlrId, m_pActiveItem, 5);
	if( pev_valid(iWpnEnt) )
	{
		if( get_pdata_float(iWpnEnt, m_flNextSecondaryAttack, 4)>0.0 )
			return true;
		else if( bCheckPreAttack )
		{
			if( pev(iPlrId, pev_button)&IN_ATTACK2 )
			{
				switch( get_pdata_int(iWpnEnt, m_iId, 4) )
				{
					case CSW_AWP, CSW_SCOUT, CSW_G3SG1, CSW_SG550, CSW_SG552, CSW_AUG: return true;
					default: return false;
				}
			}
		}
	}
	
	return false;
}

cancel_defuse_now(iPlrId, Float:fSafeGameTime) // fSafeGameTime is get_gametime()+1.0
{
	new iEnt, Float:fNextThink, Float:fNextFreq, Float:fNextBeep, Float:fNextBlink, Float:fC4Blow, Float:fDefuseCountDown, iFlags, bool:bIsOnGround;
	
	new bool:bMsgBackUp = g_bCheckTxtMsg;
	new iPlrBackup = g_iBackupPlayerNum;
	iFlags = pev(iPlrId, pev_flags);
	if( iFlags&FL_ONGROUND )
	{
		set_pev(iPlrId, pev_flags, (iFlags&~FL_ONGROUND));
		bIsOnGround = true;
	}
	
	if( bMsgBackUp )
	{
		DisableHamForward(g_hh_Think_grenade_Post);
		g_bCheckTxtMsg = false;
	}
	
	while( (iEnt=engfunc(EngFunc_FindEntityByString, iEnt, "classname", "grenade"))>0 )
	{
		if( pev_valid(iEnt) )
		{
			if( get_pdata_int(iEnt, m_fBombStatus, 5)&(BOMB_PLANTED|BOMB_DEFUSING) )
			{
				pev(iEnt, pev_nextthink, fNextThink);
				fNextFreq = get_pdata_float(iEnt, m_flNextFreq, 5);
				fNextBeep = get_pdata_float(iEnt, m_flNextBeep, 5);
				fNextBlink = get_pdata_float(iEnt, m_flNextBlink, 5);
				fC4Blow = get_pdata_float(iEnt, m_flC4Blow, 5);
				fDefuseCountDown = get_pdata_float(iEnt, m_flDefuseCountDown, 5);
				
				set_pev(iEnt, pev_nextthink, fSafeGameTime);
				set_pdata_float(iEnt, m_flNextFreq, fSafeGameTime, 5);
				set_pdata_float(iEnt, m_flNextBeep, fSafeGameTime, 5);
				set_pdata_float(iEnt, m_flNextBlink, fSafeGameTime, 5);
				set_pdata_float(iEnt, m_flC4Blow, fSafeGameTime, 5);
				set_pdata_float(iEnt, m_flDefuseCountDown, fSafeGameTime, 5);
				
				if( bIsOnGround )
				{
					g_iBackupPlayerNum = 0;
					SetPlayerBit(g_iBackupPlayerNum, iPlrId);
					
					g_iBackupPlayerNum *= -1;
					g_bCheckTxtMsg = true;
					ExecuteHam(Ham_Think, iEnt);
					g_bCheckTxtMsg = false;
				}
				else
					ExecuteHam(Ham_Think, iEnt);
				
				set_pev(iEnt, pev_nextthink, fNextThink);
				set_pdata_float(iEnt, m_flNextFreq, fNextFreq, 5);
				set_pdata_float(iEnt, m_flNextBeep, fNextBeep, 5);
				set_pdata_float(iEnt, m_flNextBlink, fNextBlink, 5);
				set_pdata_float(iEnt, m_flC4Blow, fC4Blow, 5);
				if( get_pdata_int(iEnt, m_fBombStatus, 5)&BOMB_DEFUSING )
					set_pdata_float(iEnt, m_flDefuseCountDown, fDefuseCountDown, 5);
			}
		}
	}
	
	if( bIsOnGround && CheckPlayerBit(g_iAlive, iPlrId) )
		set_pev(iPlrId, pev_flags, (pev(iPlrId, pev_flags)|FL_ONGROUND));
	
	if( bMsgBackUp )
	{
		g_bCheckTxtMsg = true;
		g_iBackupPlayerNum = iPlrBackup;
		EnableHamForward(g_hh_Think_grenade_Post);
	}
}

fm_cs_get_grenade_type(iEnt)
{
	// you can comment/remove this
	// if you are sure that the entity
	// with the given index are valid
	//if( !pev_valid(iEnt) )
	//	return 0;
	
	// you can comment/remove this
	// if you are sure that the entity
	// with the given index are "grenade"
	//new iClassname[9];
	//pev(iEnt, pev_classname, iClassname, 8);
	//if( !equal(classname, "grenade") )
	//	return 0;
	
	//if( get_pdata_int(iEnt, 96, 5)&(1<<8) ) // m_fBombStatus & m_fPlantedC4 || m_bIsC4 & IS_C4
	if( get_pdata_int(iEnt, m_fBombStatus, 5)&BOMB_PLANTED )
		return CSW_C4;
	
	//new iBits = get_pdata_int(iEnt, 114, 5); // m_usEvent || m_iGrenadeType
	new iBits = get_pdata_int(iEnt, m_usEvent, 5);
	if( iBits&(1<<0) )
		return CSW_HEGRENADE;
	else if( iBits&(1<<1) )
		return CSW_SMOKEGRENADE;
	else if( !iBits )
		return CSW_FLASHBANG;
	
	return 0
}
Ark_Procession is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 06-26-2022 , 04:18   Re: Separate plugin only for the Roundtimer fix after change map
Reply With Quote #2

unique bump, this is an historical bug that deserves a fix.
Ark_Procession is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 06-27-2022 , 10:48   Re: Separate plugin only for the Roundtimer fix after change map
Reply With Quote #3

Please link more information or explain further as not everybody has noticed, cares or has made it clear to powers-who-be Steam. If it was that big of a deal I would demand my money back and sue for stress.
__________________
DJEarthQuake is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 06-27-2022 , 13:13   Re: Separate plugin only for the Roundtimer fix after change map
Reply With Quote #4

Quote:
Originally Posted by DJEarthQuake View Post
Please link more information or explain further as not everybody has noticed, cares or has made it clear to powers-who-be Steam. If it was that big of a deal I would demand my money back and sue for stress.
Haha, it goes like this:

Since 1.6 to Condition-zero, a bug still persist:

The bug:
When you plant the bomb in a "de_" map, If the bomb explodes and ends the match an automatic changelevel occurs. if the map is other than a "De_" lets say its a "CS_" the roundtimer/freezetime is gone for good.

How to reproduce:

1) For eg, host de_dust2.
2) Plant the c4.
3) Note that the roundtimer is gone ( normal steps so far)
4) make a changelevel to another map while the c4 is still planted or simulate a match ending event by Terrorist Win with c4 explosion. (change to a cs_ map)
5) Enjoy your roundtimer/freezetime gone for the rest of the map and other maps until you rehost server.

The code i posted brings a solution to this issue.
But it has other errors that makes the server crash.
As you will see, there is many more fixes in the plugin not only the roundtimer fix. I do NOT need any other than that fix.
Ark_Procession is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 06-28-2022 , 04:58   Re: Separate plugin only for the Roundtimer fix after change map
Reply With Quote #5

Search
__________________
DJEarthQuake is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 06-28-2022 , 13:18   Re: Separate plugin only for the Roundtimer fix after change map
Reply With Quote #6

Quote:
Originally Posted by DJEarthQuake View Post
i did search and found that long ago. i just does not work.
Ark_Procession is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 06-29-2022 , 08:19   Re: Separate plugin only for the Roundtimer fix after change map
Reply With Quote #7



Show me all the stuff that you have tried that does not work. Nobody has complained about the resolutions. Post on the 2 links I have shared so they know what works and what does not work please.
__________________
DJEarthQuake is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 06-29-2022 , 15:18   Re: Separate plugin only for the Roundtimer fix after change map
Reply With Quote #8

Quote:
Originally Posted by DJEarthQuake View Post


Show me all the stuff that you have tried that does not work. Nobody has complained about the resolutions. Post on the 2 links I have shared so they know what works and what does not work please.

Where to start, i compiled that hotfix provided by that person in github, tried on my server and the issue still persist.
I am using the latest condition-zero from steam of course.
(i read somewhere that this issue was officially fixed by valve, i don't know if this is true since i don't know why i always had it)

I don't know what else should i try.

Nobody complaining does not mean it works, there are many , many approved plugins with errors that nobody complain (but me lol)

My server is neatly organized, with few plugins and i have destroyed everything to create it from zero so i know the issue is not with my build.
Ark_Procession is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 06-30-2022 , 06:22   Re: Separate plugin only for the Roundtimer fix after change map
Reply With Quote #9

I don't have access to test following code. But maybe you could give it a try. I tried multiple ways to fix the bug. Hope one of them works in-game:

PHP Code:
#include <amxmodx>

new g_iMsgShowTimerg_iMsgRoundTimeFloat:round_start_gametime

public plugin_init( )
{
    
register_plugin("Timer Fix""1.0""AMXX Community")
    
        
register_event("HLTV","event_newround","a","1=0","2=0")
    
register_logevent("EventNewRound"2"1=Round_Start")

        
g_iMsgShowTimer get_user_msgid("ShowTimer")
        
g_iMsgRoundTime get_user_msgid("RoundTime")
        
//register_message(g_iMsgRoundTime,  "Message_RoundTime");
}

public 
event_newround()
{
 
round_start_gametime get_gametime()
}

public 
EventNewRound()
{
    
//Timer Fix
    
new aPlayers_for_Timer[32], aNumplayeriTime get_roundtime();
    
get_players(aPlayers_for_TimeraNum"ch");
    for(new 
0aNuma++)
    {
        
player aPlayers_for_Timer[a];
        
message_begin(MSG_ONE_UNRELIABLEg_iMsgShowTimer,_,player);
        
message_end();

        
message_begin(MSG_ONE_UNRELIABLEg_iMsgRoundTime,_,player);
                
write_short(floatround(iTime));
        
message_end();
    }
}

stock get_roundtime()
{
 return 
get_gametime() - round_start_gametime

__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.

Last edited by bibu; 07-01-2022 at 03:44.
bibu is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 06-30-2022 , 15:27   Re: Separate plugin only for the Roundtimer fix after change map
Reply With Quote #10

Quote:
Originally Posted by bibu View Post
I don't have access to test following code. But maybe you could give it a try. I tried multiple ways to fix the bug. Hope one of them works in-game:

PHP Code:
#include <amxmodx>

new g_iMsgShowTimerg_iMsgRoundTime

public plugin_init( )
{
    
register_plugin("Timer Fix""1.0""AMXX Community")
    
    
register_logevent("EventNewRound"2"1=Round_Start")

        
g_iMsgShowTimer get_user_msgid("ShowTimer")
        
g_iMsgRoundTime get_user_msgid("RoundTime")
  

        
//register_message(g_iMsgRoundTime,  "Message_RoundTime");
}

public 
EventNewRound()
{
    
//Timer Fix
    
new aPlayers_for_Timer[32], aNumplayer;
    
get_players(aPlayers_for_TimeraNum"ch");
    for(new 
0aNuma++)
    {
        
player aPlayers_for_Timer[a];
        
message_begin(MSG_ONE_UNRELIABLEg_iMsgShowTimer,_,player);
        
message_end();

        
message_begin(MSG_ONE_UNRELIABLEg_iMsgRoundTime,_,player);
        
message_end();
    }


Hello Bibu, thank you for helping:

Fatal error - Dedicated Server

PF_messageend_i: User Msg 'Round Time':0 bytes written, expected 2.

And the game crashed to desktop
Ark_Procession is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:38.


Powered by vBulletin®
Copyright ©2000 - 2023, vBulletin Solutions, Inc.
Theme made by Freecode