AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   headshot drop bonus [Zombie Panic Source] (https://forums.alliedmods.net/showthread.php?t=342074)

ORdli 03-06-2023 03:17

headshot drop bonus [Zombie Panic Source]
 
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?

Bacardi 03-06-2023 05:21

Re: headshot drop bonus [Zombie Panic Source]
 
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

ORdli 03-06-2023 06:27

Re: headshot drop bonus [Zombie Panic Source]
 
and will it work as if an item spawns near a zombie corpse after killing it?

Bacardi 03-06-2023 12:24

Re: headshot drop bonus [Zombie Panic Source]
 
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;



ORdli 03-07-2023 06:50

Re: headshot drop bonus [Zombie Panic Source]
 
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?

Bacardi 03-07-2023 08:56

Re: headshot drop bonus [Zombie Panic Source]
 
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;
}


ORdli 03-07-2023 09:55

Re: headshot drop bonus [Zombie Panic Source]
 
the plugin works, thanks for the help!


All times are GMT -4. The time now is 05:02.

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