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

Disable blood animation.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-19-2021 , 17:54   Disable blood animation.
Reply With Quote #1

Hi there

I'm trying to help someone out with the following. I've got this code, but it's only working on the first hit. Also, the animation isn't removed, the color just turns black.

PHP Code:
public PreDisableBlood(id)
{
    if(
g_bUnderstabbed[id])
    {
        
client_print(0print_chat"Disable blood animation");
        
SetHamReturnInteger(-1);
        
g_bUnderstabbed[id] = false;
        return 
HAM_HANDLED;
    }
    return 
HAM_SUPERCEDE;

I'll just leave the entire code for any one who needs more information.

PHP Code:
/* Sublime AMXX Editor v2.2 */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <hamsandwich>

#define PLUGIN  "Anti UnderStab"
#define VERSION "1.0"
#define AUTHOR  "NapoleoN#"

#if !defined DMG_GRENADE
        #define DMG_GRENADE ( 1 << 24 )
#endif

#if !defined MAX_PLAYERS
        
const MAX_PLAYERS 32;
#endif

#define g_iIsPlayer(%0) (1 <= (%0) <= MAX_PLAYERS)

new bool:g_bUnderstabbed[MAX_PLAYERS 1];

new 
g_pYOffset;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);

    
RegisterHam(Ham_TakeDamage"player""PreTakeDamage");
    
RegisterHam(Ham_BloodColor"player""PreDisableBlood");

    
g_pYOffset register_cvar("aus_offset""20");
}

public 
PreTakeDamage(iVictimiInflictoriAttackerFloat:fDamageiDmgBits)
{
    if(!
is_user_alive(iVictim) || !is_user_alive(iAttacker) || !g_iIsPlayer(iAttacker) || !g_iIsPlayer(iVictim) || iDmgBits    DMG_GRENADE)
    {
        return 
HAM_IGNORED;
    }

    if(
cs_get_user_weapon(iAttacker) == CSW_KNIFE && cs_get_user_team(iAttacker) == CS_TEAM_CT && cs_get_user_team(iVictim) == CS_TEAM_T)
    {
        new 
iAttOrigin[3];
        new 
iVicOrigin[3];

        
get_user_origin(iAttackeriAttOrigin);
        
get_user_origin(iVictimiVicOrigin);

        
iAttOrigin[2] += get_pcvar_num(g_pYOffset);

        if(
iVicOrigin[2] > iAttOrigin[2])
        {
            
g_bUnderstabbed[iVictim] = true;
            return 
HAM_SUPERCEDE;
        }
    }
    return 
HAM_IGNORED;
}

public 
PreDisableBlood(id)
{
    if(
g_bUnderstabbed[id])
    {
        
client_print(0print_chat"Disable blood animation");
        
SetHamReturnInteger(-1);
        
g_bUnderstabbed[id] = false;
        return 
HAM_HANDLED;
    }
    return 
HAM_SUPERCEDE;

__________________

Last edited by Napoleon_be; 09-19-2021 at 18:14.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 09-20-2021 , 04:50   Re: Disable blood animation.
Reply With Quote #2

Maybe this will help

PHP Code:
#include <amxmodx>

]public plugin_init() {
    
register_plugin("No Blood" ,"0.1""ConnorMcLeod")
    
register_message(SVC_TEMPENTITY"blood_message")
}

public 
blood_message() {
    if(!
get_pcvar_num(noblood))
        return 
PLUGIN_CONTINUE

    
static arg1 arg1 get_msg_arg_int(1)

    if(
arg1 == TE_BLOODSPRITE || arg1 == TE_BLOODSTREAM || arg1 == TE_BLOOD)
        return 
PLUGIN_HANDLED

    
return PLUGIN_CONTINUE

Not sure what you mean by blood animation though.
__________________
My plugin:

Last edited by Celena Luna; 09-20-2021 at 04:51.
Celena Luna is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 09-20-2021 , 08:08   Re: Disable blood animation.
Reply With Quote #3

You switched the return values:

Code:
public PreDisableBlood(id) {     if(g_bUnderstabbed[id])     {         client_print(0, print_chat, "Disable blood animation");         SetHamReturnInteger(-1);         g_bUnderstabbed[id] = false;
        return HAM_HANDLED;
    }
    return HAM_SUPERCEDE;
}

Code:
public PreDisableBlood(id) {     if(g_bUnderstabbed[id])     {         client_print(0, print_chat, "Disable blood animation");         SetHamReturnInteger(-1);         g_bUnderstabbed[id] = false;
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORE;
}
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-20-2021 , 19:38   Re: Disable blood animation.
Reply With Quote #4

Quote:
Originally Posted by Shadows Adi View Post
You switched the return values:

Code:
public PreDisableBlood(id) {     if(g_bUnderstabbed[id])     {         client_print(0, print_chat, "Disable blood animation");         SetHamReturnInteger(-1);         g_bUnderstabbed[id] = false;
        return HAM_HANDLED;
    }
    return HAM_SUPERCEDE;
}

Code:
public PreDisableBlood(id) {     if(g_bUnderstabbed[id])     {         client_print(0, print_chat, "Disable blood animation");         SetHamReturnInteger(-1);         g_bUnderstabbed[id] = false;
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORE;
}
Thanks, i'll try this tomorrow. I misread some things on the wiki.

Also, i realized this part:
Code:
Disabling Hooks
Similar to how FakeMeta allows for unregistering of hooks with unregister_forward(), HamSandwich will allow you to disable and enable hooks whenever you want.

The RegisterHam() function will return a handle (tagged with HamHook). You can then make subsequent calls to DisableHamForward() and EnableHamForward() with the handle to stop it from forwarding, or enable its forwards again.
Would this be an option to use? The basic idea is to disable the blood animation whenever damage has been ignored by the same plugin. If so, could someone provide me an example of how i could make this work? In my opinion, this would be the right call.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 09-21-2021 , 07:31   Re: Disable blood animation.
Reply With Quote #5

Quote:
Originally Posted by Napoleon_be View Post
Also, i realized this part:
Code:
Disabling Hooks
Similar to how FakeMeta allows for unregistering of hooks with unregister_forward(), HamSandwich will allow you to disable and enable hooks whenever you want.

The RegisterHam() function will return a handle (tagged with HamHook). You can then make subsequent calls to DisableHamForward() and EnableHamForward() with the handle to stop it from forwarding, or enable its forwards again.
Would this be an option to use? The basic idea is to disable the blood animation whenever damage has been ignored by the same plugin. If so, could someone provide me an example of how i could make this work? In my opinion, this would be the right call.
No, disabling and enabling the hook, just stops the hook from calling.
Example:
You hook Ham_Spawn with RegisterHam. In return, you get a unique index for that hook. You can enable or disable that hook if a boolean is true or false.
If the boolean is true, you could enable the hook and at next player spawn it will be called, otherwise, you could disable the hook and at next player spawn it won't be called.

P.S.: It won't stop the function Ham_Spawn from being called, only your hook.

If you didn't understood, I will leave a code example later.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 09-21-2021 , 10:12   Re: Disable blood animation.
Reply With Quote #6

Stopping blood on individual stab basis but leaving it on otherwise for all other 'hits'?

PHP Code:
#!/bin/sh
echo "violence_ablood 0;violence_agibs 0;violence_hblood 0;violence_hgibs 0;rem spinx was here!" >> server.cfg 
When I saw title I immediately was wondering why the CVARs are not being utilized otherwise.
__________________
DJEarthQuake 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 01:24.


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