Raised This Month: $ Target: $400
 0% 

Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack


Post New Thread Reply   
 
Thread Tools Display Modes
Sil3nt Pr0digy
Member
Join Date: Mar 2011
Old 03-16-2011 , 06:16   Re: Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack
Reply With Quote #21

Alright so apparently I am still doing something wrong :/

Current Code:

Code:
new g_offsActiveWeapon;
new g_offsNextPrimaryAttack;
new g_offsNextSecondaryAttack;
new g_offsPlaybackRate;
new g_offsCycle;

public OnPluginStart()
{
    g_offsActiveWeapon = FindSendPropOffs("CBasePlayer", "m_hActiveWeapon");
    g_offsNextPrimaryAttack = FindSendPropOffs("CBaseCombatWeapon", "m_flNextPrimaryAttack");
    g_offsNextSecondaryAttack = FindSendPropOffs("CBaseCombatWeapon", "m_flNextSecondaryAttack");
    g_offsPlaybackRate = FindSendPropOffs("CBaseCombatWeapon","m_flPlaybackRate");
    g_offsCycle = FindSendPropOffs("CBaseCombatWeapon","m_flCycle");
}

public OnPreThink(client)
{
    if(IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client))
    {
        new weapon = GetEntData(client, g_offsActiveWeapon, 4);
        PrintToChatAll("Wep: %i", weapon);
        
        new Float:cycle = GetEntDataFloat(weapon, g_offsCycle);
        
        PrintToChatAll("Cycle: %f", cycle);
        if (FloatCompare(cycle, 0.0) == 0)
        {
            
            new Float:gameTime = GetGameTime();
            
            new Float:g_flMultiplier = 10.0;
            
            new Float:flNextPrimaryAttack = GetEntDataFloat(client, g_offsNextPrimaryAttack) - gameTime;
            new Float:flNextSecondaryAttack = GetEntDataFloat(client, g_offsNextSecondaryAttack) - gameTime;
            PrintToChatAll("Pri:%f : Sec:%f", flNextPrimaryAttack, flNextSecondaryAttack);
            
            SetEntDataFloat(client, g_offsPlaybackRate, g_flMultiplier);
            SetEntDataFloat(client, g_offsNextPrimaryAttack, (flNextPrimaryAttack / g_flMultiplier) + gameTime);
            SetEntDataFloat(client, g_offsNextSecondaryAttack, (flNextSecondaryAttack / g_flMultiplier) + gameTime);
        }  
    }
}
Surely my problem must be some minor thing that I am overlooking which will make me feel completely stupid for not being able to locate it beforehand T-T.

This whole thing is just getting really annoying to deal with. I almost feel like I would be better off creating my entire mod in C++. But there is not enough documentation on the offsets themselves, are what they alter in detail.

I just wish I could understand more about the offsets so they would stop annoying me >.<.

Can't really figure anything out unless I have to ask and bother you guys for help. :/

Any idea on what I'm overlooking Stryker?

NOTE:

This current code is crashing my SRCDS because of a memory access violation. So I assume what I am trying to do with pulling the m_flCycle from "weapon" is not working the way I intend it to. :/

Surely there is a proper way to do so?

Last edited by Sil3nt Pr0digy; 03-16-2011 at 06:19.
Sil3nt Pr0digy is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 03-17-2011 , 05:35   Re: Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack
Reply With Quote #22

You're never checking if "weapon" is even valid
AtomicStryker is offline
Sil3nt Pr0digy
Member
Join Date: Mar 2011
Old 03-17-2011 , 05:59   Re: Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack
Reply With Quote #23

Quote:
Originally Posted by AtomicStryker View Post
You're never checking if "weapon" is even valid
Using:
Code:
public OnPreThink(client)
{
    if(IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client))
    {
        new weapon = GetEntData(client, g_offsActiveWeapon, 4);
        PrintToChatAll("Wep: %i", weapon);
        
        if(IsValidEntity(weapon))
        {
            new Float:cycle = GetEntDataFloat(weapon, g_offsCycle);
            
            PrintToChatAll("Cycle: %f", cycle);
            if (FloatCompare(cycle, 0.0) == 0)
            {
                
                new Float:gameTime = GetGameTime();
                
                new Float:g_flMultiplier = 10.0;
                
                new Float:flNextPrimaryAttack = GetEntDataFloat(client, g_offsNextPrimaryAttack) - gameTime;
                new Float:flNextSecondaryAttack = GetEntDataFloat(client, g_offsNextSecondaryAttack) - gameTime;
                PrintToChatAll("Pri:%f : Sec:%f", flNextPrimaryAttack, flNextSecondaryAttack);
                
                SetEntDataFloat(client, g_offsPlaybackRate, g_flMultiplier);
                SetEntDataFloat(client, g_offsNextPrimaryAttack, (flNextPrimaryAttack / g_flMultiplier) + gameTime);
                SetEntDataFloat(client, g_offsNextSecondaryAttack, (flNextSecondaryAttack / g_flMultiplier) + gameTime);
            }  
        }
        else
        {
            PrintToChatAll("INVALID WEAPON ENTITY");
        }
    }
}
still crashing the server when a player is spawned :/
Sil3nt Pr0digy is offline
Sil3nt Pr0digy
Member
Join Date: Mar 2011
Old 03-18-2011 , 04:28   Re: Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack
Reply With Quote #24

I would really appreciate some insight on how to access m_flCycle for a weapon, as is, the plugin simply crashes the server when a player tries to join a team :/
Sil3nt Pr0digy is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 03-18-2011 , 05:22   Re: Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack
Reply With Quote #25

Remote-debugging is always difficult.


Maybe youre not getting the right offset. Try FindEntProp...
Spam Debug Prints about every local variable, before every command so you know exactly which line crashes and possibly why
AtomicStryker is offline
Sil3nt Pr0digy
Member
Join Date: Mar 2011
Old 03-18-2011 , 14:14   Re: Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack
Reply With Quote #26

Quote:
Originally Posted by AtomicStryker View Post
Remote-debugging is always difficult.


Maybe youre not getting the right offset. Try FindEntProp...
Spam Debug Prints about every local variable, before every command so you know exactly which line crashes and possibly why
I'm pretty sure I'm not getting the right offset, as "new weapon = GetEntProp(client, g_offsActiveWeapon, 4);" is what is crashing my server. I commented out that line, and sure enough, ran just fine. Whatever it is trying to do is not working at all :/
Sil3nt Pr0digy is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 03-18-2011 , 16:52   Re: Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack
Reply With Quote #27

Use GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon")


Are you using the API to find the functions you need?
AtomicStryker is offline
Sil3nt Pr0digy
Member
Join Date: Mar 2011
Old 03-19-2011 , 11:57   Re: Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack
Reply With Quote #28

Quote:
Originally Posted by AtomicStryker View Post
Use GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon")


Are you using the API to find the functions you need?
Yes I am, I will try GetEntPropEnt instead
Sil3nt Pr0digy is offline
Sil3nt Pr0digy
Member
Join Date: Mar 2011
Old 03-19-2011 , 12:16   Re: Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack
Reply With Quote #29

Quote:
Originally Posted by Sil3nt Pr0digy View Post
Yes I am, I will try GetEntPropEnt instead
Ok, I got the weapon entity now.

Now on to grabbing "m_flCycle". Using the earlier code gave me a constant 0.0000 which means I am still pulling the wrong animation data from it. So I tried switching to DT_ServerAnimationData instead of CBaseCombatWeapon, however, that is not what I want, at it returns invalid data.

I have went over the API many, many times, but I still do not have all of the functions memorized as of yet. I also have not done much work with complex offsets such as these yet.

I have done simple ones, like tweaking "m_flLaggedMovementValue" and "m_CollisionGroup", but none that directly relate to weapon entities and offsets such as those. So I'm kind of in unknown territory.
Sil3nt Pr0digy is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 03-19-2011 , 20:56   Re: Help Modifying Weapon Fire Rate Using m_flNextPrimaryAttack
Reply With Quote #30

GetEntPropFloat
AtomicStryker is offline
Reply



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 19:17.


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