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

[SOLVED][TF2] Block Grappling hook when player stunned


Post New Thread Reply   
 
Thread Tools Display Modes
Research
SourceMod Donor
Join Date: Nov 2011
Old 05-07-2015 , 11:18   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #11

Quote:
Originally Posted by Chdata View Post
You could set m_flNextPrimaryAttack during OnWeaponSwitch, the weapon parameter is the weapon you switched too. If that weapon is the grappling hook (check classname) then set nextattack then. you don't need weaponcanuse.
check TF2_OnConditionAdded and TF2_OnConditionRemoved is nice idea but I want finish this code :s sorry for rude.
I delete WeaponCanUse part and put m_flNextPrimaryAttack in OnWeaponSwitch. did I understand correctly?

Code:
public Action:OnWeaponSwitch(client, weapon)
{    
    new String:gWeapon[32];
    if(!IsValidClient(client) || !IsValidEdict(weapon) || !IsValidEntity(weapon) || !GetEntityClassname(weapon, gWeapon, sizeof(gWeapon)))
    {
        return Plugin_Continue;
    }
    GetEdictClassname(weapon, gWeapon, sizeof(gWeapon));
    
    if(TF2_IsPlayerInCondition(client, TFCond_Dazed))
    {
        if(StrEqual(gWeapon, "tf_weapon_grapplinghook"))
        {
            SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", 99999.0);
            return Plugin_Handled;
        }
    }
    return Plugin_Continue;
}
Research is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 05-07-2015 , 13:35   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #12

Quote:
Originally Posted by Research View Post
check TF2_OnConditionAdded and TF2_OnConditionRemoved is nice idea but I want finish this code :s sorry for rude.
I delete WeaponCanUse part and put m_flNextPrimaryAttack in OnWeaponSwitch. did I understand correctly?

Code:
public Action:OnWeaponSwitch(client, weapon)
{    
    new String:gWeapon[32];
    if(!IsValidClient(client) || !IsValidEdict(weapon) || !IsValidEntity(weapon) || !GetEntityClassname(weapon, gWeapon, sizeof(gWeapon)))
    {
        return Plugin_Continue;
    }
    GetEdictClassname(weapon, gWeapon, sizeof(gWeapon));
    
    if(TF2_IsPlayerInCondition(client, TFCond_Dazed))
    {
        if(StrEqual(gWeapon, "tf_weapon_grapplinghook"))
        {
            SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", 99999.0);
            return Plugin_Handled;
        }
    }
    return Plugin_Continue;
}
No No No

Who told you that you can set the value you need actual game time + block lenght in s

For example SetEntPropFloat(KnifeSlot, Prop_Send, "m_flNextPrimaryAttack", GetGameTime() + 0.5);

Also you could use the lenght of stun condition instead of hardcoding time
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player

Last edited by Michalplyoutube; 05-07-2015 at 13:36.
Michalplyoutube is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 05-07-2015 , 14:40   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #13

99999.0 or 27 hours is just fine for blocking attacks. In TF2 you shouldn't be running the same map for more than 4 hours or it will start to lag obscenely and everyone will leave. If you want to be extra sure, use 999999.0 which would be 11 days.

How is he supposed to get the duration of the stun condition? If there's actually a way to do that then yes, it'd be better to set nextattack to GetGameTime()+x instead of reseting it when the condition is removed.
__________________
Chdata is offline
Research
SourceMod Donor
Join Date: Nov 2011
Old 05-07-2015 , 20:55   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #14

my rage_stun ability maximum duration is 10 sec so I think over 10 sec is not bad :s

so, how about this? is it correct?

Code:
public Action:OnWeaponSwitch(client, weapon)
{    
    new String:gWeapon[32];
    if(!IsValidClient(client) || !IsValidEdict(weapon) || !IsValidEntity(weapon) || !GetEntityClassname(weapon, gWeapon, sizeof(gWeapon)))
    {
        return Plugin_Continue;
    }
    GetEdictClassname(weapon, gWeapon, sizeof(gWeapon));
    
    if(TF2_IsPlayerInCondition(client, TFCond_Dazed))
    {
        if(StrEqual(gWeapon, "tf_weapon_grapplinghook"))
        {
            SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", GetGameTime() + 12.0);
            return Plugin_Handled;
        }
    }
    return Plugin_Continue;
}
Research is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 05-07-2015 , 22:54   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #15

You should use TF2_OnConditionAdded instead
__________________
Chdata is offline
Research
SourceMod Donor
Join Date: Nov 2011
Old 05-08-2015 , 00:08   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #16

sorry I can't understand it.
you mean like this?

Code:
public Action:OnWeaponSwitch(client, weapon)
{    
    new String:gWeapon[32];
    if(!IsValidClient(client) || !IsValidEdict(weapon) || !IsValidEntity(weapon) || !GetEntityClassname(weapon, gWeapon, sizeof(gWeapon)))
    {
        return Plugin_Continue;
    }
    GetEdictClassname(weapon, gWeapon, sizeof(gWeapon));
    
    if(TF2_IsPlayerInCondition(client, TFCond_Dazed))
    {
        if(StrEqual(gWeapon, "tf_weapon_grapplinghook"))
        {
            return Plugin_Handled;
        }
    }
    return Plugin_Continue;
}
 
public TF2_OnConditionAdded(client, TFCond:condition)
{
   if(GetClientTeam(client)==TFTeam_Red && condition==TFCond_Dazed)
   {
      SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", GetGameTime() + 12.0);
   }
}
 
public TF2_OnConditionRemoved(client, TFCond:condition)
{
   if(GetClientTeam(client)==TFTeam_Red && condition==TFCond_Dazed)
   {
      SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", 0.0);
   }
}

Last edited by Research; 05-08-2015 at 00:09.
Research is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 05-08-2015 , 06:55   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #17

Quote:
Originally Posted by Research View Post
sorry I can't understand it.
you mean like this?

Code:
public Action:OnWeaponSwitch(client, weapon)
{    
    new String:gWeapon[32];
    if(!IsValidClient(client) || !IsValidEdict(weapon) || !IsValidEntity(weapon) || !GetEntityClassname(weapon, gWeapon, sizeof(gWeapon)))
    {
        return Plugin_Continue;
    }
    GetEdictClassname(weapon, gWeapon, sizeof(gWeapon));
    
    if(TF2_IsPlayerInCondition(client, TFCond_Dazed))
    {
        if(StrEqual(gWeapon, "tf_weapon_grapplinghook"))
        {
            return Plugin_Handled;
        }
    }
    return Plugin_Continue;
}
 
public TF2_OnConditionAdded(client, TFCond:condition)
{
   if(GetClientTeam(client)==TFTeam_Red && condition==TFCond_Dazed)
   {
      SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", GetGameTime() + 12.0);
   }
}
 
public TF2_OnConditionRemoved(client, TFCond:condition)
{
   if(GetClientTeam(client)==TFTeam_Red && condition==TFCond_Dazed)
   {
      SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", 0.0);
   }
}
You don't need oncond removed since the primary attack delay will end by the time of 12s by itself

Also more simple code

Try to use addcond 41 Cannot switch away from melee weapon

Set thier weapon on melee if it wouldn't work and restore to last weapons active after stun end
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player

Last edited by Michalplyoutube; 05-08-2015 at 06:57.
Michalplyoutube is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 05-08-2015 , 09:17   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #18

doing that melee thing is even more work... and not what he asked for anyway.

The weapon switch check is entirely unnecessary towards you goal, as well as the onconditionremoved like michael said.

PHP Code:
#include <sourcemod>
#include <tf2_stocks>

// TF2 Weapon Loadout Slots
enum
{
    
TFWeaponSlot_DisguiseKit 3,
    
TFWeaponSlot_Construction 3,
    
TFWeaponSlot_Watch 4,
    
TFWeaponSlot_Destruction 4,
    
TFWeaponSlot_PDA 5,           // What?
    
TFWeaponSlot_Grapple 5
}

public 
TF2_OnConditionAdded(clientTFCond:condition)
{
   if(
GetClientTeam(client)==_:TFTeam_Red && condition==TFCond_Dazed)
   {
      new 
iHook GetPlayerWeaponSlot(clientTFWeaponSlot_Grapple);
      if (
iHook != -1SetEntPropFloat(iHookProp_Send"m_flNextPrimaryAttack"GetGameTime() + 12.0);
   }

here ya go, you can probably compile this script as is and it'll do what you want.
__________________

Last edited by Chdata; 05-08-2015 at 09:19.
Chdata is offline
Research
SourceMod Donor
Join Date: Nov 2011
Old 05-08-2015 , 09:46   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #19

Quote:
Originally Posted by Chdata View Post
doing that melee thing is even more work... and not what he asked for anyway.

The weapon switch check is entirely unnecessary towards you goal, as well as the onconditionremoved like michael said.

PHP Code:
#include <sourcemod>
#include <tf2_stocks>

// TF2 Weapon Loadout Slots
enum
{
    
TFWeaponSlot_DisguiseKit 3,
    
TFWeaponSlot_Construction 3,
    
TFWeaponSlot_Watch 4,
    
TFWeaponSlot_Destruction 4,
    
TFWeaponSlot_PDA 5,           // What?
    
TFWeaponSlot_Grapple 5
}

public 
TF2_OnConditionAdded(clientTFCond:condition)
{
   if(
GetClientTeam(client)==_:TFTeam_Red && condition==TFCond_Dazed)
   {
      new 
iHook GetPlayerWeaponSlot(clientTFWeaponSlot_Grapple);
      if (
iHook != -1SetEntPropFloat(iHookProp_Send"m_flNextPrimaryAttack"GetGameTime() + 12.0);
   }

here ya go, you can probably compile this script as is and it'll do what you want.
Wait, grappling hook have own slot name? I trying to check grappling hook item number in onconditionadded :/
Anyway, Thanks for code!
Research is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 05-08-2015 , 10:00   Re: [SOLVED][TF2] Block Grappling hook when player stunned
Reply With Quote #20

grappling hooks are a weapon in a weapons lot
__________________
Chdata 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:04.


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