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

[L4D2] Melee hit cause explosives


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ddd123
Senior Member
Join Date: May 2021
Old 06-16-2022 , 21:09   [L4D2] Melee hit cause explosives
Reply With Quote #1

Do you know "Ullapool Caber"?
Pretty much like that but with L4D2 mod and more effective against witch/tank (More damage, Stumble, etc)

I'm trying to making it kinda similar plugin but doesn't know how it work the code
Since, i'm really noob at making code (Literally just copy paste the other scripts and i have no idea if i'm editing right) can someone help me?

Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

static const String:ENTPROP_MELEE_STRING[]    = "m_strMapSetScriptName";
static const String:CLASSNAME_MELEE_WPN[]     = "weapon_melee";


public OnClientPostAdminCheck(client)
{
    SDKHook(client, SDKHook_TraceAttack, OnTraceMeleeAttack);
}

public OnClientDisconnect(client)
{
    SDKUnhook(client, SDKHook_TraceAttack, OnTraceMeleeAttack);
}

public Action:OnTraceMeleeAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
{
    decl String:meleeweapon[128];
    GetEdictClassname(inflictor, meleeweapon, sizeof(meleeweapon));
    
    if (StrEqual(meleeweapon, CLASSNAME_MELEE_WPN))
    {
        GetEntPropString(GetPlayerWeaponSlot(attacker, 1), Prop_Data, ENTPROP_MELEE_STRING, meleeweapon, sizeof(meleeweapon));
    }
    
    if(StrEqual(meleeweapon, "cricket_bat")) 
    {
                        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); 
                        TeleportEntity(ent1, pos, NULL_VECTOR, NULL_VECTOR);
                        ActivateEntity(ent1);
                        SetEntityRenderMode(ent1, view_as<RenderMode>(3));
                        SetEntityRenderColor(ent1, 0, 0, 0, 0);
                        AcceptEntityInput(ent1, "Ignite", -1, -1);
                        AcceptEntityInput(ent1, "Break", -1, -1);
                        
                        ent2 = CreateEntityByName("prop_physics"); 
                        
                        DispatchKeyValue(ent2, "model", "models/props_junk/gascan001a.mdl"); 
                        DispatchSpawn(ent2); 
                        TeleportEntity(ent2, pos, NULL_VECTOR, NULL_VECTOR);
                        ActivateEntity(ent2);
                        SetEntityRenderMode(ent2, view_as<RenderMode>(3));
                        SetEntityRenderColor(ent2, 0, 0, 0, 0);
                        AcceptEntityInput(ent2, "Ignite", -1, -1);
                        AcceptEntityInput(ent2, "Break", -1, -1);
                        
                        float radius = 150.0;
                        float pushforce = 500.0;
                        
                        int pointHurt = CreateEntityByName("point_hurt");   
                        
                        DispatchKeyValueFloat(pointHurt, "Damage", damage*2.0);        
                        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.0);                     
                        SetVariantString("spawnflags 24");                     
                        AcceptEntityInput(push, "AddOutput");
                        DispatchSpawn(push);
                        TeleportEntity(push, pos, NULL_VECTOR, NULL_VECTOR);  
                        AcceptEntityInput(push, "Enable", -1, -1);
                        CreateTimer(0.5, DeletePushForce, push);
                        return Plugin_Continue;
        }
    
    return Plugin_Continue;
}

stock bool:IsSurvivor(client)
{
    if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2)
    {
        return true;
    }
    return false;
}  

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);
		}
	}
}

Last edited by ddd123; 06-16-2022 at 21:10.
ddd123 is offline
Reply



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 00:38.


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