View Single Post
Author Message
sorallll
Senior Member
Join Date: Oct 2018
Old 01-12-2022 , 12:52   [L4D2]Exclude projectiles that have been thrown
Reply With Quote #1

Is there a better way to get the player's weapon without throwing projectiles?

The method currently in use
PHP Code:
int g_iGrenadeThrower[MAXPLAYERS 1];
public 
void OnEntityCreated(int entity, const char[] classname)
{
    if(
classname[0] != 'm' && classname[0] != 'p' && classname[0] != 'v')
        return;

    if(
strncmp(classname"molotov_projectile"19) == || strncmp(classname"pipe_bomb_projectile"21) == || strncmp(classname"vomitjar_projectile"20) == 0)
        
SDKHook(entitySDKHook_SpawnPostHook_SpawnPost);
}

void Hook_SpawnPost(int entity)
{
    
SDKUnhook(entitySDKHook_SpawnPostHook_SpawnPost);
    if(
entity <= MaxClients || !IsValidEntity(entity))
        return;

    
int iOwner GetEntPropEnt(entityProp_Data"m_hOwnerEntity");
    if(
iOwner <= MaxClients && IsClientInGame(iOwner) && GetClientTeam(iOwner) == 2)
    {
        
int iSlot GetPlayerWeaponSlot(iOwner2);
        if(
iSlot MaxClients)
            
g_iGrenadeThrower[iOwner] = EntIndexToEntRef(iSlot);
    }
}

char sWeapon [32];
int iSlot GetPlayerWeaponSlot(client2);
if(
iSlot MaxClients)
{
    if(
EntIndexToEntRef(iSlot) != g_iGrenadeThrower[client])
    {
        
GetEntityClassname(iSlotsWeaponsizeof(sWeapon));
    }


Last edited by sorallll; 01-21-2022 at 13:16.
sorallll is offline