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

Limit amount of damage per enemy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ecca
Sexy Santa
Join Date: Jan 2011
Old 04-20-2014 , 16:57   Limit amount of damage per enemy
Reply With Quote #1

So basically i want to limit the damage you can do to players , you can not do damage over their health or more. Examples my be easier
  1. Player has 100 damage, you can do max 100 damage on him no more
  2. Player has 30 hp , you can not do more than 30

I tried to hook both player_hurt and OnTakeDamage with sdkhooks but it seems like if you don't 1 kill players the limit will exceed 100.

PHP Code:
HookEvent("player_hurt"PlayerHurtCallback);

public 
Action:PlayerHurtCallback(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    new 
damage GetEventInt(event"dmg_health");
    
    if(
ValidClient(victim) && ValidClient(attacker) && (victim != attacker))
    {
        new 
clienthealth GetClientHealth(victim);
        new 
realhealth clienthealth damage;
        
        if (
realhealth damage )
        {
            
PrintToChatAll("Damage on %N: %d"victimrealhealth);
        }
    }

but both fires to late , do i need to store the players health on hit and then check against that ?
__________________
ecca is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 04-20-2014 , 17:40   Re: Limit amount of damage per enemy
Reply With Quote #2

EventHookMode_Pre ?
__________________
Pelipoika is offline
Internet Bully
Member
Join Date: Apr 2014
Old 04-20-2014 , 17:48   Re: Limit amount of damage per enemy
Reply With Quote #3

PHP Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotypehitboxhitgroup)

    if(
ValidClient(victim) && ValidClient(attacker) && (victim != attacker)) 
    { 
        if (
damage GetClientHealth(victim)) 
        { 
            
damage GetClientHealth(victim);
            return 
Plugin_Changed;
        } 
    } 
    return 
Plugin_Continue;


public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);


Last edited by Internet Bully; 04-20-2014 at 17:49.
Internet Bully is offline
ecca
Sexy Santa
Join Date: Jan 2011
Old 04-20-2014 , 18:37   Re: Limit amount of damage per enemy
Reply With Quote #4

I've tried every method like yours , i just shot him in the head and the chat returned this: Values are float converted to ints.



but still he doesn't die . Game is CSGO. I guess it's needed to store players health before he even get shot at.
__________________

Last edited by ecca; 04-20-2014 at 18:39.
ecca is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-22-2014 , 02:05   Re: Limit amount of damage per enemy
Reply With Quote #5

...I think, problem could be that, player is alive even it health get exactly to 0.
And next time when this victim get damage, you set damage as also to 0.0

PHP Code:

#include <sdkhooks>

public OnPluginStart()
{

    for(new 
1<= MaxClientsi++)
    {
        if(
IsClientInGame(i))
        {
            
OnClientPutInServer(i);
        }
    }
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);

}

public 
Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotypehitboxhitgroup)
{
    if( 
attacker <= MaxClients && GetClientTeam(victim) != GetClientTeam(attacker) )
    {
        new 
health GetClientHealth(victim);

        new 
dmg RoundFloat(damage);

        if (
dmg health)
        {
            
//PrintToServer("Real dmg Float:%0.2f, rounded dmg %i, health %i", damage, dmg, health);
            
damage float(health)+1.0;

            return 
Plugin_Changed;
        }
    }
    return 
Plugin_Continue;

Bacardi is offline
ecca
Sexy Santa
Join Date: Jan 2011
Old 04-22-2014 , 14:01   Re: Limit amount of damage per enemy
Reply With Quote #6

PHP Code:
Real dmg Float:127.40rounded dmg 127health 100
Real dmg Float
:456.24rounded dmg 456health 49
Real dmg Float
:455.19rounded dmg 455health 1 
CSGO seems to be stupid while hooking damage , this is really my problem -
__________________
ecca is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-22-2014 , 15:08   Re: Limit amount of damage per enemy
Reply With Quote #7

damed, armor is affecting...
Bacardi is offline
ecca
Sexy Santa
Join Date: Jan 2011
Old 04-22-2014 , 15:25   Re: Limit amount of damage per enemy
Reply With Quote #8

Ofcourse armor affects , but not to stay alive from a awp shot right in the head. So the logic seems wierd :<

Best way to get damaged in hp is to hook player_hurt but it fires late and you canno't alter it.
__________________
ecca is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-22-2014 , 16:04   Re: Limit amount of damage per enemy
Reply With Quote #9

Why exactly, you need limit over-damage to match victim remaining health ?

Do you see it (output) somewhere at the end ? In Stats/rank plugin or else ??
Bacardi is offline
ecca
Sexy Santa
Join Date: Jan 2011
Old 04-22-2014 , 17:09   Re: Limit amount of damage per enemy
Reply With Quote #10

^

I'm doing some rank calculations based on alot of things , included the damage. That's why i need to get it exactly :p
__________________
ecca 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 08:42.


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