Raised This Month: $32 Target: $400
 8% 

hp problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
generals
Senior Member
Join Date: Aug 2018
Old 01-04-2020 , 11:01   hp problem
Reply With Quote #1

hi

I have no idea how to make for one player with variable damage reduced by 40%. Can u tell me how?

I want do this work when player switch weapon to knife (for css)

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdkhooks>

new bool:adminabuser[MAXPLAYERS+1];

public 
OnClientPutInServer(client) {

    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamagePre);
}

public 
Action:OnTakeDamagePre(victim, &attacker, &inflictor, &Float:damage, &damagetype) {

    if (
victim && victim <= MAXPLAYERS) {
        if (
adminabuser[victim]) {
            
damage -= damage 0.4// Reduce damage by 40%
            
return Plugin_Changed;
        }
    }


Last edited by generals; 01-08-2020 at 05:27.
generals is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 01-04-2020 , 19:42   Re: Reduced Damage
Reply With Quote #2

If I understand correctly, you are saying you want the 40% reduction on knife only? Your code was close to what is needed. I assume it was copied from another plugin, given the admin abuser variable. Here you go:

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

public void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_OnTakeDamageEvent_OnTakeDamage);
}

public 
Action Event_OnTakeDamage(int victimint &attackerint &inflictorfloat &fDamageint &damagetypeint &weaponfloat a_fDmgForce[3], float a_fDmgPosition[3])
{
    
char sWeaponClass[20]; 
    
GetEntityClassname(inflictorsWeaponClasssizeof(sWeaponClass)); 
    if(
StrContains(sWeaponClass"knife"false) != -1)         //check if knife
    

        
fDamage *= 0.6;        //60% of original dmg (40% reduction)
        
return Plugin_Changed;
    }
    
    return 
Plugin_Continue;

__________________

Last edited by ThatOneGuy; 01-07-2020 at 21:06.
ThatOneGuy is offline
generals
Senior Member
Join Date: Aug 2018
Old 01-05-2020 , 08:36   Re: Reduced Damage
Reply With Quote #3

hi ..
Yes, you know exactly what I mean

compile error = i added :

PHP Code:
new bool:iWeapon
but damage don't reduced.. when i switch weapon to knife

Can't use this?

PHP Code:
public OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
}
public 
Action:OnWeaponSwitch(clientweapon
{
    
char WeaponName[32];
    
GetEdictClassname(weaponWeaponNamesizeof(WeaponName));
    if(!
StrEqual(WeaponName"weapon_knife"))
    {
        
//Some Codes
    
}

Edit:

i removed bool and fix this line But it didn't work again :

PHP Code:
    GetEntityClassname(weaponsWeaponClasssizeof(sWeaponClass)); 
when ct attack to terror: terror not die

but when t attack to ct: ct die without hp reduction 40%

Last edited by generals; 01-05-2020 at 12:22.
generals is offline
generals
Senior Member
Join Date: Aug 2018
Old 01-07-2020 , 19:24   Re: Reduced Damage
Reply With Quote #4

hi again

when i change this code and add inflictor to this :

PHP Code:
GetEntityClassname(inflictorsWeaponClasssizeof(sWeaponClass)); 
And I'll delete this line :

PHP Code:
if(StrContains(sWeaponClass"knife"false) != -1)         //check if knife 
plugin working .. But can't detect the knife.. I think the bet is wrong

Someone can help? this plugin very important for me

Last edited by generals; 01-07-2020 at 19:33.
generals is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 01-07-2020 , 21:15   Re: Reduced Damage
Reply With Quote #5

Recompile my updated post. The compile error you mention was a single word that needed changing. It should work just fine.

Side note: I apparently made a plugin that does similar to this and a bit more in the past:
https://forums.alliedmods.net/showthread.php?t=317685

Figure out what the 40% reduction is and set the following 4 variables accordingly:
HTML Code:
togknifedmg_reg_left        [left click knife]
togknifedmg_reg_right       [right click knife]
togknifedmg_back_left       [left click back stab]
togknifedmg_back_right      [right click back stab]
Moral of the story, consider doing a more thorough search of the forums prior to making requests.
__________________

Last edited by ThatOneGuy; 01-07-2020 at 21:16.
ThatOneGuy is offline
generals
Senior Member
Join Date: Aug 2018
Old 01-08-2020 , 03:56   Re: Reduced Damage
Reply With Quote #6

Brother, I think you don't understand me

I don't want to do less damage to the enemy when I get the knife

I want it when the knife is in my hand. The enemy will do me less damage by 40%

i searched of the forums before created this topic.. but I didn't find anything

Last edited by generals; 01-08-2020 at 04:01.
generals is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 01-08-2020 , 04:36   Re: Reduced Damage
Reply With Quote #7

Well you could hook OnTakeDamage in OnWeaponSwitch and if it's not a knife you unhook OnTakeDamage
Maybe is not 100% safe but try it.

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

public OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
}
public 
Action:OnWeaponSwitch(clientweapon
{
    
char WeaponName[32];
    
GetEdictClassname(weaponWeaponNamesizeof(WeaponName));
    if(
StrEqual(WeaponName"weapon_knife"false))
    {
        
SDKHook(clientSDKHook_OnTakeDamageEvent_OnTakeDamage);
    }
    else
    {
        
SDKUnhook(clientSDKHook_OnTakeDamageEvent_OnTakeDamage);
    }
}

public 
Action Event_OnTakeDamage(int victimint &attackerint &inflictorfloat &fDamageint &damagetypeint &weaponfloat a_fDmgForce[3], float a_fDmgPosition[3])
{
    
fDamage *= 0.6;        
    return 
Plugin_Changed;

__________________

Last edited by Marttt; 01-08-2020 at 04:36.
Marttt is offline
generals
Senior Member
Join Date: Aug 2018
Old 01-08-2020 , 05:13   Re: Reduced Damage
Reply With Quote #8

really thanks brother

its working

Last edited by generals; 01-08-2020 at 05:14.
generals is offline
OhHai
Junior Member
Join Date: Aug 2019
Old 01-08-2020 , 07:08   Re: Reduced Damage
Reply With Quote #9

Quote:
Originally Posted by Marttt View Post
Well you could hook OnTakeDamage in OnWeaponSwitch and if it's not a knife you unhook OnTakeDamage
Maybe is not 100% safe but try it.

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

public OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
}
public 
Action:OnWeaponSwitch(clientweapon
{
    
char WeaponName[32];
    
GetEdictClassname(weaponWeaponNamesizeof(WeaponName));
    if(
StrEqual(WeaponName"weapon_knife"false))
    {
        
SDKHook(clientSDKHook_OnTakeDamageEvent_OnTakeDamage);
    }
    else
    {
        
SDKUnhook(clientSDKHook_OnTakeDamageEvent_OnTakeDamage);
    }
}

public 
Action Event_OnTakeDamage(int victimint &attackerint &inflictorfloat &fDamageint &damagetypeint &weaponfloat a_fDmgForce[3], float a_fDmgPosition[3])
{
    
fDamage *= 0.6;        
    return 
Plugin_Changed;

So, you're hooking/unhooking SDKHook_OnTakeDamage every time a player switches weapons? Super sloppy.
OhHai is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 01-08-2020 , 07:13   Re: hp problem
Reply With Quote #10

Of course is not the best way to do it, as I said
Quote:
Maybe is not 100% safe
but there is a lot of worse plugin shared here in the forum

If you want to help, guide the user to a better way to do it instead of just blaming the code, which is not helpful.
__________________

Last edited by Marttt; 01-08-2020 at 19:49.
Marttt 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 02:52.


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