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

[L4D2]Another method used to get the m_strMapSetScriptName of a melee weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sorallll
Senior Member
Join Date: Oct 2018
Old 12-03-2022 , 00:50   [L4D2]Another method used to get the m_strMapSetScriptName of a melee weapon
Reply With Quote #1

When we tried to get the m_strMapSetScriptName of the tonfa dropped by the riot police, it returned an empty string
Attached Files
File Type: sp Get Plugin or Get Source (test.sp - 55 views - 2.0 KB)
sorallll is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 12-03-2022 , 08:55   Re: [L4D2]Another method used to get the m_strMapSetScriptName of a melee weapon
Reply With Quote #2

the other method that I usually use is checking by its model name.

PHP Code:
"models/weapons/melee/w_tonfa.mdl" 
in this case.
__________________

Last edited by Marttt; 12-03-2022 at 09:12.
Marttt is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 12-03-2022 , 09:08   Re: [L4D2]Another method used to get the m_strMapSetScriptName of a melee weapon
Reply With Quote #3

I have noticed another prop m_hMeleeWeaponInfo (Prop_Send) buy maybe comparing it with the meleeweapons table could find something.

These are my debug values:

Using on c5m1_waterfront map

Code:
] melee_dump_weapons_server 
(Server)0: shovel (hash=12) (4e467140)
(Server)1: pitchfork (hash=11) (8736c70)
(Server)2: golfclub (hash=10) (737ef0f0)
(Server)3: knife (hash=9) (6fd8f100)
(Server)4: electric_guitar (hash=8) (7292f100)
(Server)5: katana (hash=7) (f8ff120)
(Server)6: tonfa (hash=6) (6fb8a1c0)
(Server)7: cricket_bat (hash=5) (46a87d40)
(Server)8: crowbar (hash=4) (74e8f140)
(Server)9: baseball_bat (hash=3) (7202f160)
(Server)10: machete (hash=2) (5e461a60)
(Server)11: frying_pan (hash=1) (4a2ab460)
(Server)12: fireaxe (hash=0) (3fbc0410)

g_aMeleeScripts [0] fireaxe
g_aMeleeScripts [1] frying_pan
g_aMeleeScripts [2] machete
g_aMeleeScripts [3] baseball_bat
g_aMeleeScripts [4] crowbar
g_aMeleeScripts [5] cricket_bat
g_aMeleeScripts [6] tonfa
g_aMeleeScripts [7] katana
g_aMeleeScripts [8] electric_guitar
g_aMeleeScripts [9] knife
g_aMeleeScripts[10] golfclub
g_aMeleeScripts[11] pitchfork
g_aMeleeScripts[12] shovel
Result from the following melees:
  • frying_pan: Prop_Send integer "CTerrorMeleeWeapon" "m_hMeleeWeaponInfo" is 1
  • tonfa: Prop_Send integer "CTerrorMeleeWeapon" "m_hMeleeWeaponInfo" is 6
  • katana: Prop_Send integer "CTerrorMeleeWeapon" "m_hMeleeWeaponInfo" is 7

So in theory you can match the "ID" with the "hash"/index value of the meleetable.

In GitHub I only found one plugin that uses that netprop:
https://github.com/SamuelXXX/l4d2_su...e_when_died.sp
__________________

Last edited by Marttt; 12-03-2022 at 09:15.
Marttt is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 12-03-2022 , 09:31   Re: [L4D2]Another method used to get the m_strMapSetScriptName of a melee weapon
Reply With Quote #4

The ID's change every map start, so don't cache them for other maps.

Left4DHooks provides the native
PHP Code:
/**
 * @brief Retrieve the index for a given melee weapon from the Melee Weapon Database.
 * @remarks Index updated on OnMapStart - suggest using RequestFrame to find index.
 * @remarks Index can change depending on available melee weapons each map.
 *
 * @param weaponName     Weapon to lookup index id for
 *
 * @return                The index id. Returns -1 if no match is found or melee unavailable.
 */
// L4D2 only.
native int L4D2_GetMeleeWeaponIndex(const char[] weaponName); 
__________________
Silvers 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 13:44.


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