View Single Post
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 09-27-2011 , 20:04   Re: No ammo refill since recent updates
Reply With Quote #4

Ok, there's no problem with GiveAmmo - my fault, it's just not fired at all for automatic reloads.

This is a better patch obeying the maxammo of that ammotype again.

PHP Code:
new bool:g_bHasNoAmmoInClip1[MAXPLAYERS+1] = {false,...};

public 
OnClientPutInServer(client)
{
    
g_DeathTimes[client] = 0.0;
    
CreateTimer(10.0Timer_WelcomeGetClientUserId(client));
    
    
g_bHasNoAmmoInClip1[client] = false;
}

public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if(!
g_AmmoHooks)
        return 
Plugin_Continue;
    
    new 
entity GetEntDataEnt2(clientg_ActiveWepOffs);
    if (
entity 1)
    {
        
g_bHasNoAmmoInClip1[client] = false;
        return 
Plugin_Continue;
    }
    
    
// He's out of ammo -> reloading
    
new iClip1 GetEntProp(entityProp_Send"m_iClip1");
    if(
iClip1 == 0)
    {
        
g_bHasNoAmmoInClip1[client] = true;
    }
    
// He got ammo in clip1 again but hadn't before -> reloaded.
    
else if(g_bHasNoAmmoInClip1[client])
    {
        
g_bHasNoAmmoInClip1[client] = false;
        
        new 
ammoType GetEntProp(entityProp_Send"m_iPrimaryAmmoType");
        
        if(
ammoType 0)
        {
            return 
Plugin_Continue;
        }
        
        
// Give some ammo.
        
DM_GiveClientAmmo(clientammoType30false);
    }
    
    return 
Plugin_Continue;

Attached Files
File Type: sp Get Plugin or Get Source (dm_basics.sp - 317 views - 8.5 KB)
File Type: smx dm_basics.smx (6.6 KB, 390 views)
__________________
Peace-Maker is offline