AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [L4D2] l4d2_weapons.inc (https://forums.alliedmods.net/showthread.php?t=326441)

Dragokas 08-06-2021 13:58

Re: [L4D2] l4d2_weapons.inc
 
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.

Dragokas 09-29-2022 04:24

Re: [L4D2] l4d2_weapons.inc
 
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.


All times are GMT -4. The time now is 23:43.

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