View Single Post
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 02-01-2014 , 14:38   Re: [CSGO] player_hurt & player_death
Reply With Quote #4

Quote:
Originally Posted by Root_ View Post
I had similar issue with finding whether or not usp or m4a1-s was used. I found a way and implemented that in this plugin.
Here is a small snippet that I made just now, untested.
Code:
new m_bSilencerOn, m_hActiveWeapon; public OnPluginStart() {     m_bSilencerOn   = FindSendPropOffs("CWeaponCSBaseGun", "m_bSilencerOn");     m_hActiveWeapon = FindSendPropOffs("CBasePlayer",      "m_hActiveWeapon"); } public OnSomeEvent() {     // Declare weapon string and player slot     decl String:szWeapon[MAX_NAME_LENGTH], slot; // Make sure slot is valid and we can retrieve its classname     if ((slot = GetEntDataEnt2(client, m_hActiveWeapon)) != -1 && GetEdictClassname(slot, szWeapon, sizeof(szWeapon)))     {         // Check whether or not silencer is inserted         if (bool:GetEntData(slot, m_bSilencerOn, true) == true)         {             // Replace whole weapon string appropriately. If 8th char is 'h' (weapon_Hpk2000) replace string to weapon_usp, otherwise it was m4a1.             ReplaceString(szWeapon, sizeof(szWeapon), szWeapon, (szWeapon[8] == 'h' ? "weapon_usp" : "weapon_m4a1"))         }         // Other stuff     } }
To be honest I'd like to use StrCat instead of replacing whole string (due to performance purposes), so take a look at Ammo Manager as well.
Is that not causing problem if you remove the silencer from the gun?
Mathias. is offline