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

GivePlayerAmmo in new dev build, how it works ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PlayBoy31
Senior Member
Join Date: May 2011
Location: into the void
Old 02-11-2014 , 11:34   GivePlayerAmmo in new dev build, how it works ?
Reply With Quote #1

there is a new func in dev build

GivePlayerAmmo in new dev build

but how it works ?

and what is ammotype ? how get the list of ammotype?
PlayBoy31 is offline
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 02-11-2014 , 11:40   Re: GivePlayerAmmo in new dev build, how it works ?
Reply With Quote #2

PHP Code:
/**
* Gives ammo of a certain type to a player.
* This natives obeys the maximum amount of ammo a player can carry per ammo type.
*
* @param client        The client index.
* @param amount        Amount of ammo to give. Is capped at ammotype's limit.
* @param ammotype      Type of ammo to give to player.
* @param suppressSound If true, don't play the ammo pickup sound.
*
* @return Amount of ammo actually given.
*/
native GivePlayerAmmo(clientamountammotypebool:suppressSound=false); 
To retrieve ammo type you should use GetEntProp(weaponIdx, Prop_Data, "m_iPrimaryAmmoType");
Other than that this plugin also sets weapon ammo.
See also SetAmmo.
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
PlayBoy31
Senior Member
Join Date: May 2011
Location: into the void
Old 02-11-2014 , 12:03   Re: GivePlayerAmmo in new dev build, how it works ?
Reply With Quote #3

ok

i currently use this for set metal on tf2 player

Code:
offset_m_iAmmo = FindSendPropOffs("CTFPlayer", "m_iAmmo");
SetEntData(client, offset_m_iAmmo + (3 * 4), iNewAmmo, 4);
so i can replace by

Code:
offset_m_iAmmo = FindSendPropOffs("CTFPlayer", "m_iAmmo");
GivePlayerAmmo(client, iNewAmmo, offset_m_iAmmo, false);

Last edited by PlayBoy31; 02-11-2014 at 12:04.
PlayBoy31 is offline
Chief149
Member
Join Date: Sep 2010
Old 07-17-2014 , 14:02   Re: GivePlayerAmmo in new dev build, how it works ?
Reply With Quote #4

I used the above method to give ammo to a player, but I can only get it to give pistol, smg, shotgun ammo, and grenades. Idk how to make it give crossbow, revolver, assault rifle, and rpg ammo, and slams. I'm coding for hl2 btw. Obviously each weapon slot is only pointing to the first of the two or more weapons. How do I get the second or 3rd of the weapons from each slot?
Chief149 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-17-2014 , 16:51   Re: GivePlayerAmmo in new dev build, how it works ?
Reply With Quote #5

PHP Code:
    new array_size GetEntPropArraySize(clientProp_Send"m_hMyWeapons");
    new 
entity;

    for(new 
0array_sizea++)
    {
        
entity GetEntPropEnt(clientProp_Send"m_hMyWeapons"a);

        if(
entity != -1)
        {
            
// Player carrying this weapon
        
}
    } 
net props
Bacardi is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-17-2014 , 19:07   Re: GivePlayerAmmo in new dev build, how it works ?
Reply With Quote #6

Quote:
Originally Posted by Bacardi View Post
PHP Code:
    new array_size GetEntPropArraySize(clientProp_Send"m_hMyWeapons");
    new 
entity;

    for(new 
0array_sizea++)
    {
        
entity GetEntPropEnt(clientProp_Send"m_hMyWeapons"a);

        if(
entity != -1)
        {
            
// Player carrying this weapon
        
}
    } 
net props
That'll work until Valve decides to randomly change it to a CUtlVector, which SM currently can't read. *coughm_hMyWearablescough*
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-17-2014 , 23:16   Re: GivePlayerAmmo in new dev build, how it works ?
Reply With Quote #7

hope they not invent hats to rest of OB games...
Bacardi is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-18-2014 , 09:21   Re: GivePlayerAmmo in new dev build, how it works ?
Reply With Quote #8

Quote:
Originally Posted by Bacardi View Post
hope they not invent hats to rest of OB games...
...CS:GO appears to have functions for dealing with wearables...
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 07-18-2014 , 09:28   Re: GivePlayerAmmo in new dev build, how it works ?
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
...CS:GO appears to have functions for dealing with wearables...
... such as weapons on chest.
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-18-2014 , 09:31   Re: GivePlayerAmmo in new dev build, how it works ?
Reply With Quote #10

Quote:
Originally Posted by Powerlord View Post
...CS:GO appears to have functions for dealing with wearables...
As in Dota, much of the "econ" code was ported from TF2, so there is support for them.

They did experiments with other item types in CS:GO before deciding to just do weapon skins. There's a document out there somewhere (from GDC maybe?) where they detail the pros and cons of each type of economy items they could do in and why they choose to only modify weapon finishes. It makes it seem unlikely that they'll do anything further in the near future.
psychonic 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 21:38.


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