PDA

View Full Version : Useful Stocks


Wilson [29th ID]
03-20-2007, 03:54 AM
Post your useful stocks here.

This one turns a weapon ID into a weapon Name. The one that comes with AMXX core doesn't do it properly.


stock dod_get_weaponname( wpnID, szWpnName[32] ) {
xmod_get_wpnlogname( wpnID, szWpnName, 31 );
format( szWpnName, 31, "weapon_%s", szWpnName );
}


This one gets the users weapon entity number, based on the weapon the client is currently holding. It incorporates the above stock into it.


stock detect_weapon_id( id ) {
new m_iCurEnt = -1, m_iWpnEnt = 0, m_szWpn[32];

// Get User Weapon and WpnName
new clip, ammo, m_iWpn = get_user_weapon(id,clip,ammo);
xmod_get_wpnlogname( m_iWpn, m_szWpn, 31 ); // Requires DoDX Module
format( m_szWpn, 31, "weapon_%s", m_szWpn );

// Get User Origin
new Float:m_flOrigin[3];
pev( id, pev_origin, m_flOrigin );

// Find Dummy Weapon
while( ( m_iCurEnt = engfunc( EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0 ) ) != 0 ) {
new m_szClassname[32];
pev( m_iCurEnt, pev_classname, m_szClassname, 31 );

if( equal( m_szClassname, m_szWpn ) )
m_iWpnEnt = m_iCurEnt;
}
return m_iWpnEnt;
}


This one tests whether a player has his bazooka shouldered. Requires Fakemeta module and the detect_weapon_id stock.


// Returns 1 if rocket is shouldered
#if defined _fakemeta_included
stock dod_is_shouldered( id ) {
return get_pdata_int( detect_weapon_id(id), 115, 4 );
}
#end if


Set User Pronestate. Requires either FM or Engine.

stock dod_set_pronestate( id, flag ) {
#if defined _fakemeta_included
set_pev( id, pev_iuser3, flag );
#elseif defined _engine_included
entity_set_int( id, EV_INT_iuser3, flag );
#endif
}



Attached Below
Const file for Model Sequences in DoD by Wilson

TooLz
03-21-2007, 03:39 PM
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.. lol

Cya

Wilson [29th ID]
03-25-2007, 10:49 AM
Updated 25 MAR 2007. Added dod_is_shouldered()

I'll be adding set_shouldered soon, but it requires animation setting etc. and I'm in the midst of something at the moment.

TooLz
03-26-2007, 11:23 AM
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.

stock dod_get_scoped(id) {
new m_iCurEnt = -1, m_iWpnEnt = 0, m_szWpn[32];
new clip, ammo, m_iWpn = get_user_weapon(id,clip,ammo);
new is_scoped
xmod_get_wpnlogname(m_iWpn, m_szWpn, 31);
format(m_szWpn, 31, "weapon_%s", m_szWpn);
if(equal(m_szWpn, "weapon_scoped_enfield")) m_szWpn = "weapon_enfield";
if(equal(m_szWpn, "weapon_scoped_fg42")) m_szWpn = "weapon_fg42";
new Float:m_flOrigin[3];
pev(id, pev_origin, m_flOrigin);
while((m_iCurEnt = engfunc(EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0)) != 0) {
new m_szClassname[32];
pev(m_iCurEnt, pev_classname, m_szClassname, 31);
if(equal(m_szClassname, m_szWpn))
m_iWpnEnt = m_iCurEnt;
}
is_scoped = get_pdata_int(m_iWpnEnt,115,4);
return is_scoped;
}

Pretty 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.

Also based on that is set scoped.

stock dod_set_scoped(id, dValue[2]) {
new m_iCurEnt = -1, m_iWpnEnt = 0, m_szWpn[32];
new clip, ammo, m_iWpn = get_user_weapon(id,clip,ammo);
xmod_get_wpnlogname(m_iWpn, m_szWpn, 31);
format(m_szWpn, 31, "weapon_%s", m_szWpn);
if(equal(m_szWpn, "weapon_scoped_enfield")) m_szWpn = "weapon_enfield";
if(equal(m_szWpn, "weapon_scoped_fg42")) m_szWpn = "weapon_fg42";
new Float:m_flOrigin[3];
pev(id, pev_origin, m_flOrigin);
while((m_iCurEnt = engfunc(EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0)) != 0) {
new m_szClassname[32];
pev(m_iCurEnt, pev_classname, m_szClassname, 31);
if(equal(m_szClassname, m_szWpn))
m_iWpnEnt = m_iCurEnt;
}
set_pdata_int(id,m_iWpnEnt,115, dValue, 4);
}

1 Will set it to scoped, 0 will set it to normal.

Cya

Wilson [29th ID]
03-29-2007, 12:53 AM
Updated 28 MAR 2007 -- Added Sequences Const file (should be .inc but forums won't allow that filetype)

Will update it this week to include sequences of v_ models as well

diamond-optic
03-29-2007, 02:50 AM
should be able to attach inc files..

Kiel |17.SS|
04-14-2007, 05:47 AM
Where do you put the stocks?

diamond-optic
04-14-2007, 09:05 PM
in the sma file

Wilson [29th ID]
12-20-2007, 11:36 PM
A better form of detect_weapon_id() that does not require using a string.


stock detect_weapon_id( id, wpnid ) {
new ent = -1, entid;

// Get User Origin
new Float:origin[3];
pev( id, pev_origin, origin );

// Find Weapon
while( ( ent = engfunc( EngFunc_FindEntityInSphere, ent, origin, Float:1.0 ) ) != 0 ) {
entid = get_pdata_int( ent, 91, 4 );

if( wpnid == entid ) return ent;
}
return 0;
}

Wilson [29th ID]
12-21-2007, 12:30 AM
Thread closed. Please refer to the DoD Stocks (http://dodplugins.net/forums/showthread.php?t=1101) thread for further stock submission/download.