AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [L4D/L4D2] Heal Refuse (https://forums.alliedmods.net/showthread.php?t=322920)

bullet28 04-07-2020 17:29

[L4D/L4D2] Heal Refuse
 
2 Attachment(s)
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.

Silvers 04-07-2020 23:30

Re: [L4D/L4D2] Heal Refuse
 
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.

bullet28 04-08-2020 01:36

Re: [L4D/L4D2] Heal Refuse
 
Quote:

Originally Posted by Silvers (Post 2691614)
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 (Post 2691614)
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 :D

Quote:

Originally Posted by Silvers (Post 2691614)
CreateTimer(0.1, OnTimerCheckIfInterrupted, GetClientUserId(healer));

Done.

Quote:

Originally Posted by Silvers (Post 2691614)
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!

Silvers 04-08-2020 06:21

Re: [L4D/L4D2] Heal Refuse
 
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 (Post 2691622)
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).

xZk 04-08-2020 12:39

Re: [L4D/L4D2] Heal Refuse
 
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);
                    
                }
            }
        }
    }



Lux 04-08-2020 12:58

Re: [L4D/L4D2] Heal Refuse
 
Quote:

Originally Posted by xZk (Post 2691750)
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

bullet28 04-08-2020 13:33

Re: [L4D/L4D2] Heal Refuse
 
Quote:

Originally Posted by xZk (Post 2691750)
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

sorallll 04-08-2020 13:39

Re: [L4D/L4D2] Heal Refuse
 
https://forums.alliedmods.net/showpo...41&postcount=4
SDKCall(sdkStopBeingRevievd, healer, true);
Can canceling healing
My English is bad

bullet28 04-08-2020 14:00

Re: [L4D/L4D2] Heal Refuse
 
Quote:

Originally Posted by sorallll (Post 2691763)
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

xZk 04-08-2020 14:07

Re: [L4D/L4D2] Heal Refuse
 
Quote:

Originally Posted by bullet28 (Post 2691762)
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);
                    
                }
            }
        }
    }




All times are GMT -4. The time now is 08:29.

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