Raised This Month: $535 Target: $400
 133% 

Solved [L4D2] Help fix the Game Crash when chainsaw on witch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ddd123
Senior Member
Join Date: May 2021
Old 11-17-2022 , 19:57   [L4D2] Help fix the Game Crash when chainsaw on witch
Reply With Quote #1

So i'm editing this plugin but only explode when witch die

It's work fine but i have a problem

When i chainsaw a witch, the game crash and it doesn't give any error log or nothing

Does anybody know why it will crash the game when i kill witch with chainsaw? Or it is just me? Can someone fix this?

Code:
/* Plugin Template generated by Pawn Studio */
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
ConVar l4d_witch_death_explode_damage;
ConVar l4d_witch_death_explode_radius;
ConVar l4d_witch_death_explode_force;

public Plugin myinfo = 
{
	name = "Witch explode death",
	author = "Pan Xiaohai, tornasuk",
	description = "Allahu Akbar",
	version = "1.1.1",
	url = "<- URL ->"
}

public void OnPluginStart()
{
	l4d_witch_death_explode_damage = CreateConVar("l4d_witch_death_explode_damage", "100", "explode damage of rock");
	l4d_witch_death_explode_radius = CreateConVar("l4d_witch_death_explode_radius", "300", "explosion radius of rock");
	l4d_witch_death_explode_force = CreateConVar("l4d_witch_death_explode_force", "500", "explosion force of rock");

	AutoExecConfig(true, "l4d_witchexplodedeath");

	HookEvent("witch_killed", witch_killed);

}

public Action witch_killed(Event hEvent, const char[] strName, bool DontBroadcast)
{
	int witchid = hEvent.GetInt("witchid");
	
	ExplodeStarWitch(witchid);
}

public void OnMapStart()
{
	PrecacheModel("models/props_junk/propanecanister001a.mdl", true);
	PrecacheModel("models/props_junk/gascan001a.mdl", true);
} 

void ExplodeStarWitch(int victim)
{
	int ent1 = 0;
	int ent2 = 0;
	float pos[3];
	GetEntPropVector(victim, Prop_Send, "m_vecOrigin", pos);	
	pos[2] += 50.0;

	ent1 = CreateEntityByName("prop_physics"); 
	
	DispatchKeyValue(ent1, "model", "models/props_junk/propanecanister001a.mdl"); 
	DispatchSpawn(ent1); 
	int flags = GetEntityFlags(ent1);
	SetEntityFlags(ent1, flags|FL_EDICT_DONTSEND);
	TeleportEntity(ent1, pos, NULL_VECTOR, NULL_VECTOR);
	//ActivateEntity(ent1);
	SetEntityRenderMode(ent1, RENDER_TRANSALPHAADD);
	SetEntityRenderColor(ent1, 0, 0, 0, 0);
	//AcceptEntityInput(ent1, "Ignite", -1, -1);
	AcceptEntityInput(ent1, "Break", -1, -1);
	SetEntProp(ent1, Prop_Send, "m_CollisionGroup", 1, 1);
	SetEntityMoveType(ent1, MOVETYPE_NONE);
	
	ent2 = CreateEntityByName("prop_physics"); 
	
	DispatchKeyValue(ent2, "model", "models/props_junk/gascan001a.mdl"); 
	DispatchSpawn(ent2); 
	int flagss = GetEntityFlags(ent2);
	SetEntityFlags(ent2, flagss|FL_EDICT_DONTSEND);
	TeleportEntity(ent2, pos, NULL_VECTOR, NULL_VECTOR);
	//ActivateEntity(ent2);
	SetEntityRenderMode(ent2, RENDER_TRANSALPHAADD);
	SetEntityRenderColor(ent2, 0, 0, 0, 0);
	//AcceptEntityInput(ent2, "Ignite", -1, -1);
	AcceptEntityInput(ent2, "Break", -1, -1);
	SetEntProp(ent2, Prop_Send, "m_CollisionGroup", 1, 1);
	SetEntityMoveType(ent2, MOVETYPE_NONE);
	
	float damage = GetConVarFloat(l4d_witch_death_explode_damage);
	float radius = GetConVarFloat(l4d_witch_death_explode_radius);
	float pushforce = GetConVarFloat(l4d_witch_death_explode_force);
	
	int pointHurt = CreateEntityByName("point_hurt");   

	DispatchKeyValueFloat(pointHurt, "Damage", damage);        
	DispatchKeyValueFloat(pointHurt, "DamageRadius", radius);     
	DispatchKeyValue(pointHurt, "DamageDelay", "0.0");   
	DispatchSpawn(pointHurt);
	TeleportEntity(pointHurt, pos, NULL_VECTOR, NULL_VECTOR);  
	AcceptEntityInput(pointHurt, "Hurt", -1);    
	CreateTimer(0.1, DeletePointHurt, pointHurt); 

	int push = CreateEntityByName("point_push");         
	DispatchKeyValueFloat (push, "magnitude", pushforce);                     
	DispatchKeyValueFloat (push, "radius", radius*1.1);                     
	SetVariantString("spawnflags 24");                     
	AcceptEntityInput(push, "AddOutput");
	DispatchSpawn(push);
	TeleportEntity(push, pos, NULL_VECTOR, NULL_VECTOR);  
	AcceptEntityInput(push, "Enable", -1, -1);
	CreateTimer(1.0, DeletePushForce, push);
	
}


public Action DeletePushForce(Handle timer, any ent)
{
	if (IsValidEntity(ent))
	{
		char classname[64];
		GetEdictClassname(ent, classname, sizeof(classname));
		if (StrEqual(classname, "point_push", false))
		{
			AcceptEntityInput(ent, "Disable");
			AcceptEntityInput(ent, "Slay"); 
			RemoveEdict(ent);
		}
	}
}

public Action DeletePointHurt(Handle timer, any ent)
{
	if (IsValidEntity(ent))
	{
		char classname[64];
		GetEdictClassname(ent, classname, sizeof(classname));
		if (StrEqual(classname, "point_hurt", false))
		{
			AcceptEntityInput(ent, "Slay"); 
			RemoveEdict(ent);
		}
	}
}
You can rework entire and post on plugins forum, that would be really helpful

Last edited by ddd123; 11-18-2022 at 09:13.
ddd123 is offline
oqyh
Senior Member
Join Date: May 2019
Location: United Arab Emirates
Old 11-17-2022 , 20:55   Re: [L4D2] Help fix the Game Crash when chainsaw on witch
Reply With Quote #2

Quote:
Originally Posted by ddd123 View Post
So i'm editing this plugin but only explode when witch die

It's work fine but i have a problem

When i chainsaw a witch, the game crash and it doesn't give any error log or nothing

Does anybody know why it will crash the game when i kill witch with chainsaw? Or it is just me? Can someone fix this?

Code:
/* Plugin Template generated by Pawn Studio */
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
ConVar l4d_witch_death_explode_damage;
ConVar l4d_witch_death_explode_radius;
ConVar l4d_witch_death_explode_force;

public Plugin myinfo = 
{
	name = "Witch explode death",
	author = "Pan Xiaohai, tornasuk",
	description = "Allahu Akbar",
	version = "1.1.1",
	url = "<- URL ->"
}

public void OnPluginStart()
{
	l4d_witch_death_explode_damage = CreateConVar("l4d_witch_death_explode_damage", "100", "explode damage of rock");
	l4d_witch_death_explode_radius = CreateConVar("l4d_witch_death_explode_radius", "300", "explosion radius of rock");
	l4d_witch_death_explode_force = CreateConVar("l4d_witch_death_explode_force", "500", "explosion force of rock");

	AutoExecConfig(true, "l4d_witchexplodedeath");

	HookEvent("witch_killed", witch_killed);

}

public Action witch_killed(Event hEvent, const char[] strName, bool DontBroadcast)
{
	int witchid = hEvent.GetInt("witchid");
	
	ExplodeStarWitch(witchid);
}

public void OnMapStart()
{
	PrecacheModel("models/props_junk/propanecanister001a.mdl", true);
	PrecacheModel("models/props_junk/gascan001a.mdl", true);
} 

void ExplodeStarWitch(int victim)
{
	int ent1 = 0;
	int ent2 = 0;
	float pos[3];
	GetEntPropVector(victim, Prop_Send, "m_vecOrigin", pos);	
	pos[2] += 50.0;

	ent1 = CreateEntityByName("prop_physics"); 
	
	DispatchKeyValue(ent1, "model", "models/props_junk/propanecanister001a.mdl"); 
	DispatchSpawn(ent1); 
	int flags = GetEntityFlags(ent1);
	SetEntityFlags(ent1, flags|FL_EDICT_DONTSEND);
	TeleportEntity(ent1, pos, NULL_VECTOR, NULL_VECTOR);
	//ActivateEntity(ent1);
	SetEntityRenderMode(ent1, RENDER_TRANSALPHAADD);
	SetEntityRenderColor(ent1, 0, 0, 0, 0);
	//AcceptEntityInput(ent1, "Ignite", -1, -1);
	AcceptEntityInput(ent1, "Break", -1, -1);
	SetEntProp(ent1, Prop_Send, "m_CollisionGroup", 1, 1);
	SetEntityMoveType(ent1, MOVETYPE_NONE);
	
	ent2 = CreateEntityByName("prop_physics"); 
	
	DispatchKeyValue(ent2, "model", "models/props_junk/gascan001a.mdl"); 
	DispatchSpawn(ent2); 
	int flagss = GetEntityFlags(ent2);
	SetEntityFlags(ent2, flagss|FL_EDICT_DONTSEND);
	TeleportEntity(ent2, pos, NULL_VECTOR, NULL_VECTOR);
	//ActivateEntity(ent2);
	SetEntityRenderMode(ent2, RENDER_TRANSALPHAADD);
	SetEntityRenderColor(ent2, 0, 0, 0, 0);
	//AcceptEntityInput(ent2, "Ignite", -1, -1);
	AcceptEntityInput(ent2, "Break", -1, -1);
	SetEntProp(ent2, Prop_Send, "m_CollisionGroup", 1, 1);
	SetEntityMoveType(ent2, MOVETYPE_NONE);
	
	float damage = GetConVarFloat(l4d_witch_death_explode_damage);
	float radius = GetConVarFloat(l4d_witch_death_explode_radius);
	float pushforce = GetConVarFloat(l4d_witch_death_explode_force);
	
	int pointHurt = CreateEntityByName("point_hurt");   

	DispatchKeyValueFloat(pointHurt, "Damage", damage);        
	DispatchKeyValueFloat(pointHurt, "DamageRadius", radius);     
	DispatchKeyValue(pointHurt, "DamageDelay", "0.0");   
	DispatchSpawn(pointHurt);
	TeleportEntity(pointHurt, pos, NULL_VECTOR, NULL_VECTOR);  
	AcceptEntityInput(pointHurt, "Hurt", -1);    
	CreateTimer(0.1, DeletePointHurt, pointHurt); 

	int push = CreateEntityByName("point_push");         
	DispatchKeyValueFloat (push, "magnitude", pushforce);                     
	DispatchKeyValueFloat (push, "radius", radius*1.1);                     
	SetVariantString("spawnflags 24");                     
	AcceptEntityInput(push, "AddOutput");
	DispatchSpawn(push);
	TeleportEntity(push, pos, NULL_VECTOR, NULL_VECTOR);  
	AcceptEntityInput(push, "Enable", -1, -1);
	CreateTimer(1.0, DeletePushForce, push);
	
}


public Action DeletePushForce(Handle timer, any ent)
{
	if (IsValidEntity(ent))
	{
		char classname[64];
		GetEdictClassname(ent, classname, sizeof(classname));
		if (StrEqual(classname, "point_push", false))
		{
			AcceptEntityInput(ent, "Disable");
			AcceptEntityInput(ent, "Slay"); 
			RemoveEdict(ent);
		}
	}
}

public Action DeletePointHurt(Handle timer, any ent)
{
	if (IsValidEntity(ent))
	{
		char classname[64];
		GetEdictClassname(ent, classname, sizeof(classname));
		if (StrEqual(classname, "point_hurt", false))
		{
			AcceptEntityInput(ent, "Slay"); 
			RemoveEdict(ent);
		}
	}
}
You can rework entire and post on plugins forum, that would be really helpful

did you try this ?
https://forums.alliedmods.net/showpo...9&postcount=68
__________________
.:[ >> My Plugins << ]:.

My discord : Gold KingZ#1337
oqyh is offline
ddd123
Senior Member
Join Date: May 2021
Old 11-18-2022 , 04:36   Re: [L4D2] Help fix the Game Crash when chainsaw on witch
Reply With Quote #3

Quote:
Originally Posted by oqyh View Post
Yes, i edit the latest version

But after so many time to test and crashes (Yes, i did so many time), i finally got the error message and it's said "too many indices for index buffer. tell a programmer"

If that's a problem for crash, how come chainsawing to witch will produce many indices index buffer?

Might change the subject, But is there anyway to solve this problem? Maybe block blood(i assume that causing crash for too many blood?) when using chainsaw against witch or something?

EDIT: I remove all blood, explosion, fire, witch workshop mod and all lower graphic setting and is still crash

Last edited by ddd123; 11-18-2022 at 05:37.
ddd123 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 11-18-2022 , 06:21   Re: [L4D2] Help fix the Game Crash when chainsaw on witch
Reply With Quote #4

May be related to both issues below:

https://github.com/ValveSoftware/Sou...es/issues/2526
https://github.com/ValveSoftware/Sou...es/issues/3607
__________________
Marttt is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 11-18-2022 , 07:10   Re: [L4D2] Help fix the Game Crash when chainsaw on witch
Reply With Quote #5

Yeah, seems like using Chainsaw + Explosion with this method below , will make game crash when killing a witch, at least for windows
Code:
void Explosion(int client, float vPos[3])
{
	int entity = CreateEntityByName("prop_physics");
	if (!IsValidEntity(entity)) return;
	
	DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl");
	DispatchSpawn(entity);
	SetEntProp(entity, Prop_Send, "m_CollisionGroup", 1);
	TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
	AcceptEntityInput(entity, "break");
}

Use this instead: Tested > Working Fine

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.0"
#define SOUND "ambient/explosions/explode_1.wav"

ConVar g_Cvar_Enable;
ConVar g_Cvar_Damage;
ConVar g_Cvar_Radius;

public 
void OnPluginStart()
{
    
CreateConVar ("l4d_witch_death_explosion_version"PLUGIN_VERSION"l4d witch death explosion"FCVAR_SPONLY FCVAR_NOTIFY FCVAR_DONTRECORD);
    
g_Cvar_Enable CreateConVar("l4d_witch_death_explodsion_enable""1""Enable l4d2 witch death explosion"FCVAR_NOTIFYtrue0.0true1.0);
    
g_Cvar_Damage CreateConVar("l4d_witch_death_explodsion_damage""20""Set explosion damage after killing witches"FCVAR_NOTIFY);
    
g_Cvar_Radius CreateConVar("l4d_witch_death_explodsion_radius""300""Set explosion radius after killing witches"FCVAR_NOTIFY);
    
AutoExecConfig(true"l4d_witch_death_explosion");

    
HookEvent("witch_killed"Event_WitchKilled);
}

public 
void OnMapStart()
{
    
PrecacheSound(SOUNDfalse);
}

void Event_WitchKilled(Event event, const char[] namebool dontBroadcast)
{
    
float vPos[3];
    
int witchid event.GetInt("witchid");
    
    if(!
IsValidEntity(witchid) || !g_Cvar_Enable.BoolValue) return;
    
GetEntPropVector(witchidProp_Send"m_vecOrigin"vPos);
    
    
ExplosionEffect(vPos);
    
PushForceEffect(vPos);


// From Earendil: https://forums.alliedmods.net/showthread.php?p=2747814
void ExplosionEffect(float vPos[3])
{
    
int entity CreateEntityByName("env_explosion");
    
    
TeleportEntity(entityvPosNULL_VECTORNULL_VECTOR);
    
DispatchKeyValueFloat(entity"iMagnitude"g_Cvar_Damage.FloatValue);
    
DispatchKeyValueFloat(entity"iRadiusOverride"g_Cvar_Radius.FloatValue);
    
DispatchKeyValue(entity"rendermode""5");
    
DispatchKeyValue(entity"spawnflags""128");
    
DispatchKeyValue(entity"fireballsprite""sprites/zerogxplode.spr");
    
DispatchSpawn(entity);
    
    
SetVariantString("OnUser1 !self:Explode::0.01:1)");
    
AcceptEntityInput(entity"Addoutput");
    
AcceptEntityInput(entity"FireUser1");
    
EmitSoundToAll(SOUND_SNDCHAN_AUTOSNDLEVEL_RAIDSIRENSND_NOFLAGSSNDVOL_NORMALSNDPITCH_LOW, -1NULL_VECTORNULL_VECTORtrue0.0);
}

void PushForceEffect(float vPos[3])
{
    
float vTarg[3];
    for (
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
GetClientAbsOrigin(ivTarg);
            if(
GetVectorDistance(vPosvTarg) <= g_Cvar_Radius.FloatValue)
                
StaggerClient(GetClientUserId(i), vPos);
        }
    }
}

// From Silvers: https://forums.alliedmods.net/showthread.php?t=322063
void StaggerClient(int client, const float fPos[3])
{
    static 
int iScriptLogic INVALID_ENT_REFERENCE;
    if(
iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
    {
        
iScriptLogic EntIndexToEntRef(CreateEntityByName("logic_script"));
        if(
iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic)) return;
        
DispatchSpawn(iScriptLogic);
    }
    static 
char sBuffer[96];
    
Format(sBuffersizeof(sBuffer), "GetPlayerFromUserID(%d).Stagger(Vector(%d,%d,%d))"clientRoundFloat(fPos[0]), RoundFloat(fPos[1]), RoundFloat(fPos[2]));
    
SetVariantString(sBuffer);
    
AcceptEntityInput(iScriptLogic"RunScriptCode");
    
RemoveEntity(iScriptLogic);

__________________

Last edited by alasfourom; 11-18-2022 at 11:41.
alasfourom is offline
ddd123
Senior Member
Join Date: May 2021
Old 11-18-2022 , 08:51   Re: [L4D2] Help fix the Game Crash when chainsaw on witch
Reply With Quote #6

Quote:
Originally Posted by alasfourom View Post
Yeah, seems like using Chainsaw + Explosion with this method below , will make game crash when killing a witch, at least for windows
Code:
void Explosion(int client, float vPos[3])
{
	int entity = CreateEntityByName("prop_physics");
	if (!IsValidEntity(entity)) return;
	
	DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl");
	DispatchSpawn(entity);
	SetEntProp(entity, Prop_Send, "m_CollisionGroup", 1);
	TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
	AcceptEntityInput(entity, "break");
}

Use this instead: Tested > Working Fine

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.0"
#define SOUND "ambient/explosions/explode_1.wav"

ConVar g_Cvar_Damage;
ConVar g_Cvar_Radius;

public 
void OnPluginStart()
{
    
CreateConVar ("l4d_witchexplodedeath_version"PLUGIN_VERSION"l4d witchexplode death"FCVAR_SPONLY FCVAR_NOTIFY FCVAR_DONTRECORD);
    
g_Cvar_Damage CreateConVar("l4d_witch_death_explodsion_damage""20""explode damage of rock"FCVAR_NOTIFY);
    
g_Cvar_Radius CreateConVar("l4d_witch_death_explodsion_radius""300""explosion radius of rock"FCVAR_NOTIFY);
    
AutoExecConfig(true"l4d_witchexplodedeath");

    
HookEvent("witch_killed"Event_WitchKilled);

}

public 
void OnMapStart()
{
    
PrecacheSound(SOUNDfalse);
}

void Event_WitchKilled(Event event, const char[] namebool dontBroadcast)
{
    
float vPos[3];
    
int witchid event.GetInt("witchid");
    if(!
IsValidEntity(witchid)) return;
    
GetEntPropVector(witchidProp_Send"m_vecOrigin"vPos);
    
    
ExplosionEffect(vPos);
    
PushForceEffect(vPos);


// From Earendil: https://forums.alliedmods.net/showthread.php?p=2747814
void ExplosionEffect(float vPos[3])
{
    
int entity CreateEntityByName("env_explosion");
    
    
TeleportEntity(entityvPosNULL_VECTORNULL_VECTOR);
    
DispatchKeyValueFloat(entity"iMagnitude"g_Cvar_Damage.FloatValue);
    
DispatchKeyValueFloat(entity"iRadiusOverride"g_Cvar_Radius.FloatValue);
    
DispatchKeyValue(entity"rendermode""5");
    
DispatchKeyValue(entity"spawnflags""128");
    
DispatchKeyValue(entity"fireballsprite""sprites/zerogxplode.spr");
    
    
DispatchSpawn(entity);
    
    
SetVariantString("OnUser1 !self:Explode::0.01:1)");
    
AcceptEntityInput(entity"Addoutput");
    
AcceptEntityInput(entity"FireUser1");
    
EmitSoundToAll(SOUND_SNDCHAN_AUTOSNDLEVEL_RAIDSIRENSND_NOFLAGSSNDVOL_NORMALSNDPITCH_LOW, -1NULL_VECTORNULL_VECTORtrue0.0);
}

void PushForceEffect(float vPos[3])
{
    
float vTarg[3];
    for (
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
GetClientAbsOrigin(ivTarg);
            if(
GetVectorDistance(vPosvTarg) <= g_Cvar_Radius.FloatValue)
                
StaggerClient(GetClientUserId(i), vPos);
        }
    }
}

// From Silvers: https://forums.alliedmods.net/showthread.php?t=322063
void StaggerClient(int client, const float fPos[3])
{
    static 
int iScriptLogic INVALID_ENT_REFERENCE;
    if(
iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
    {
        
iScriptLogic EntIndexToEntRef(CreateEntityByName("logic_script"));
        if(
iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic)) return;
        
DispatchSpawn(iScriptLogic);
    }
    static 
char sBuffer[96];
    
Format(sBuffersizeof(sBuffer), "GetPlayerFromUserID(%d).Stagger(Vector(%d,%d,%d))"clientRoundFloat(fPos[0]), RoundFloat(fPos[1]), RoundFloat(fPos[2]));
    
SetVariantString(sBuffer);
    
AcceptEntityInput(iScriptLogic"RunScriptCode");
    
RemoveEntity(iScriptLogic);

omg Thank you so much! This work fine and no longer crashes!
Bless with your plugin/coding skill, alasfourom!
ddd123 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 18:02.


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