Wilson [29th ID]
01-20-2007, 05:35 AM
This is barely a tutorial. It's more like a reference for those who already know somewhat how to do it.
I found the pdata offsets for weapon's rate of fire in dod.
// These are the offsets and the values when the player is
// standing still, not firing, ready to fire.
#define OFFSET_1 103
#define OFFSET_2 104
#define VALUE_1 -1.0
#define VALUE_2 -0.001
Both get set to 0.49 when Firing the k98's primary fire, and set to 0.538 when bayoneting. Obviously this would be different for each weapon, but I believe it is the time before it can be fired/bayoneted again.
Here is some example code for changing the rate of fire. It basically makes it unlimited ROF so you can fire completely semi auto with any weapon (kar can shoot as fast as pistol or carbine)
public cmd_set_pdata( id ) {
new num, args[16];
read_args( args, 199 );
num = str_to_num( args );
new clip, ammo, weaponID = get_user_weapon(id,clip,ammo)
new weapon[32]
xmod_get_wpnlogname( weaponID, weapon, 31 );
format( weapon, 31, "weapon_%s", weapon );
new wpnent = detect_weapon_id( id, weapon );
if( num == 1 ) set_pdata_float( wpnent, OFFSET_1, VALUE_1 );
else if( num == 2 ) set_pdata_float( wpnent, OFFSET_2, VALUE_2 );
console_print( id, "Set pdata" );
return PLUGIN_HANDLED;
}
stock detect_weapon_id( id, szWpn[32] ) {
new m_iCurEnt = -1, m_iWpn = 0;
// 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, szWpn ) )
m_iWpn = m_iCurEnt;
}
return m_iWpn;
}
So it gets the user's origin, then finds the weapon entity in that origin that matches the weapon name that the user is holding, then depending on whether the command's argument was 1 or 2, it sets primary or secondary fire to the VALUE_1 / VALUE_2
So you'd register the client command in plugin_init like register_clcmd("setpdata", "cmd_set_pdata") then, for example, bind MOUSE1 "+attack;setpdata 1" and bind MOUSE2 "+attack2;setpdata 2"
Try it out it's extremely fun, and hopefully I'll have a customisable rate of fire plugin soon enough.
I found the pdata offsets for weapon's rate of fire in dod.
// These are the offsets and the values when the player is
// standing still, not firing, ready to fire.
#define OFFSET_1 103
#define OFFSET_2 104
#define VALUE_1 -1.0
#define VALUE_2 -0.001
Both get set to 0.49 when Firing the k98's primary fire, and set to 0.538 when bayoneting. Obviously this would be different for each weapon, but I believe it is the time before it can be fired/bayoneted again.
Here is some example code for changing the rate of fire. It basically makes it unlimited ROF so you can fire completely semi auto with any weapon (kar can shoot as fast as pistol or carbine)
public cmd_set_pdata( id ) {
new num, args[16];
read_args( args, 199 );
num = str_to_num( args );
new clip, ammo, weaponID = get_user_weapon(id,clip,ammo)
new weapon[32]
xmod_get_wpnlogname( weaponID, weapon, 31 );
format( weapon, 31, "weapon_%s", weapon );
new wpnent = detect_weapon_id( id, weapon );
if( num == 1 ) set_pdata_float( wpnent, OFFSET_1, VALUE_1 );
else if( num == 2 ) set_pdata_float( wpnent, OFFSET_2, VALUE_2 );
console_print( id, "Set pdata" );
return PLUGIN_HANDLED;
}
stock detect_weapon_id( id, szWpn[32] ) {
new m_iCurEnt = -1, m_iWpn = 0;
// 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, szWpn ) )
m_iWpn = m_iCurEnt;
}
return m_iWpn;
}
So it gets the user's origin, then finds the weapon entity in that origin that matches the weapon name that the user is holding, then depending on whether the command's argument was 1 or 2, it sets primary or secondary fire to the VALUE_1 / VALUE_2
So you'd register the client command in plugin_init like register_clcmd("setpdata", "cmd_set_pdata") then, for example, bind MOUSE1 "+attack;setpdata 1" and bind MOUSE2 "+attack2;setpdata 2"
Try it out it's extremely fun, and hopefully I'll have a customisable rate of fire plugin soon enough.