Raised This Month: $32 Target: $400
 8% 

[INS] Get/Give Upgrades/Gear


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 02-13-2018 , 21:46   [INS] Get/Give Upgrades/Gear
Reply With Quote #1

I have a friend that occasionally sends me coding requests for the insurgency servers he runs. The fun of that is that SM doesnt support the game too well, and there isnt much out there for examples/resources. Still, using jaredballou's work and random threads, experience, and lots of poking around, I've managed each request. I've hit a brick wall on the current one though.

Can anyone help me figure out how to check a players attachments (gear/upgrades)? I will eventually need to give them to players as well, but I if I can find netprops or ents to do this buy, I've found client cmds I can use (give_upgrade, give_gear). My dead end is knowing what attachments a player currently has. I cant find them as entities, so I assume they are some kind of property instead, either on the client or the weapon ent.

Any help out there?
__________________

Last edited by ThatOneGuy; 02-13-2018 at 21:49.
ThatOneGuy is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 02-16-2018 , 21:18   Re: [INS] Get/Give Upgrades/Gear
Reply With Quote #2

Things I've tried:
  • Equipping the items then running a test cmd to loop ents and list them all to see if it is listed.
  • sm_dump_netprops, sm_dump_classes, sm_dump_datamaps, sm_dump_teprops
  • Checking in VPKs for scripts or other entity documentation. Found:
    • "resource/insurgency_english.txt", which lists all of the ents (this appears to be a translation file), but the lookup keys cant be found anywhere else via searches.
    • "scripts/theaters/" has a bunch of game logic/settings for when upgrades are applied, etc. Found several references, but nothing I was able to work with.
  • Tried searching Insurgency SDK, but it seemed more map focused.
  • Hours of searching via alliedmods and google.

Any help or direction is appreciated.
__________________
ThatOneGuy is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 02-24-2018 , 18:05   Re: [INS] Get/Give Upgrades/Gear
Reply With Quote #3

Ok, I found a working method after finding the netprop m_upgradeSlots for weapons. However, this indirectly gives them the attachments, and doesnt actually overwrite the attachments in their inventory, making it so that, despite having the weapons attached, it doesnt appear that way in the inventory screen.

However, I had it showing the gear correctly, so I looked more into that and found the table m_PlayerInventory under class CINSPlayer. Here, I found exactly what I need, but I am having trouble navigating the property tree and could use some help.

CINSPlayer Relevant Netprops


I can access the members of m_EquippedGear no problem:
Code:
	int iGearOffs = GetEntSendPropOffs(client, "m_EquippedGear", true);
	if(iGearOffs != -1)
	{
		for(int i = 0; i <= TOTAL_GEAR_SLOTS; i++)
		{
			a_iGearMembers[i] = GetEntData(client, iGearOffs + (4*i));
		}
	}
But given that "m_WeaponPurchases" has a table for each weapon, each of which has members and its own "m_hUpgrades" table, I'm having trouble figuring out how to get to the tables at the weapon level, and its m_hUpgrades table, since the names appear multiple times, and I am a bit confused how the offsets work with nested tables. I've searched all over the forums for examples with nested netprop tables, but couldnt find any. I also checked out https://wiki.alliedmods.net/Entity_Properties , which several threads linked. I've also tried looking up navigating netprops and other related stuff.

Looking at the GetEnt* functions, I wondered if the "element" parameter would allow me to enumerate "m_WeaponPurchases" into each table. However, the ones I noticed with the element piece (GetEntProp, GetEntPropEnt) just return a value or ent index. I'm not sure if I'm supposed to just get the ent, then work off of its own class, and have concerns that doing that will land me back where I was with the inventory not being updated to reflect the changes.

I was also curious how GetEntDataArray works, and if that could help. In looking to test it to find out, I wasnt sure how to size it ("arraySize" param) when there are sub-tables...I first scripted:
Code:
	int aaiWeapons[12];
	iWeaponSlotOffs = FindSendPropInfo("m_PlayerInventory", "m_WeaponPurchases");
	GetEntDataArray(client, iWeaponSlotOffs, aaiWeapons, 12);
But before testing realized that the array would contain the 12 tables (0 - 11), but wasnt sure how that would hold the sub-tables.

Any help would be appreciated. The concept behind how to do this goes past this plugin and would be useful for others as well.
__________________
ThatOneGuy 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:24.


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