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

[L4D2] Drop Secondary (v1.4/1.6, 26-11-19)


Post New Thread Reply   
 
Thread Tools Display Modes
plug344
Member
Join Date: Dec 2021
Old 01-11-2022 , 19:16   Re: [L4D2] Drop Secondary (v1.4/1.6, 26-11-19)
Reply With Quote #31

Quote:
Originally Posted by HarryPotter View Post
PHP Code:
#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
    
HookEvent("player_death"OnPlayerDeathEventHookMode_Pre);
}

public 
void OnPlayerDeath(Event event, const char[] namebool dontBroadcast
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
    if(
client == || !IsClientInGame(client) || GetClientTeam(client) != 2)
    {
        return;
    }

    
int itemIdx;
    for (
int x 0<= 4x++)
    {
        if((
itemIdx GetPlayerWeaponSlot(clientx)) != -1)
        {
            
RemovePlayerItem(clientitemIdx);
            
AcceptEntityInput(itemIdx"Kill");
        }
    }

Your knowledge and wisdom are awesome! Now i can safely give items to respawn players. Thank you!
plug344 is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 02-16-2022 , 09:44   Re: [L4D2] Drop Secondary (v1.4/1.6, 26-11-19)
Reply With Quote #32

A better way to drop secondary weapon

Fix "Weapon 813 is not owned by client 1" error
Attached Files
File Type: sp Get Plugin or Get Source (drop_secondary.sp - 206 views - 1.7 KB)
File Type: txt drop_secondary.txt (1.2 KB, 171 views)

Last edited by sorallll; 05-17-2022 at 10:05.
sorallll is offline
Nexedail
Junior Member
Join Date: Dec 2020
Location: Italy
Old 05-17-2022 , 08:23   Re: [L4D2] Drop Secondary (v1.4/1.6, 26-11-19)
Reply With Quote #33

sorallll Plugin fails to compile
Spoiler
Nexedail is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 05-17-2022 , 10:04   Re: [L4D2] Drop Secondary (v1.4/1.6, 26-11-19)
Reply With Quote #34

Quote:
Originally Posted by Nexedail View Post
sorallll Plugin fails to compile
Spoiler
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdkhooks>

#define GAMEDATA    "drop_secondary"

int
    g_iOff_m_hHiddenWeapon
;

public 
Plugin myinfo =
{
    
name "L4D2 Drop Secondary",
    
author "Jahze, Visor, NoBody & HarryPotter, sorallll",
    
version    "2.0",
    
description    "Survivor players will drop their secondary weapon when they die",
    
url "https://github.com/Attano/Equilibrium"
};

public 
void OnPluginStart()
{
    
char sPath[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMsPathsizeof sPath"gamedata/%s.txt"GAMEDATA);
    if (!
FileExists(sPath))
        
SetFailState("\n==========\nMissing required file: \"%s\".\n=========="sPath);

    
GameData hGameData = new GameData(GAMEDATA);
    if (!
hGameData)
        
SetFailState("Failed to load \"%s.txt\" gamedata."GAMEDATA);

    
g_iOff_m_hHiddenWeapon hGameData.GetOffset("CTerrorPlayer::OnIncapacitatedAsSurvivor::m_hHiddenWeapon");
    if (
g_iOff_m_hHiddenWeapon == -1)
        
SetFailState("Failed to find offset: CTerrorPlayer::OnIncapacitatedAsSurvivor::m_hHiddenWeapon");
    
    
delete hGameData;

    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);
}

void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (!
client || !IsClientInGame(client) || GetClientTeam(client) != 2)
        return;

    
int entity GetEntDataEnt2(clientg_iOff_m_hHiddenWeapon);
    
SetEntData(clientg_iOff_m_hHiddenWeapon, -1);
    if (
entity MaxClients && IsValidEntity(entity) && GetEntPropEnt(entityProp_Data"m_hOwnerEntity") == client) {
        
float vecTarget[3];
        
GetEntPropVector(entityProp_Data"m_vecAbsOrigin"vecTarget);
        
SDKHooks_DropWeapon(cliententityvecTargetNULL_VECTOR/*, false*/);
    }

sorallll 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 23:09.


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