Raised This Month: $ Target: $400
 0% 

[HL2MP ]How to know when a player is reloading


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Master53
Veteran Member
Join Date: Dec 2009
Old 12-02-2010 , 13:27   [HL2MP ]How to know when a player is reloading
Reply With Quote #1

this shows you when a player is reloadnig the current weapon in there hand. you need to put "IsReloading(Weapon)" on a timer or hook "IN_RELOAD" to see if the player is reloading or not

PHP Code:
stock bool:IsReloading(Weapon)
{

    
//Valid Weapon:
    
if(Weapon != -1)
    {

        
//Declare
        
new ReloadOffset GetEntProp(WeaponProp_Data"m_bInReload");

        
//Not Reloading:
        
if(ReloadOffset == 1)
        {

            
//Return:
            
return true;
        }
    }

    
//Return:
    
return false;
}

stock bool:IsValidWeapon(Client)
{

    
//Declare:
    
decl String:WeaponName[32];

    
//Initialize:
    
GetClientWeapon(ClientWeaponNamesizeof(WeaponName));


    
//Valid Weapon:
    
if((StrEqual(WeaponName"weapon_crowbar") || StrEqual(WeaponName"weapon_stunstick")))
    {

        
//Return:
        
return false;
    }

    
//Return:
    
return true;
}

stock HasClientWeapon(Client)

{


    
//Declare
    
new Offset FindSendPropOffs("CBasePlayer""m_hMyWeapons");

    new 
MaxGuns 256;



    
//Loop:
    
for(new 0MaxGuns= (4))

    {


        
//Declare:
        
new WeaponId GetEntDataEnt2(ClientOffset X);


        
//Valid Weapon:
        
if(WeaponId 0)

        {


            
//Declare:
            
decl String:ClassName[32], String:WeaponName[32];


            
//Initialize:
            
GetClientWeapon(ClientWeaponNamesizeof(WeaponName));
            
GetEdictClassname(WeaponIdClassNamesizeof(ClassName));


            
//Valid Weapon:
            
if(IsValidWeapon(Client) == true)
            {
                
//Is Current Weapon:
                
if(StrEqual(WeaponNameClassName))

                {


                    
//Return:
                    
return WeaponId;

                }
            }

        }

    }

    
//Return:
    
return -1;


__________________
Master(d)




Last edited by Master53; 12-03-2010 at 19:36.
Master53 is offline
 



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 18:23.


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