Raised This Month: $12 Target: $400
 3% 

[CSGO] C4 Bomb explode when hit 3 times.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
asdfxD
Veteran Member
Join Date: Apr 2011
Old 09-22-2019 , 10:17   [CSGO] C4 Bomb explode when hit 3 times.
Reply With Quote #1

hi,

someone can create a plugin when you hit the bomb on players back it will explode? there is a plugin but the explode function is not working anymore, already tried.

https://forums.alliedmods.net/showthread.php?t=264341

from source:

Code:
/***********************************************************/
/********************* WHEN PLAYER HURT ********************/
/***********************************************************/
/* BACK = hitbox = 8 + hitgroup = 2 */
public Action OnTracekAttack(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
{
	//if(B_active_track_bomb)
	{
		if(B_active_track_bomb_c4_explode)
		{
			if(Client_IsIngame(victim) && Client_IsIngame(attacker))
			{
				int c4 = GetPlayerWeaponSlot(victim, CS_SLOT_C4);
				if(c4 != -1)
				{
					if(hitbox == 9 && damagetype == DMG_SHOT && hitgroup == 2)
					{
						if(GetClientTeam(victim) != GetClientTeam(attacker))
						{
							C_hit_num += 1;
							damage = 0.0;
							
							Handle kv = CreateKeyValues("bomb");
							KvSetNum(kv, "hit", C_hit_num);	
							KvSetNum(kv, "total_hit", C_active_track_bomb_hit_num);	
							KvSetNum(kv, "victim", victim);
							KvSetNum(kv, "attacker", attacker);
							
							if(C_hit_num == C_active_track_bomb_hit_num)
							{	
								Explode(victim, attacker, c4);
								CreateTimer(F_active_track_bomb_delay_time_msg, DisplayMessageHolderExplode, kv);	
								
								C_hit_num = 0;
							}
							else if(C_hit_num != 0 && C_hit_num < C_active_track_bomb_hit_num)
							{
								CreateTimer(F_active_track_bomb_delay_time_msg, DisplayMessageWarningBomb, kv);
							}
						}
						return Plugin_Changed;
					}
				}
			}
		}
	}
	return Plugin_Continue;
}

/***********************************************************/
/********************** PLAYER EXPLODE *********************/
/***********************************************************/
void Explode(int victim, int attacker, int c4)
{
	float pos[3];
	GetClientAbsOrigin(victim, pos);
	int victim_death = GetEntProp(victim, Prop_Data, "m_iDeaths");
	int vicitm_frags = GetEntProp(victim, Prop_Data, "m_iFrags");
	int attacker_frags = GetEntProp(attacker, Prop_Data, "m_iFrags");
	
	int explosion = CreateEntityByName("env_explosion");
	
	if(explosion != -1)
	{
		SetEntityHealth(victim, 1);
		
		// Stuff we will need
		float vector[3];
		int damage = 500;
		int radius = 128;
		int team = GetEntProp(victim, Prop_Send, "m_iTeamNum");
					
		// We're going to use eye level because the blast can be clipped by almost anything.
		// This way there's no chance that a small street curb will clip the blast.
		GetClientEyePosition(victim, vector);
					
			
		SetEntProp(explosion, Prop_Send, "m_iTeamNum", team);
		SetEntProp(explosion, Prop_Data, "m_spawnflags", 264);
		SetEntProp(explosion, Prop_Data, "m_iMagnitude", damage);
		SetEntProp(explosion, Prop_Data, "m_iRadiusOverride", radius);
		
		DispatchKeyValue(explosion, "rendermode", "5");
					
		DispatchSpawn(explosion);
		ActivateEntity(explosion);

		TE_SetupExplosion(pos, M_HALO01_PRECACHED, 5.0, 1, 0, 100, 1500);
		TE_Start("World Decal");
		TE_WriteVector("m_vecOrigin", pos);
		int random = GetRandomInt(0, 12);
		TE_WriteNum("m_nIndex", M_TACK_BOMB_DECALS_BLOOD[random]);
	
		TE_SendToAll();
		
		RemovePlayerItem(victim, c4);
		AcceptEntityInput(c4, "Kill");
		
		TeleportEntity(explosion, vector, NULL_VECTOR, NULL_VECTOR);
		EmitSoundToAll("weapons/hegrenade/explode3.wav", explosion, 1, 90);		
		AcceptEntityInput(explosion, "Explode");

		EmitSoundToAll("weapons/c4/c4_explode1.wav", explosion, 1, 90);
		
		SetEntProp(victim, Prop_Data, "m_iFrags", vicitm_frags);
		SetEntProp(victim, Prop_Data, "m_iDeaths", victim_death + 1);
		SetEntProp(attacker, Prop_Data, "m_iFrags", attacker_frags + 1);
	}
}

/***********************************************************/
/****************** PRECACHE BLOOD DECALS ******************/
/***********************************************************/
void PrecacheDecalsBlood()
{
	M_TACK_BOMB_DECALS_BLOOD[0] = PrecacheDecal("decals/blood_splatter.vtf");
	M_TACK_BOMB_DECALS_BLOOD[1] = PrecacheDecal("decals/bloodstain_003.vtf");
	M_TACK_BOMB_DECALS_BLOOD[2] = PrecacheDecal("decals/bloodstain_101.vtf");
	M_TACK_BOMB_DECALS_BLOOD[3] = PrecacheDecal("decals/bloodstain_002.vtf");
	M_TACK_BOMB_DECALS_BLOOD[4] = PrecacheDecal("decals/bloodstain_001.vtf");
	M_TACK_BOMB_DECALS_BLOOD[5] = PrecacheDecal("decals/blood8.vtf");
	M_TACK_BOMB_DECALS_BLOOD[6] = PrecacheDecal("decals/blood7.vtf");
	M_TACK_BOMB_DECALS_BLOOD[7] = PrecacheDecal("decals/blood6.vtf");
	M_TACK_BOMB_DECALS_BLOOD[8] = PrecacheDecal("decals/blood5.vtf");
	M_TACK_BOMB_DECALS_BLOOD[9] = PrecacheDecal("decals/blood4.vtf");
	M_TACK_BOMB_DECALS_BLOOD[10] = PrecacheDecal("decals/blood3.vtf");
	M_TACK_BOMB_DECALS_BLOOD[11] = PrecacheDecal("decals/blood2.vtf");
	M_TACK_BOMB_DECALS_BLOOD[12] = PrecacheDecal("decals/blood1.vtf");
}
asdfxD is offline
asdfxD
Veteran Member
Join Date: Apr 2011
Old 01-26-2023 , 11:46   Re: [CSGO] C4 Bomb explode when hit 3 times.
Reply With Quote #2

bump
asdfxD is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-26-2023 , 16:35   Re: [CSGO] C4 Bomb explode when hit 3 times.
Reply With Quote #3

necro!

lets see

Last edited by Bacardi; 01-26-2023 at 16:35.
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-27-2023 , 01:16   Re: [CSGO] C4 Bomb explode when hit 3 times.
Reply With Quote #4

Here is my own version, example.
- This not kill players.

Plugin check bomb carrier, bomb location (is player holding bomb in hands or back)
- Note! Works normally on player models what have attachment points "c4", "weapon_hand_R" and "weapon_hand_L"
So if you use custom models, there is a chance this would not work.

C4 get hits by bullet only.

C4 not get hits when dropped on gound. Player need carry the bomb.

When player hit c4 location of player body (you need hit player body, back or hands),
victim not take damage. And Chat announcment appear when hit.

After 3 hits, there is explosion and C4 get removed.


Again, plugin is example.
Attached Files
File Type: sp Get Plugin or Get Source (test.sp - 56 views - 5.8 KB)
__________________
Do not Private Message @me
Bacardi is offline
asdfxD
Veteran Member
Join Date: Apr 2011
Old 01-27-2023 , 16:31   Re: [CSGO] C4 Bomb explode when hit 3 times.
Reply With Quote #5

thanks @Barcardi :-)

plugin has errors and cannot be downloaded

199282.attach(196) : warning 213: tag mismatch
asdfxD is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-27-2023 , 17:29   Re: [CSGO] C4 Bomb explode when hit 3 times.
Reply With Quote #6

You could try compile source file yourself.
Web Compiler is using SourcePawn Compiler 1.10.0.6453


*edit
Here is continue of that plugin.

This kill bomb carrier when c4 get 3 hits while bomb is carried.

- Note! Game have client side bug, when you die, your ragdoll velocity get reset (zero ?).
But other players sees your ragdoll flying normally in server.
And you see other players ragdoll flying fine on server.
It is you, when your ragdoll fail working, in your own screen.

compiled plugin in zip
Code:
SourcePawn Compiler 1.12.0.6971
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2021 AlliedModders LLC

Code size:         12636 bytes
Data size:         3080 bytes
Stack/heap size:      16776 bytes
Total requirements:   32492 bytes
Attached Files
File Type: zip test.zip (11.1 KB, 81 views)
__________________
Do not Private Message @me

Last edited by Bacardi; 01-27-2023 at 19:32.
Bacardi is offline
asdfxD
Veteran Member
Join Date: Apr 2011
Old 04-22-2023 , 13:36   Re: [CSGO] C4 Bomb explode when hit 3 times.
Reply With Quote #7

thank u barcardi sry for the late reply, it works fine but if a bot has the bomb and got hit by a player or bot the server crashes.

edit: i updated sm from 6929 to 6934 and now it works with both.

Last edited by asdfxD; 04-22-2023 at 13:58.
asdfxD 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 17:35.


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