Raised This Month: $ Target: $400
 0% 

[L4D] Limit ammo pile usage to 1 clip per use


Post New Thread Reply   
 
Thread Tools Display Modes
Hanzoligen
Junior Member
Join Date: Feb 2013
Old 02-26-2013 , 14:12   Re: [L4D] Limit ammo pile usage to 1 clip per use
Reply With Quote #11

I thought about that one, nice idea. How do I get the amount of ammo the player has?

PHP Code:
m_iAmmo_prim GetEntProp(clientProp_Send"m_iAmmo"_m_iPrimaryAmmoType); // Player ammunition for this weapon ammo type 
always delivers the maximum the player can carry.

Last edited by Hanzoligen; 02-26-2013 at 14:13.
Hanzoligen is offline
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 02-26-2013 , 15:12   Re: [L4D] Limit ammo pile usage to 1 clip per use
Reply With Quote #12

Quote:
Originally Posted by Hanzoligen View Post
I thought about that one, nice idea. How do I get the amount of ammo the player has?

PHP Code:
m_iAmmo_prim GetEntProp(clientProp_Send"m_iAmmo"_m_iPrimaryAmmoType); // Player ammunition for this weapon ammo type 
always delivers the maximum the player can carry.

You must be doing it wrong cause all you need is m_iammo, and a few other things:

First, you need the offsets for each weapon:

PHP Code:
#define    HUNTING_RIFLE_OFFSET_AMMO    8
#define    RIFLE_OFFSET_AMMO        12
#define    SMG_OFFSET_AMMO            20
#define    SHOTGUN_OFFSET_AMMO        24 
Second this is how I set ammo for a player:

PHP Code:
    new m_iAmmo FindDataMapOffs(client"m_iAmmo");
    
SetEntData(clientm_iAmmo+HUNTING_RIFLE_OFFSET_AMMO0);
    
SetEntData(clientm_iAmmo+RIFLE_OFFSET_AMMO0);
    
SetEntData(clientm_iAmmo+SMG_OFFSET_AMMO0);
    
SetEntData(clientm_iAmmo+SHOTGUN_OFFSET_AMMO0); 
So instead of SetEnData, use GetEntData to obtain their ammo with the right offset.
__________________
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
Hanzoligen
Junior Member
Join Date: Feb 2013
Old 02-26-2013 , 15:23   [L4D] Limit ammo pile usage to 1 clip per use
Reply With Quote #13

Did you read the code or try for yourself? I bet you dont receive the amout of ammo but the max limit instead.

I tried it 100 times
Hanzoligen is offline
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 02-26-2013 , 17:27   Re: [L4D] Limit ammo pile usage to 1 clip per use
Reply With Quote #14

Quote:
Originally Posted by Hanzoligen View Post
Did you read the code or try for yourself? I bet you dont receive the amout of ammo but the max limit instead.

I tried it 100 times
I didn't try your code, I tried mine from one of my plugins, and I got 200 Ammo for my rifle.
__________________
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
Hanzoligen
Junior Member
Join Date: Feb 2013
Old 02-26-2013 , 17:28   [L4D] Limit ammo pile usage to 1 clip per use
Reply With Quote #15

Can you please post your code here?
Hanzoligen is offline
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 02-26-2013 , 18:38   Re: [L4D] Limit ammo pile usage to 1 clip per use
Reply With Quote #16

Quote:
Originally Posted by Hanzoligen View Post
Can you please post your code here?
It's from survivor upgrades and it won't work with yours so its useless. The fact is you are obviously doing it wrong. You need to set the m_iAmmo based on the weapon's clip sizes.

PHP Code:
CheckWeaponUpgradeLimit(weaponclient)
{
    new 
UpgradeLimit 0;
    
decl String:WEAPON_NAME[64];
    
GetEdictClassname(weaponWEAPON_NAME32);

    if(
StrEqual(WEAPON_NAME"weapon_rifle") || StrEqual(WEAPON_NAME"weapon_smg"))
    {
        
UpgradeLimit 50;
    }
    else if(
StrEqual(WEAPON_NAME"weapon_pumpshotgun"))
    {
        
UpgradeLimit 8;
    }
    else if(
StrEqual(WEAPON_NAME"weapon_autoshotgun"))
    {
        
UpgradeLimit 10;
    }
    else if(
StrEqual(WEAPON_NAME"weapon_hunting_rifle"))
    {
        
UpgradeLimit 15;
    }
    return 
UpgradeLimit;

This should help you in trying to get the values of weapons and proper amount of ammo.
__________________

Last edited by Marcus101RR; 02-26-2013 at 18:39.
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
Hanzoligen
Junior Member
Join Date: Feb 2013
Old 02-26-2013 , 18:43   [L4D] Limit ammo pile usage to 1 clip per use
Reply With Quote #17

That defines a value for appropriate clipsizes.
Whats the code for returning the current amount of ammo of a player?
I read through survivor uogrades sourcecode also. I remember its the same method. You can do it two ways. Both of them didnt return the current amount but max amount instead. Post a screenshot with text from the script or the sourcecode which worked for you please
Hanzoligen is offline
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 02-26-2013 , 18:49   Re: [L4D] Limit ammo pile usage to 1 clip per use
Reply With Quote #18

Quote:
Originally Posted by Hanzoligen View Post
That defines a value for appropriate clipsizes.
Whats the code for returning the current amount of ammo of a player?
I read through survivor uogrades sourcecode also. I remember its the same method. You can do it two ways. Both of them didnt return the current amount but max amount instead. Post a screenshot with text from the script or the sourcecode which worked for you please
You are trying to get ammo based on clipsizes, for every use, it adds a clip size to the reserve? You need to experiment with the events. I suggest you try blocking the ammo pickup event to see if that stops the ammo reserve from increasing. Then, try using the player_use event to determine if its an ammo pile they are using and add the amount of ammo to the reserve of whatever value is returned based on the weapon they are carrying.

Of course they won't RETURN the current amount of the reserve, it returns the max because the event is fired first. You need to stop the event from giving the ammo in the first place, and add your own ammo to it. It requires some heavy scripting. I can think of 2 possible ways to do it. Phyiscally I have not tested, it but outside the constraints, I can add for each use ammo to the player's reserve and limit the amount of ammo usage.

If all else fails, I would set the max ammo cvars to their respectful ammo clip sizes, that, or put it to 0. Then use the events to handle all ammo packaging.
__________________
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
Hanzoligen
Junior Member
Join Date: Feb 2013
Old 02-26-2013 , 18:54   [L4D] Limit ammo pile usage to 1 clip per use
Reply With Quote #19

Thanks. Sounds like more work than expected.
Do you know where I can find info on blocking the ammo pile from giving max ammo?
Hanzoligen is offline
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 02-26-2013 , 18:57   Re: [L4D] Limit ammo pile usage to 1 clip per use
Reply With Quote #20

Quote:
Originally Posted by Hanzoligen View Post
Thanks. Sounds like more work than expected.
Do you know where I can find info on blocking the ammo pile from giving max ammo?
http://wiki.alliedmods.net/Events_(S...locking_Events

Sometimes things will not work the way you want. I suggest you find a way to prevent the ammo pile giving ammo first then deal with your own method of giving the ammo. Also do not use Primary Ammo, you do not need it. All you need is m_clip, and m_iAmmo.
__________________
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
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 22:29.


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