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

[L4D2] l4d2_weapons.inc


Post New Thread Reply   
 
Thread Tools Display Modes
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
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 09-29-2022 , 04:24   Re: [L4D2] l4d2_weapons.inc
Reply With Quote #12

Just to inform, here is a fork with multilingual support, using Valve #phrases:
https://github.com/dragokas/l4d2_weapons

Some items has no appropriate intrinsic phrases, so only English/Russian translations are integrated as a walkaround for them.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Reply


Thread Tools
Display Modes

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 10:06.


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