View Single Post
Author Message
ddd123
Senior Member
Join Date: May 2021
Old 11-17-2022 , 18: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 08:13.
ddd123 is offline