Day of Defeat Plugins Community
This site is an archive — everything is readable and downloadable, nothing can be posted. Admin

Useful Stocks

by Wilson [29th ID] · 2007-03-20 · 9 replies · 2219 views · 20 downloads

Read the thread (10 posts)

From the first post

Post your useful stocks here.
rn
rnThis one turns a weapon ID into a weapon Name. The one that comes with AMXX core doesn't do it properly.
rn
rn
stock dod_get_weaponname( wpnID, szWpnName[32] ) {rn	xmod_get_wpnlogname( wpnID, szWpnName, 31 );rn	format( szWpnName, 31, "weapon_%s", szWpnName );rn}

rn
rnThis one gets the users weapon entity number, based on the weapon the client is currently holding. It incorporates the above stock into it.
rn
rn
stock detect_weapon_id( id ) {rn	new m_iCurEnt = -1, m_iWpnEnt = 0, m_szWpn[32];rn	rn	// Get User Weapon and WpnNamern	new clip, ammo, m_iWpn = get_user_weapon(id,clip,ammo);rn	xmod_get_wpnlogname( m_iWpn, m_szWpn, 31 ); // Requires DoDX Modulern	format( m_szWpn, 31, "weapon_%s", m_szWpn );rnrn	// Get User Originrn	new Float:m_flOrigin[3];rn	pev( id, pev_origin, m_flOrigin );rn	rn	// Find Dummy Weaponrn	while( ( m_iCurEnt = engfunc( EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0 ) ) != 0 ) {rn		new m_szClassname[32];rn		pev( m_iCurEnt, pev_classname, m_szClassname, 31 );rn    rn		if( equal( m_szClassname, m_szWpn ) )rn			m_iWpnEnt = m_iCurEnt;rn	}rn	return m_iWpnEnt;rn}

rn
rnThis one tests whether a player has his bazooka shouldered. Requires Fakemeta module and the detect_weapon_id stock.
rn
rn
// Returns 1 if rocket is shoulderedrn#if defined _fakemeta_includedrnstock dod_is_shouldered( id ) {rn	return get_pdata_int( detect_weapon_id(id), 115, 4 );rn}rn#end if

rn
rnSet User Pronestate. Requires either FM or Engine.
rn
stock dod_set_pronestate( id, flag ) {rn#if defined _fakemeta_includedrn	set_pev( id, pev_iuser3, flag );rn#elseif defined _engine_includedrn	entity_set_int( id, EV_INT_iuser3, flag );rn#endifrn}

rn
rn
rnAttached Below
rnConst file for Model Sequences in DoD by Wilson

Files

sequences_const.txt Config / Docs 8 KB 20 dl Download

The thread

All 10 posts from 4 people on Useful Stocks, kept as they were written.

Wilson [29th ID]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
03-20-2007, 02:54 AM #1

Post your useful stocks here.rnrnThis one turns a weapon ID into a weapon Name. The one that comes with AMXX core doesn't do it properly.rnrn

rnstock dod_get_weaponname( wpnID, szWpnName[32] ) {rn	xmod_get_wpnlogname( wpnID, szWpnName, 31 );rn	format( szWpnName, 31, "weapon_%s", szWpnName );rn}rn
rnrnThis one gets the users weapon entity number, based on the weapon the client is currently holding. It incorporates the above stock into it.rnrn
rnstock detect_weapon_id( id ) {rn	new m_iCurEnt = -1, m_iWpnEnt = 0, m_szWpn[32];rn	rn	// Get User Weapon and WpnNamern	new clip, ammo, m_iWpn = get_user_weapon(id,clip,ammo);rn	xmod_get_wpnlogname( m_iWpn, m_szWpn, 31 ); // Requires DoDX Modulern	format( m_szWpn, 31, "weapon_%s", m_szWpn );rnrn	// Get User Originrn	new Float:m_flOrigin[3];rn	pev( id, pev_origin, m_flOrigin );rn	rn	// Find Dummy Weaponrn	while( ( m_iCurEnt = engfunc( EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0 ) ) != 0 ) {rn		new m_szClassname[32];rn		pev( m_iCurEnt, pev_classname, m_szClassname, 31 );rn    rn		if( equal( m_szClassname, m_szWpn ) )rn			m_iWpnEnt = m_iCurEnt;rn	}rn	return m_iWpnEnt;rn}rn
rnrnThis one tests whether a player has his bazooka shouldered. Requires Fakemeta module and the detect_weapon_id stock.rnrn
rn// Returns 1 if rocket is shoulderedrn#if defined _fakemeta_includedrnstock dod_is_shouldered( id ) {rn	return get_pdata_int( detect_weapon_id(id), 115, 4 );rn}rn#end ifrn
rnrnSet User Pronestate. Requires either FM or Engine.rn
rnstock dod_set_pronestate( id, flag ) {rn#if defined _fakemeta_includedrn	set_pev( id, pev_iuser3, flag );rn#elseif defined _engine_includedrn	entity_set_int( id, EV_INT_iuser3, flag );rn#endifrn}rn
rnrnrnAttached BelowrnConst file for Model Sequences in DoD by Wilson

T TooLz
posted here
Posts: 96
Threads: 11
Joined: Oct 2005
03-21-2007, 02:39 PM #2

So I could basically do this if I wanted to say get a weapon name for a Scoped FG42 or Scoped Enfield? I'm on my never ending quest for a weapon id for those right now.. lolrnrnCya

Wilson [29th ID]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
03-25-2007, 09:49 AM #3

Updated 25 MAR 2007. Added dod_is_shouldered()rnrnI'll be adding set_shouldered soon, but it requires animation setting etc. and I'm in the midst of something at the moment.

T TooLz
posted here
Posts: 96
Threads: 11
Joined: Oct 2005
03-26-2007, 10:23 AM #4

Based off of the "detect_weapon_id" by Wilson, I have come up with one to check to see if the weapon is a scoped weapon (For FG42 and Enfield uses only), and another to set it.nn

stock dod_get_scoped(id) {n    new m_iCurEnt = -1, m_iWpnEnt = 0, m_szWpn[32];n    new clip, ammo, m_iWpn = get_user_weapon(id,clip,ammo);n    new is_scopedn    xmod_get_wpnlogname(m_iWpn, m_szWpn, 31);n    format(m_szWpn, 31, "weapon_%s", m_szWpn);n    if(equal(m_szWpn, "weapon_scoped_enfield")) m_szWpn = "weapon_enfield";n    if(equal(m_szWpn, "weapon_scoped_fg42")) m_szWpn = "weapon_fg42";n    new Float:m_flOrigin[3];n    pev(id, pev_origin, m_flOrigin);n    while((m_iCurEnt = engfunc(EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0)) != 0) {n        new m_szClassname[32];n        pev(m_iCurEnt, pev_classname, m_szClassname, 31);n        if(equal(m_szClassname, m_szWpn))n            m_iWpnEnt = m_iCurEnt;n    }n    is_scoped = get_pdata_int(m_iWpnEnt,115,4);n    return is_scoped;n}
nnPretty much every gun should return 0 unless its Scoped FG42 or Scoped Enfield to my knowledge. If it returns 1, then its already the scoped version, if it returns 0 then it is not.nnAlso based on that is set scoped.nn
stock dod_set_scoped(id, dValue[2]) {n	new m_iCurEnt = -1, m_iWpnEnt = 0, m_szWpn[32];n	new clip, ammo, m_iWpn = get_user_weapon(id,clip,ammo);n	xmod_get_wpnlogname(m_iWpn, m_szWpn, 31);n	format(m_szWpn, 31, "weapon_%s", m_szWpn);n	if(equal(m_szWpn, "weapon_scoped_enfield")) m_szWpn = "weapon_enfield";n	if(equal(m_szWpn, "weapon_scoped_fg42")) m_szWpn = "weapon_fg42";n	new Float:m_flOrigin[3];n	pev(id, pev_origin, m_flOrigin);n	while((m_iCurEnt = engfunc(EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0)) != 0) {n		new m_szClassname[32];n		pev(m_iCurEnt, pev_classname, m_szClassname, 31);n		if(equal(m_szClassname, m_szWpn))n			m_iWpnEnt = m_iCurEnt;n	}n	set_pdata_int(id,m_iWpnEnt,115, dValue, 4);n}
nn1 Will set it to scoped, 0 will set it to normal.nnCya

Wilson [29th ID]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
03-28-2007, 11:53 PM #5

Updated 28 MAR 2007 -- Added Sequences Const file (should be .inc but forums won't allow that filetype)rnrnWill update it this week to include sequences of v_ models as well

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
03-29-2007, 01:50 AM #6

should be able to attach inc files..

K Kiel |17.SS|
posted here
Posts: 163
Threads: 12
Joined: Jul 2006
04-14-2007, 04:47 AM #7

Where do you put the stocks?

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
04-14-2007, 08:05 PM #8

in the sma file

Wilson [29th ID]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
12-20-2007, 11:36 PM #9

A better form of detect_weapon_id() that does not require using a string.nn

nstock detect_weapon_id( id, wpnid ) {n	new ent = -1, entid;nn	// Get User Originn	new Float:origin[3];n	pev( id, pev_origin, origin );n	n	// Find Weaponn	while( ( ent = engfunc( EngFunc_FindEntityInSphere, ent, origin, Float:1.0 ) ) != 0 ) {		n		entid = get_pdata_int( ent, 91, 4 );n    n		if( wpnid == entid ) return ent;n	}n	return 0;n}n
Wilson [29th ID]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
12-21-2007, 12:30 AM #10

Thread closed. Please refer to the DoD Stocks thread for further stock submission/download.

DoD Plugins Archive · Repository · Old Forum Threads · Maps · Admin · built 14 Sep 2026 00:34 UTC