Raised This Month: $51 Target: $400
 12% 

Solved Player attack only in air


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ShD3luxe
Member
Join Date: Aug 2019
Location: Localhost
Old 08-07-2019 , 20:16   Player attack only in air
Reply With Quote #1

Hi, I'm new to sourcemod. I'm trying to set the attack only from the air ( the player can't shoot when he is on the ground ) . I managed to block the attack when he is on the ground but I can't reset the nextattack when he is in air.
Here is what I have until now but is not working as expected. Can anybody help ?
Code:
#define FL_ONGROUND2    (FL_ONGROUND | FL_PARTIALGROUND | FL_INWATER | FL_CONVEYOR) 
public Action:OnPreThink(client)
{
	new iWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
        if( IsValidClient(client))
	{
		if(!is_user_in_air(client))
		{
			SetEntPropFloat(client, Prop_Send, "m_flNextAttack", GetGameTime() + 100.0); 
		}else{
			SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 0.0); // this is not working 
                       // how can I reset the next attack time ?
		}
	}
	return Plugin_Continue;
}
stock is_user_in_air(const any:client)
{
	if(!(GetEntityFlags(client) & FL_ONGROUND2))
		return true;
	
	return false;
}

Last edited by ShD3luxe; 08-08-2019 at 10:35. Reason: Solved
ShD3luxe is offline
lugui
Senior Member
Join Date: Feb 2016
Location: GetClientAbsOrigin();
Old 08-08-2019 , 07:49   Re: Player attack only in air
Reply With Quote #2

mybe somethinglike this(untested):
PHP Code:
public Action OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon

     if (
buttons IN_ATTACK)
          if (!(
GetEntityFlags(client) & FL_ONGROUND)) {
               
buttons &= ~IN_ATTACK;
          }  
    return 
Plugin_Continue

__________________
Add me for commissions!
Steam: [U:1:88621772]
Discord: lugui#0889
My Plugins
lugui is offline
farawayf
Senior Member
Join Date: Jan 2019
Old 08-08-2019 , 07:53   Re: Player attack only in air
Reply With Quote #3

do with onplayerruncmd. return plugin_handled if onground, return plugin_continue if air.
farawayf is offline
ShD3luxe
Member
Join Date: Aug 2019
Location: Localhost
Old 08-08-2019 , 10:34   Re: Player attack only in air
Reply With Quote #4

Thx, I solved this using another method. I hooked the PostThink then unhooked when the player is on the ground . Checked if the user is in air in PreThink and is working perfectly.
ShD3luxe 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 13:11.


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