Raised This Month: $37 Target: $400
 9% 

[CS:GO] Get active weapon's default clip value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abgar
Senior Member
Join Date: Apr 2015
Old 02-16-2016 , 02:05   [CS:GO] Get active weapon's default clip value
Reply With Quote #1

Hi guys,

For CS GO, i need to be able to determine what weapon a player is holding, what's the standard full clip value, and then reset the ammo to that particular value.

The idea will be that if you kill someone, you'll have a chance to have your weapon automatically filled. I know this can be done by using SMLIB functions to set ammo etc, but how can i get the current weapon's default clip size, without manually defining each individual weapons clip size?

Cheers
abgar is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 02-16-2016 , 02:07   Re: [CS:GO] Get active weapon's default clip value
Reply With Quote #2

https://forums.alliedmods.net/showpo...62&postcount=4
__________________
8guawong is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 02-16-2016 , 03:14   Re: [CS:GO] Get active weapon's default clip value
Reply With Quote #3



I might make a nice api for the items file.......
__________________
Neuro Toxin is offline
abgar
Senior Member
Join Date: Apr 2015
Old 02-16-2016 , 07:27   Re: [CS:GO] Get active weapon's default clip value
Reply With Quote #4

Thanks.
Forgive my ignorance, but how would that actually work in a plugin application?

As in, in an event, say player death, how would I read the TXT file and get the relevant data?

Thanks again for any further hell
abgar is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 02-16-2016 , 17:16   Re: [CS:GO] Get active weapon's default clip value
Reply With Quote #5

You would iterate the file and store the definition index and default clip into arrays.

Then you have a function like GetWeaponDefaultClip which loops the array to get the clipsize.

You wouldnt iterate the items file every call as it would rek server performance.
__________________

Last edited by Neuro Toxin; 02-16-2016 at 17:17.
Neuro Toxin is offline
abgar
Senior Member
Join Date: Apr 2015
Old 02-16-2016 , 23:04   Re: [CS:GO] Get active weapon's default clip value
Reply With Quote #6

Hmm i don't even have the csgo.txt file in my directory to parse....

From a different angle, where can i find the complete list of CS GO weapon names (for sourcemod - i.e. weapon_m4a1)?

I've had a look at your plugin Neuro Toxin, but i don't actually understand it sorry, so i will have to rely on manually defining the clip value for each weapon.
abgar is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 02-16-2016 , 23:52   Re: [CS:GO] Get active weapon's default clip value
Reply With Quote #7

If you want. Ill update give named item ex to include natives to get clip sizes?

This way u don't have to update source code when things change.
__________________
Neuro Toxin is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 02-17-2016 , 09:28   Re: [CS:GO] Get active weapon's default clip value
Reply With Quote #8

Hey Neuro, I'm also working on a CSGO Items project, I added you back on steam since I was wondering if you would like to collaborate with the project. Anyway feel free to check it out here: https://bitbucket.org/SM91337/csgo-items/src

I have also created a PHP api https://fragdeluxe.com/api/itemdata/

Quote:
Originally Posted by abgar View Post
Hi guys,

For CS GO, i need to be able to determine what weapon a player is holding, what's the standard full clip value, and then reset the ammo to that particular value.

The idea will be that if you kill someone, you'll have a chance to have your weapon automatically filled. I know this can be done by using SMLIB functions to set ammo etc, but how can i get the current weapon's default clip size, without manually defining each individual weapons clip size?

Cheers
I can also add this functionality to CSGO Items.

I think this API could be useful for Deathmatch plugins by creating a dynamic gun menu etc, I did not originally plan on releasing it but I feel I need to do my part to give back to this amazing community at Alliedmods.

Last edited by SM9; 02-17-2016 at 09:46.
SM9 is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 02-17-2016 , 11:26   Re: [CS:GO] Get active weapon's default clip value
Reply With Quote #9

Edit: done.

PHP Code:
#include <csgoitems>

public Plugin myinfo 
{
    
name "Test Plugin"
    
author "SM9"
    
version "0.1"
    
url "http://www.fragdeluxe.com"
};

public 
void OnPluginStart()
{
    if (
GetEngineVersion() != Engine_CSGO) {
        
SetFailState("This plugin is for CSGO only.");
    }
}

stock int GetActiveDefaultClipAmmo(int iClient
{
    
int iDefIndex CSGOItems_GetActiveWeaponDefIndex(iClient);
    return 
CSGOItems_GetWeaponClipAmmoByDefIndex(iDefIndex);
}

stock bool RefillActiveWeapon(int iClient
{
    
int iWeapon CSGOItems_GetActiveWeaponIndex(iClient);
    return 
CSGOItems_RefillClipAmmo(iWeapon); // true on success.


Last edited by SM9; 02-17-2016 at 16:29.
SM9 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-17-2016 , 13:36   Re: [CS:GO] Get active weapon's default clip value
Reply With Quote #10

Quote:
Originally Posted by xCoderx View Post
Hey Neuro, I'm also working on a CSGO Items project, I added you back on steam since I was wondering if you would like to collaborate with the project. Anyway feel free to check it out here: https://bitbucket.org/SM91337/csgo-items/src

I have also created a PHP api https://fragdeluxe.com/api/itemdata/



I can also add this functionality to CSGO Items.

I think this API could be useful for Deathmatch plugins by creating a dynamic gun menu etc, I did not originally plan on releasing it but I feel I need to do my part to give back to this amazing community at Alliedmods.
You have the repo set to private.

Without looking at it, it would honestly be as easy as just hardcoding the values, and making the plugin update when ever csgo updates, instead of constantly grabbing it from all the weapon script files.

Last edited by Mitchell; 02-17-2016 at 13:37.
Mitchell is offline
Reply


Thread Tools
Display Modes

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 02:23.


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