Thread: Too many checks
View Single Post
FoxMulder
Senior Member
Join Date: Jan 2009
Location: Orlando, FL
Old 04-17-2011 , 09:01   Re: Too many checks
Reply With Quote #12

Sandman still has ammo.

If you use m_iItemDefinitionIndex then you would need a list to check against (http://wiki.alliedmods.net/Team_Fort...nition_Indexes)


Think doing something like this would work.
PHP Code:
public bool:IsActiveWeaponMelee(client)
{
    
//returns false when active weapon is not melee
    //otherwise returns true
    
    
new iWeapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon");
    
    
//do check to see if activeweapon is in the first slot
    
if(GetPlayerWeaponSlot(client2) != iWeapon)
        return 
false;
    
    if(!
IsValidEntity(iWeapon))
        return 
false;
    
    
//check to see if it has ammo
    
new iOffset GetEntProp(iWeaponProp_Send"m_iPrimaryAmmoType"1)*4;
    new 
iAmmoTable FindSendPropInfo("CTFPlayer""m_iAmmo");
    new 
iCurAmmo GetEntData(clientiAmmoTable+iOffset);
    
    
//has ammo, technically not a melee weapon
    
if(iCurAmmo 0)
        return 
false;
    
    
//it's a melee weapon  :D
    
return true;

__________________

Last edited by FoxMulder; 04-17-2011 at 12:24. Reason: Derp, Slot 2 = Melee
FoxMulder is offline