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

[CS:GO] How to compare Enums


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pavelas
Junior Member
Join Date: Oct 2016
Old 11-08-2017 , 15:55   [CS:GO] How to compare Enums
Reply With Quote #1

Hello guys,

I have a question about enum. At the moment I am using <cstrike> library and I am trying to use CS_OnCSWeaponDrop function.

As you can see from the API, I am able to get weaponIndex.
PHP Code:
forward Action CS_OnCSWeaponDrop(int clientint weaponIndex); 
I would like to compare weaponIndex. For example, check if it is "awp". Of course I can use GetEntityClassname, but I see that there is enum CSWeaponID.

Is it possible somehow to compare weaponIndex in a clean way?
Something like:
PHP Code:
if (weaponIndex == CSWeapon_AWP)
... 
As you can see "CSWeapon_AWP" is inside enum, is it possible somehow to use it?

Thank you.
Pavelas is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 11-09-2017 , 00:08   Re: [CS:GO] How to compare Enums
Reply With Quote #2

But I don't think CSWeapon_AWP is a weapon/entity index
__________________
8guawong is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 11-09-2017 , 15:16   Re: [CS:GO] How to compare Enums
Reply With Quote #3

if you use the latest snapshot of sm 1.9 you can use.

Edit:
PHP Code:
int iItemDefIndex GetEntProp(entityProp_Send"m_iItemDefinitionIndex");

CSWeaponID id CS_ItemDefIndexToID(iItemDefIndex);

if (
id == CSWeapon_AWP
{
 
//do things


Last edited by Dr!fter; 11-09-2017 at 15:47.
Dr!fter is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-09-2017 , 16:49   Re: [CS:GO] How to compare Enums
Reply With Quote #4

What about defining new constants based on item definition for CSGO to avoid CS_ItemDefIndexToID?
__________________
Neuro Toxin is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 11-09-2017 , 20:02   Re: [CS:GO] How to compare Enums
Reply With Quote #5

SM itself wont use itemdefs directly in plugins (at least for now) since everything already uses weaponid's. New weapons use itemdefs in the enum now however (https://github.com/alliedmodders/sou...trike.inc#L135) You could also compare itemdefid using CS_WeaponIDToItemDefIndex(CSWeapon_AWP) (https://github.com/alliedmodders/sou...trike.inc#L395)

Last edited by Dr!fter; 11-09-2017 at 20:05.
Dr!fter 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 19:43.


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