Raised This Month: $ Target: $400
 0% 

[L4D2] how to check if an active weapon has deploy done and can fire?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
little_froy
Senior Member
Join Date: May 2021
Old 09-10-2024 , 02:54   [L4D2] how to check if an active weapon has deploy done and can fire?
Reply With Quote #1

for chainsaw we can use the netprop "m_iState (offset 6112)", but for other weapons?
little_froy is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 09-10-2024 , 11:52   Re: [L4D2] how to check if an active weapon has deploy done and can fire?
Reply With Quote #2

PHP Code:
#include <left4dhooks>
bool IsWeaponReadyToFire(int weapon)
{
    
float game_time GetGameTime();
    
float atk_time GetEntPropFloat(weaponProp_Send"m_flNextPrimaryAttack");
    
float interval atk_time game_time;

    static 
char weapon_name[32];
    
GetEntityClassname(weaponweapon_namesizeof(weapon_name));
    
float cycle L4D2_GetFloatWeaponAttribute(weapon_nameL4D2FWA_CycleTime);
    
bool is_ready_to_fire interval <= cycle;

    
// PrintToChatAll("%.2f %.2f %.2f %.2f %d", game_time, atk_time, interval, cycle, is_ready_to_fire);

    
return is_ready_to_fire;

If you just need to check whether a weapon is able to fire, this should work.
__________________

Last edited by Paimon; 09-10-2024 at 11:54.
Paimon is offline
little_froy
Senior Member
Join Date: May 2021
Old 09-10-2024 , 20:18   Re: [L4D2] how to check if an active weapon has deploy done and can fire?
Reply With Quote #3

Quote:
Originally Posted by Paimon View Post
PHP Code:
#include <left4dhooks>
bool IsWeaponReadyToFire(int weapon)
{
    
float game_time GetGameTime();
    
float atk_time GetEntPropFloat(weaponProp_Send"m_flNextPrimaryAttack");
    
float interval atk_time game_time;

    static 
char weapon_name[32];
    
GetEntityClassname(weaponweapon_namesizeof(weapon_name));
    
float cycle L4D2_GetFloatWeaponAttribute(weapon_nameL4D2FWA_CycleTime);
    
bool is_ready_to_fire interval <= cycle;

    
// PrintToChatAll("%.2f %.2f %.2f %.2f %d", game_time, atk_time, interval, cycle, is_ready_to_fire);

    
return is_ready_to_fire;

If you just need to check whether a weapon is able to fire, this should work.
thanks
little_froy is offline
Reply


Thread Tools
Display Modes

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 16:14.


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