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

[REQ] L4D1 Fix incorrect ammo refill


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
axelnieves2012
Senior Member
Join Date: Oct 2014
Location: Argentina
Old 03-22-2020 , 22:54   [REQ] L4D1 Fix incorrect ammo refill
Reply With Quote #1

Hello everybody. Can anybody fix this bug please?
I need a plugin which refills ammo correctly just like L4D2, whenever you pickup ammo from ammo-pile.

The correct way is Fullammo + maxClipSize - currentAmmo.
I was not able to make this plugin by myself because I couldn't find any way to get max clip size.

I know maxclipsize for autoshotgun is 10, for m16a1 is 50, etc..... But it can be modified by plugins (survivor_upgrades, or by /left4dead/scripts/weapon_autoshotgun.txt)....
So I cannot trust in those values...

That's why I got stuck.
axelnieves2012 is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 07-12-2020 , 14:10   Re: [REQ] L4D1 Fix incorrect ammo refill
Reply With Quote #2

you can look here
see how rotoblin fix ammo refill, and separate out a individual plugin.

PHP Code:
// Fixed up the game mechanics bug when the ammo piles use didn't provide a full ammo refill for weapons.
public EF_ev_AmmoPickup(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
_EF_DoAmmoPilesFix(client,false);
}

public 
EF_ev_PlayerUse(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
target GetEventInt(event"targetid");
    if (!
IsWeaponSpawnEx(target) || GetEntProp(targetProp_Send"m_weaponID") != WEAPID_AMMO) return;

    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
_EF_DoAmmoPilesFix(clienttrue);
}

public 
Action:_IEF_OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seedmouse[2])
{
    
    if(
GetClientTeam(client) == && !TryToFixClientAmmo[client])
    {
        if(
buttons IN_USE)
        {
            if(
IsLookingAtAmmo(client))
            {
                
TryToFixClientAmmo[client] = true;
                
CreateTimer(0.05Timer_AmmoCheckclient);
                return 
Plugin_Continue;
            }
        }
    }
}

public 
_EF_DoAmmoPilesFix(clientbool:bUse)
{
    ...
}

public 
Action:Timer_AmmoCheck(Handle:timerany:client)
{
    if(
IsClientConnected(client)&&IsClientInGame(client)&&GetClientTeam(client) == 2)
    {
        
_EF_DoAmmoPilesFix(client,false);
    }
    
TryToFixClientAmmo[client] = false;

__________________

Last edited by HarryPotter; 07-12-2020 at 14:17.
HarryPotter is offline
axelnieves2012
Senior Member
Join Date: Oct 2014
Location: Argentina
Old 07-13-2020 , 22:51   Re: [REQ] L4D1 Fix incorrect ammo refill
Reply With Quote #3

Quote:
Originally Posted by fbef0102 View Post
you can look here
see how rotoblin fix ammo refill, and separate out a individual plugin.

PHP Code:
// Fixed up the game mechanics bug when the ammo piles use didn't provide a full ammo refill for weapons.
public EF_ev_AmmoPickup(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
_EF_DoAmmoPilesFix(client,false);
}

public 
EF_ev_PlayerUse(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
target GetEventInt(event"targetid");
    if (!
IsWeaponSpawnEx(target) || GetEntProp(targetProp_Send"m_weaponID") != WEAPID_AMMO) return;

    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
_EF_DoAmmoPilesFix(clienttrue);
}

public 
Action:_IEF_OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seedmouse[2])
{
    
    if(
GetClientTeam(client) == && !TryToFixClientAmmo[client])
    {
        if(
buttons IN_USE)
        {
            if(
IsLookingAtAmmo(client))
            {
                
TryToFixClientAmmo[client] = true;
                
CreateTimer(0.05Timer_AmmoCheckclient);
                return 
Plugin_Continue;
            }
        }
    }
}

public 
_EF_DoAmmoPilesFix(clientbool:bUse)
{
    ...
}

public 
Action:Timer_AmmoCheck(Handle:timerany:client)
{
    if(
IsClientConnected(client)&&IsClientInGame(client)&&GetClientTeam(client) == 2)
    {
        
_EF_DoAmmoPilesFix(client,false);
    }
    
TryToFixClientAmmo[client] = false;

Thank you so much, very useful answer.
axelnieves2012 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 20:41.


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