Alright so I've been looking up how to modify the players weapon fire rate dynamically. And I've found some code, but have been struggling to get it working properly. I've modified it for my uses, but it is still not working. So I figured I'd make a post that would not just help me, but others trying to do something similar.
I would truly appreciate any and all help received.
Here is my current code (I have cut out non-relevant code for ease of reading).
Code:
new g_offsActiveWeapon;
new g_offsNextPrimaryAttack;
public OnPluginStart()
{
g_offsActiveWeapon = FindSendPropOffs("CBasePlayer","m_hActiveWeapon");
g_offsNextPrimaryAttack = FindSendPropOffs("CBaseCombatWeapon","m_flNextPrimaryAttack");
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_PostThinkPost, OnPostThinkPost);
}
public OnPostThinkPost(client)
{
if(IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client))
{
new Float:gameTime = GetGameTime();
SetEntDataFloat(client, g_offsNextPrimaryAttack, gameTime,true);
}
}
What I am planning to do is eventually have a modifier so that different players fire at different rates. However, weapons do not seem to fire at a different rate. Instead the animations for all weapons and times from reload to fire for weapons like the xm1014 seem to be skewed.
Does anyone else have experience in matters such as these?
And before anyone mentions "weapon mod" I have taken a look at the code, and have tried to figure out the basis for how m_flNextPrimaryAttack works, so that I may create the code I need properly. However, there isn't a lot of documentation about using prop offsets like these.
Like I said above, any help is more than welcome.