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

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Research
SourceMod Donor
Join Date: Nov 2011
Old 05-05-2015 , 00:52   [SOLVED][TF2] Block Grappling hook when player stunned
Reply With Quote #1

I want if player get stun(TF2_StunPlayer), block they action slot items
so make this code:

Code:
AddCommandListener(OnUseGrapplingHook, "use_action_slot_item");
    AddCommandListener(OnUseGrapplingHook, "+use_action_slot_item");

public Action:OnUseGrapplingHook(client, const String:command[], args)
{
    if(!IsValidClient(client))
    {
        return Plugin_Continue;
    }
    if(!IsPlayerAlive(client))
    {
        return Plugin_Continue;
    }
    if(IsBoss(client))
    {
        return Plugin_Continue;
    }
    if(GetEntProp(client, Prop_Send, "m_iStunFlags")!=TF_STUNFLAGS_GHOSTSCARE)
    {
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
but it's not working :/

Last edited by Research; 05-08-2015 at 09:46. Reason: Ok, Done. Thanks Chdata!
Research is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 05-05-2015 , 08:53   Re: [TF2] How can I check TF2_StunPlayer?
Reply With Quote #2

tfcond_dazed
__________________
Chdata is offline
Research
SourceMod Donor
Join Date: Nov 2011
Old 05-05-2015 , 10:07   Re: [TF2] How can I check TF2_StunPlayer?
Reply With Quote #3

Quote:
Originally Posted by Chdata View Post
tfcond_dazed
Thanks for answer but player still shot grappling hooks :s
is this code have problem?

Code:
AddCommandListener(OnUseGrapplingHook, "use_action_slot_item");
AddCommandListener(OnUseGrapplingHook, "+use_action_slot_item");
AddCommandListener(OnUseGrapplingHook, "use_action_slot_item_server");
AddCommandListener(OnUseGrapplingHook, "+use_action_slot_item_server");

public Action:OnUseGrapplingHook(client, const String:command[], args)
{
    if(!IsValidClient(client))
    {
        return Plugin_Continue;
    }
    if(!IsPlayerAlive(client))
    {
        return Plugin_Continue;
    }
    if(IsBoss(client))
    {
        return Plugin_Continue;
    }
    if(!TF2_IsPlayerInCondition(client, TFCond_Dazed))
    {
        return Plugin_Continue;
    }
    return Plugin_Handled;
}
Research is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 05-05-2015 , 10:56   Re: [TF2] How can I check TF2_StunPlayer?
Reply With Quote #4

can't the hook be used with +attack or something as well

then you'd need to block IN_ATTACK

you could also try setting

m_flNextPrimaryAttack

instead of dealing with all of this

to prevent switching to the grapple hook at all, you could use a OnWeaponSwitch sdkhook

or remove their grappling hook


You might also want to add

PrintToChatAll("floseogseg");

to make sure that this code is even running, and/or remove all of the checks and make the callback just return Plugin_Handled to see if that even blocks grapple hook in the first place.
__________________
Chdata is offline
Research
SourceMod Donor
Join Date: Nov 2011
Old 05-06-2015 , 07:16   Re: [TF2] How can I check TF2_StunPlayer?
Reply With Quote #5

AddCommandListener is not working(my script skill is bad, maybe that's the problem :/)
so I change the way - OnWeaponSwitch

Code:
public OnClientPutInServer(client) //of course OnClientPutInServer have more code but I think that part is not need write in here :s
{
    SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch);
}

public Action:OnWeaponSwitch(client, weapon)
{
    new String:gWeapon[32];
    GetEdictClassname(weapon, gWeapon, sizeof(gWeapon));

    if(TF2_IsPlayerInCondition(client, TFCond_Dazed))
    {
        if(StrEqual(gWeapon, "tf_weapon_grapplinghook"))
        {
            return Plugin_Handled;
        }
    }
    return Plugin_Continue;
}
and it's working! ...in this time. maybe it need more test.
Chdata, thanks for answer!
Research is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 05-06-2015 , 09:40   Re: [SOLVED][TF2] Block Grappling hook when player stunned
Reply With Quote #6

What if they already have the weapon equipped?

You'll need m_flNextPrimaryAttack to block that.
__________________
Chdata is offline
Research
SourceMod Donor
Join Date: Nov 2011
Old 05-06-2015 , 10:57   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #7

then it's not solved. I edit this thread name
I can't find enough example for m_flNextPrimaryAttack :s
is this work?

Code:
public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch);
    SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
}

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

public Action:WeaponCanUse(client, weapon)
{
    new String:gpWeapon[32];
    GetEdictClassname(weapon, gpWeapon, sizeof(gpWeapon));
    if(!IsValidClient(client) || !IsValidEdict(weapon))
    {
        return Plugin_Continue;
    }
    
    if(TF2_IsPlayerInCondition(client, TFCond_Dazed))
    {
        if(StrEqual(gpWeapon, "tf_weapon_grapplinghook"))
        {
            SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", 99999.0);
        }
    }
    return Plugin_Continue;
}
error appeared when I not add WeaponCanUse part:
Code:
[SM] Native "GetEdictClassname" reported: Invalid edict (-1 - -1)
so I add if(!IsValidClient(client) || !IsValidEdict(weapon)) check. is this working?

too many question here :/ sorry

Last edited by Research; 05-06-2015 at 11:13. Reason: [SM] Native "GetEdictClassname" reported: Invalid edict (-1 - -1) //ohhhhh
Research is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 05-06-2015 , 14:28   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #8

check isvalidedict before you getedictclassname

possibly use isvalidentity / getentityclassname? idk
__________________
Chdata is offline
Research
SourceMod Donor
Join Date: Nov 2011
Old 05-06-2015 , 21:46   Re: [TF2] Block Grappling hook when player stunned
Reply With Quote #9

hmm. how about this?

Code:
public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch);
    SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
}

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 Action:WeaponCanUse(client, weapon)
{
    new String:gpWeapon[32];
    if(!IsValidClient(client) || !IsValidEdict(weapon) || !IsValidEntity(weapon) || !GetEntityClassname(weapon, gpWeapon, sizeof(gpWeapon)))
    {
        return Plugin_Continue;
    }
    GetEdictClassname(weapon, gpWeapon, sizeof(gpWeapon));
    
    if(TF2_IsPlayerInCondition(client, TFCond_Dazed))
    {
        if(StrEqual(gpWeapon, "tf_weapon_grapplinghook"))
        {
            SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", 99999.0);
        }
    }
    return Plugin_Continue;
}

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

if weaponcanuse fires in tf2 then maybe, dunno myself.

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.

If you only want to block someone from grappling while they are stunned, and allow them to use it when not stun, then you should use TF2_OnConditionAdded and TF2_OnConditionRemoved to set/reset m_flNextPrimaryAttack. Setting it to 0.0 will work to allow them to use it again.
__________________

Last edited by Chdata; 05-07-2015 at 09:04.
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 20:11.


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