View Single Post
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 08-06-2021 , 13:58   Re: [L4D2] l4d2_weapons.inc
Reply With Quote #11

Many good stocks, but to find out how to equip weapon and set the max ammo, need a bottle of vodka.
By try and fail, using some your examples, my final variant:

PHP Code:

void PlayerEquip
(int clientchar[] weap_name)
{
    
int typeidiEntiCurWep;
    
float vOrigin[3];
    
GetClientAbsOrigin(clientvOrigin);
    
    if( 
weap_name[0] )
    {
        
type L4D2Wep_IdentifyItemByName(weap_nameid);
        if( 
type == ITEM_MELEE )
        {
            if( !
L4D2Wep_IsValidMelee(weap_name) )
                continue;
        }
        
        if( 
L4D2Wep_IsValidItemAndID(idtype) )
        {
            
int slot L4D2Wep_GetSlotByID(id);
            
iEnt L4D2Wep_SpawnItem(idtypevOrigin__false);
            if( 
iEnt != -)
            {
                
iCurWep GetPlayerWeaponSlot(clientslot);
                if( 
L4D2Wep_IsValidAndEntity(iCurWep) )
                {
                    
RemovePlayerItem(clientiCurWep);
                    
AcceptEntityInput(iCurWep"Kill");
                }
                
EquipPlayerWeapon(clientiEnt);
                
                if( 
slot == )
                {
                    
RequestFrame(Frame_SetMaxAmmoGetClientUserId(client));
                }
            }
        }
    }
}

public 
void Frame_SetMaxAmmo(int UserId)
{
    
int client GetClientOfUserId(UserId);
    if( 
client && IsClientInGame(client) )
    {
        
int ent GetPlayerWeaponSlot(client0);
        
int wep_id L4D2Wep_Identify(entIDENTIFY_HOLD);
        
int ammoId L4D2Wep_WepIDToAmmoID(wep_id);
        if( 
ammoId != AMMOID_NONE )
        {
            
L4D2Wep_SetPlayerAmmo(clientL4D2Wep_GetAmmo(ammoId));
        }
    }

Will be good to have it as a stock.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline