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

No ammo refill since recent updates


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 09-25-2011 , 21:42   No ammo refill since recent updates
Reply With Quote #1

There were some changes to the weapon reloading in the past css updates, which broke the GiveAmmo method as used by now. The weapon_reload event isn't fired for automatic reloads on empty clips either.

That's why players don't get their ammo refilled after blasting some enemies, which gets them out of ammo pretty fast.

Here's a quick and dirty fix to the dm_basics.sp replacing that GiveAmmo call and giving ammo after automatic reloads. This just sets the ammo to 200 instead of obeying the max clip size as before.

Primary changes:
Replaced
PHP Code:
DM_GiveClientAmmo(clientammoType30false); 
with
PHP Code:
SetEntData(client, (g_AmmoOffs + (ammoType*4)), 2004true); 
(and got the offset in OnPluginStart)

and required sdktools now
PHP Code:
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.
        
SetEntData(client, (g_AmmoOffs + (ammoType*4)), 2004true);
    }
    
    return 
Plugin_Continue;

Attached Files
File Type: sp Get Plugin or Get Source (dm_basics.sp - 240 views - 8.7 KB)
File Type: smx dm_basics.smx (6.7 KB, 285 views)
__________________

Last edited by Peace-Maker; 09-25-2011 at 22:00.
Peace-Maker is offline
Old 09-27-2011, 01:22
.ice
This message has been deleted by .ice.
.ice
Junior Member
Join Date: Jun 2011
Old 09-27-2011 , 01:23   Re: No ammo refill since recent updates
Reply With Quote #2

Thank you ! Good shit.
.ice is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 09-27-2011 , 06:57   Re: No ammo refill since recent updates
Reply With Quote #3

Nice fix. You should submit it as a patch so it makes it into official builds.
GoD-Tony is offline
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
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 10-07-2011 , 11:46   Re: No ammo refill since recent updates
Reply With Quote #5

Quote:
Originally Posted by GoD-Tony View Post
Nice fix. You should submit it as a patch so it makes it into official builds.
I did.
__________________
Peace-Maker is offline
-=Leb=-
SourceMod Donor
Join Date: Dec 2008
Location: Sweden/Stockholm
Old 10-13-2011 , 21:05   Re: No ammo refill since recent updates
Reply With Quote #6

The dead bodies are not disappearing
-=Leb=- is offline
-=Leb=-
SourceMod Donor
Join Date: Dec 2008
Location: Sweden/Stockholm
Old 10-15-2011 , 11:11   Re: No ammo refill since recent updates
Reply With Quote #7

peace maker, would you plz find a solution for ragdoll?
-=Leb=- is offline
Reply



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 05:38.


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