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

[L4D/L4D2] Heal Refuse


Post New Thread Reply   
 
Thread Tools Display Modes
Author
bullet28
Member
Join Date: Apr 2012
Plugin ID:
7033
Plugin Version:
2.0
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Allows you to deny someones first aid kit healing by pressing E
    Old 04-07-2020 , 17:29   [L4D/L4D2] Heal Refuse
    Reply With Quote #1

    No cvars. Video: https://youtu.be/5rce73OwE_o

    Updates history:
    08 April 2020: Fixes. Bots will be temporary blocked to deploy medkit after player refuse

    Thanks to Silvers for code advices.
    Attached Files
    File Type: sp Get Plugin or Get Source (lfd_healRefuse.sp - 532 views - 4.5 KB)
    File Type: smx lfd_healRefuse.smx (7.1 KB, 518 views)

    Last edited by bullet28; 04-08-2020 at 16:55.
    bullet28 is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 04-07-2020 , 23:30   Re: [L4D/L4D2] Heal Refuse
    Reply With Quote #2

    Restore previous flags, don't overwrite with something different:
    PHP Code:
    void giveItem(int client, const char[] weapon) {
        
    int flags GetCommandFlags("give");
        
    SetCommandFlags("give"flags & ~FCVAR_CHEAT);
        
    FakeClientCommand(client"give %s"weapon);
        
    SetCommandFlags("give"flags);



    You're also leaking entities:
    PHP Code:
    RemovePlayerItem(healeritem); // This only removes it, does not delete.
    AcceptEntityInput(item"Kill"); // Delete the entity because you're not reequiping 


    You should also be passing userids into timers and verifying they're correct, same with your other time:
    PHP Code:
        CreateTimer(0.1OnTimerCheckIfInterruptedGetClientUserId(healer));
    }

    public 
    Action OnTimerCheckIfInterrupted(Handle timerany healer) {
        
    healer GetClientOfUserId(healer);
        if (
    healer && healingTarget[healer] != 0) { 


    Also maybe add a longer timer for bots, it's not possible to stop them otherwise.
    __________________

    Last edited by Silvers; 04-07-2020 at 23:47.
    Silvers is offline
    bullet28
    Member
    Join Date: Apr 2012
    Old 04-08-2020 , 01:36   Re: [L4D/L4D2] Heal Refuse
    Reply With Quote #3

    Quote:
    Originally Posted by Silvers View Post
    Restore previous flags, don't overwrite with something different
    In fact this is real flags of 'give' command. I'm doing that way because I had very strange rare bug on my servers when every players was able to use 'give' console command. this bug remained working until the server reboot, so I come to conclusion that in some way one giveItem function copied flags before another instance of this function have not restored FCVAR_CHEAT flag. So every next call of this function was restoring 'broken' flags. I know that srcds is one-threaded and maybe it's sounds like bullshit, but after I changed my giveItem function to use this static flags this bug never happened again. However, I will do as you said for the public version of this plugin.

    Quote:
    Originally Posted by Silvers View Post
    You're also leaking entities
    Wow.. never knew that RemovePlayerItem isn't removing entity.. going to fix it in 10 plugins where I used this function

    Quote:
    Originally Posted by Silvers View Post
    CreateTimer(0.1, OnTimerCheckIfInterrupted, GetClientUserId(healer));
    Done.

    Quote:
    Originally Posted by Silvers View Post
    Also maybe add a longer timer for bots, it's not possible to stop them otherwise.
    I didn't get how longer timer will help to stop bots, they will continue to try heal until you have low health.. It's not really meant to support bots, they for sure has some behavior tree and we can't change their logic. At least I don't know any clear way to do this. If we block weapon switch for bots it's not a good decision as they probably will want to heal someone else, who won't to refuse healing (for example). I tried to do so and they started to repeatedly shoving me, it's shaking screen and stopping movement speed, very boring.. So I have blocked their weapon switch and shove for 10 sec, it's not ideal but at least you has a chance now to switch their attention to the shootout..

    Thank you for help!

    Last edited by bullet28; 04-08-2020 at 02:23.
    bullet28 is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 04-08-2020 , 06:21   Re: [L4D/L4D2] Heal Refuse
    Reply With Quote #4

    You're welcome for the help. Good plugin this has been needed for a long time and I hope more servers adopt it!

    Quote:
    Originally Posted by bullet28 View Post
    In fact this is real flags of 'give' command. I'm doing that way because I had very strange rare bug on my servers when every players was able to use 'give' console command.
    I guess this is because some other plugin on your server was not respecting the flags and also changing to the wrong ones. Maybe a conflict somewhere if two plugins changing at the same time (although as you said single thread and probably shouldn't happen). Another option might be to restore the flags you saved and add the cheat flag again SetCommandFlags("give", flags | FCVAR_CHEAT) just incase.

    Bots it's possible to memory patch when you need to block for X seconds and prevent them healing others but that's more complicated and maybe slightly buggy (I tried years ago and sometimes they just stood there with medkit in hand, but now I know more could probably find a better place to patch). Another solution might be with Left4DHooks to block them healing someone (but requiring more plugins just for this is annoying, could be optional anyway if Left4DHooks was detected then enable blocking).
    __________________
    Silvers is offline
    xZk
    Senior Member
    Join Date: Nov 2017
    Location: cl
    Old 04-08-2020 , 12:39   Re: [L4D/L4D2] Heal Refuse
    Reply With Quote #5

    Nice idea!, regarding canceling healing, perhaps this can be helpful in not removing the player's kit
    PHP Code:
    public Action OnTimerCheckIfInterrupted(Handle timerany healerID) {
        
    int healer GetClientOfUserId(healerID);
        if (
    healer && healingTarget[healer] != 0) {
            if (
    isPlayerAliveSurvivor(healer)) {
                
    int item GetPlayerWeaponSlot(healer3);
                
    int activeWeapon GetEntPropEnt(healerProp_Send"m_hActiveWeapon");
                if (
    item != -&& item == activeWeapon) {
                    
    char classname[32];
                    
    GetEntityClassname(itemclassnamesizeof classname);
                    if (
    StrEqual(classname"weapon_first_aid_kit")) {
                        
    //RemovePlayerItem(healer, item);
                        //AcceptEntityInput(item, "Kill");
                        //giveItem(healer, "first_aid_kit");
                        
    int target GetEntPropEnt(healerProp_Send"m_useActionTarget");
                        if(
    isPlayerAliveSurvivor(target)){
                            
    SetEntPropEnt(targetProp_Send"m_useActionOwner"0);
                            
    SetEntPropEnt(targetProp_Send"m_useActionTarget"0);
                            
    SetEntProp(targetProp_Send"m_iCurrentUseAction"0);
                        }
                        
    SetEntPropEnt(healer,  Prop_Send"m_useActionTarget"0);
                        
    SetEntPropEnt(healerProp_Send"m_useActionOwner"0);
                        
    SetEntProp(healerProp_Send"m_iCurrentUseAction"0);
                        
                    }
                }
            }
        }

    xZk is offline
    Lux
    Veteran Member
    Join Date: Jan 2015
    Location: Cat
    Old 04-08-2020 , 12:58   Re: [L4D/L4D2] Heal Refuse
    Reply With Quote #6

    Quote:
    Originally Posted by xZk View Post
    Nice idea!, regarding canceling healing, perhaps this can be helpful in not removing the player's kit
    PHP Code:
    public Action OnTimerCheckIfInterrupted(Handle timerany healerID) {
        
    int healer GetClientOfUserId(healerID);
        if (
    healer && healingTarget[healer] != 0) {
            if (
    isPlayerAliveSurvivor(healer)) {
                
    int item GetPlayerWeaponSlot(healer3);
                
    int activeWeapon GetEntPropEnt(healerProp_Send"m_hActiveWeapon");
                if (
    item != -&& item == activeWeapon) {
                    
    char classname[32];
                    
    GetEntityClassname(itemclassnamesizeof classname);
                    if (
    StrEqual(classname"weapon_first_aid_kit")) {
                        
    //RemovePlayerItem(healer, item);
                        //AcceptEntityInput(item, "Kill");
                        //giveItem(healer, "first_aid_kit");
                        
    int target GetEntPropEnt(healerProp_Send"m_useActionTarget");
                        if(
    isPlayerAliveSurvivor(target)){
                            
    SetEntPropEnt(targetProp_Send"m_useActionOwner"0);
                            
    SetEntPropEnt(targetProp_Send"m_useActionTarget"0);
                            
    SetEntProp(targetProp_Send"m_iCurrentUseAction"0);
                        }
                        
    SetEntPropEnt(healer,  Prop_Send"m_useActionTarget"0);
                        
    SetEntPropEnt(healerProp_Send"m_useActionOwner"0);
                        
    SetEntProp(healerProp_Send"m_iCurrentUseAction"0);
                        
                    }
                }
            }
        }

    Holy that's a monstrous code snip to me O.O
    __________________
    Connect
    My Plugins: KlickME
    [My GitHub]

    Commission me for L4D
    Lux is offline
    bullet28
    Member
    Join Date: Apr 2012
    Old 04-08-2020 , 13:33   Re: [L4D/L4D2] Heal Refuse
    Reply With Quote #7

    Quote:
    Originally Posted by xZk View Post
    perhaps this can be helpful in not removing the player's kit
    Tried both 0 and -1, it's crashing server every time this code executed

    Last edited by bullet28; 04-08-2020 at 13:33.
    bullet28 is offline
    sorallll
    Senior Member
    Join Date: Oct 2018
    Old 04-08-2020 , 13:39   Re: [L4D/L4D2] Heal Refuse
    Reply With Quote #8

    https://forums.alliedmods.net/showpo...41&postcount=4
    SDKCall(sdkStopBeingRevievd, healer, true);
    Can canceling healing
    My English is bad
    sorallll is offline
    bullet28
    Member
    Join Date: Apr 2012
    Old 04-08-2020 , 14:00   Re: [L4D/L4D2] Heal Refuse
    Reply With Quote #9

    Quote:
    Originally Posted by sorallll View Post
    Can canceling healing
    It does, but bot immediately tries to heal again. "lastinv" doing the same result.
    UPD: sorry, I was wrong - lastinv affects only real players

    Last edited by bullet28; 04-08-2020 at 15:58.
    bullet28 is offline
    xZk
    Senior Member
    Join Date: Nov 2017
    Location: cl
    Old 04-08-2020 , 14:07   Re: [L4D/L4D2] Heal Refuse
    Reply With Quote #10

    Quote:
    Originally Posted by bullet28 View Post
    Tried both 0 and -1, it's crashing server every time this code executed
    it's true i should try that before sorry :s, but now try this and it seems to work fine:
    PHP Code:
    public Action OnTimerCheckIfInterrupted(Handle timerany healerID) {
        
    int healer GetClientOfUserId(healerID);
        if (
    healer && healingTarget[healer] != 0) {
            if (
    isPlayerAliveSurvivor(healer)) {
                
    int item GetPlayerWeaponSlot(healer3);
                
    int activeWeapon GetEntPropEnt(healerProp_Send"m_hActiveWeapon");
                if (
    item != -&& item == activeWeapon) {
                    
    char classname[32];
                    
    GetEntityClassname(itemclassnamesizeof classname);
                    if (
    StrEqual(classname"weapon_first_aid_kit")) {
                        
    //RemovePlayerItem(healer, item);
                        //AcceptEntityInput(item, "Kill");
                        //giveItem(healer, "first_aid_kit");
                        
    int target GetEntPropEnt(healerProp_Send"m_useActionTarget");
                        if(
    isPlayerAliveSurvivor(target)){
                            
    SetEntProp(targetProp_Send"m_iCurrentUseAction"0);
                        }
                        
    SetEntProp(healerProp_Send"m_iCurrentUseAction"0);
                        
                    }
                }
            }
        }

    xZk 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 09:37.


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