Raised This Month: $ Target: $400
 0% 

headshot drop bonus [Zombie Panic Source]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ORdli
Member
Join Date: Nov 2021
Old 03-06-2023 , 03:17   headshot drop bonus [Zombie Panic Source]
Reply With Quote #1

I need a simple plugin that will give a bonus for killing zombies in the head, so that after they die, a random type of ammunition will spawn near them, be it pills, pistol cartridges, or a shotgun ammo, who will not be difficult to do this?
ORdli is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-06-2023 , 05:21   Re: headshot drop bonus [Zombie Panic Source]
Reply With Quote #2

here is event of "headshot" kill
Code:
player_feed
 userid       short   4
 attacker     short   3
 assistant    short   0
 weapon       string  ppk
 headshot     bool    TRUE
 death        bool    TRUE
 dmgbits      short   8194

here list of entities
Spoiler
__________________
Do not Private Message @me
Bacardi is offline
ORdli
Member
Join Date: Nov 2021
Old 03-06-2023 , 06:27   Re: headshot drop bonus [Zombie Panic Source]
Reply With Quote #3

and will it work as if an item spawns near a zombie corpse after killing it?
ORdli is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-06-2023 , 12:24   Re: headshot drop bonus [Zombie Panic Source]
Reply With Quote #4

Try this
PHP Code:

#include <sdktools>
#include <sdkhooks>

#define ZPS_TEAM_NONE            0    // player running on map but haven't choose team
#define ZPS_TEAM_SPECTATOR    1    // observer
#define ZPS_TEAM_HUMAN        2    // human
#define ZPS_TEAM_ZOMBIE        3    // zombie


char items[][] = {
    
//"item_ammo_barricade",
    //"item_ammo_barricade_clip",
    //"item_ammo_barricadepile",
    //"item_ammo_flare",
    
"item_ammo_pistol",
    
"item_ammo_pistol_clip",
    
"item_ammo_revolver",
    
"item_ammo_revolver_clip",
    
"item_ammo_rifle",
    
"item_ammo_rifle_clip",
    
"item_ammo_shotgun",
    
"item_ammo_shotgun_clip",
    
"item_armor",
    
//"item_deliver",
    
"item_healthkit",
    
"item_pills"
}

public 
void OnPluginStart()
{
    
HookEvent("player_feed"player_feed)
}

public 
void player_feed(Event event, const char[] namebool dontBroadcast)
{
    if(!
event.GetBool("death") || !event.GetBool("headshot"))
        return;

    
int client GetClientOfUserId(event.GetInt("userid"));

    if(
GetClientTeam(client) == ZPS_TEAM_ZOMBIE// && ZPS_IsCarrier(client))
    
{
        
float pos[3];
        
GetClientEyePosition(clientpos);
        
        
DataPack pack = new DataPack();
        
pack.WriteFloatArray(possizeof(pos));
        
        
RequestFrame(delaypack);
    }
}

public 
void delay(DataPack data)
{
    
data.Reset();

    
float pos[3];
    
data.ReadFloatArray(possizeof(pos));

    
delete data;

    
int item CreateEntityByName(items[GetRandomInt(0sizeof(items)-1)]);
        
    if(
item != -1)
    {
        
TeleportEntity(itemposNULL_VECTORNULL_VECTOR);
        
DispatchSpawn(item);
    }
}

stock bool ZPS_IsCarrier(int client)
{
    if(
HasEntProp(clientProp_Send"m_bIsCarrier") &&
        
GetEntProp(clientProp_Send"m_bIsCarrier"))
    {
        return 
true;
    }

    return 
false;

__________________
Do not Private Message @me
Bacardi is offline
ORdli
Member
Join Date: Nov 2021
Old 03-07-2023 , 06:50   Re: headshot drop bonus [Zombie Panic Source]
Reply With Quote #5

works, thanks, but is it possible to somehow edit it so that items fall only if the player kills zombies with a sledgehammer? as I understand it, I should replace the headshot line with the name of the weapon?
ORdli is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-07-2023 , 08:56   Re: headshot drop bonus [Zombie Panic Source]
Reply With Quote #6

Code:
#include <sdktools>

#define ZPS_TEAM_NONE			0	// player running on map but haven't choose team
#define ZPS_TEAM_SPECTATOR	1	// observer
#define ZPS_TEAM_HUMAN		2	// human
#define ZPS_TEAM_ZOMBIE		3	// zombie


char items[][] = {
	//"item_ammo_barricade",
	//"item_ammo_barricade_clip",
	//"item_ammo_barricadepile",
	//"item_ammo_flare",
	"item_ammo_pistol",
	"item_ammo_pistol_clip",
	"item_ammo_revolver",
	"item_ammo_revolver_clip",
	"item_ammo_rifle",
	"item_ammo_rifle_clip",
	"item_ammo_shotgun",
	"item_ammo_shotgun_clip",
	"item_armor",
	//"item_deliver",
	"item_healthkit",
	"item_pills"
}

public void OnPluginStart()
{
	HookEvent("player_feed", player_feed)
}

public void player_feed(Event event, const char[] name, bool dontBroadcast)
{
	if(!event.GetBool("death") || !event.GetBool("headshot"))
		return;

	int client = GetClientOfUserId(event.GetInt("userid"));

	if(GetClientTeam(client) == ZPS_TEAM_ZOMBIE) // && ZPS_IsCarrier(client))
	{
		char weapon[50];
		event.GetString("weapon", weapon, sizeof(weapon));

		if(StrContains(weapon, "sledgehammer", false) == -1)
			return;

		float pos[3];
		GetClientEyePosition(client, pos);
		
		DataPack pack = new DataPack();
		pack.WriteFloatArray(pos, sizeof(pos));
		
		RequestFrame(delay, pack);
	}
}

public void delay(DataPack data)
{
	data.Reset();

	float pos[3];
	data.ReadFloatArray(pos, sizeof(pos));

	delete data;

	int item = CreateEntityByName(items[GetRandomInt(0, sizeof(items)-1)]);
		
	if(item != -1)
	{
		TeleportEntity(item, pos, NULL_VECTOR, NULL_VECTOR);
		DispatchSpawn(item);
	}
}

stock bool ZPS_IsCarrier(int client)
{
	if(HasEntProp(client, Prop_Send, "m_bIsCarrier") &&
		GetEntProp(client, Prop_Send, "m_bIsCarrier"))
	{
		return true;
	}

	return false;
}
__________________
Do not Private Message @me
Bacardi is offline
ORdli
Member
Join Date: Nov 2021
Old 03-07-2023 , 09:55   Re: headshot drop bonus [Zombie Panic Source]
Reply With Quote #7

the plugin works, thanks for the help!
ORdli 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 16:57.


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