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

[SDK hooks] public Action:OnTakeDamage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-21-2013 , 06:04   [SDK hooks] public Action:OnTakeDamage
Reply With Quote #1

Got a nother question about :

Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
after using this, my plugin work fine but, when player reach 0HP, they don't die !

I don't understand why. Actually I use a ForcePlayerSuicide(client); but it's not really nice...
Arkarr is offline
Sillium
AlliedModders Donor
Join Date: Sep 2008
Location: Germany
Old 06-21-2013 , 07:08   Re: [SDK hooks] public Action:OnTakeDamage
Reply With Quote #2

Just a wild guess:
What is your return value?
__________________
brb, dishes have developed their own language and are talking to the garbage about overthrowing me... i must correct this


www.unterwasserpyromanen.de
Sillium is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-21-2013 , 07:31   Re: [SDK hooks] public Action:OnTakeDamage
Reply With Quote #3

Quote:
Originally Posted by Sillium View Post
Just a wild guess:
What is your return value?


I know, my code is propably the worst you have see ever but maybe you can help me ?

Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{	
	
	if(armor >= 1){
	
		intdamage = RoundFloat(damage);
	
		armor-=intdamage;
	
		ClearSyncHud(victim, hHudText);
		SetHudTextParams(-0.75, 0.90, 45.0, 40, 151, 249, 255);
		ShowSyncHudText(victim, hHudText, "Armor : %i", armor);
		
		return Plugin_Handled;
	}
	else{
	
		SetEntProp(victim, Prop_Send, "m_iHealth", GetClientHealth(victim) - intdamage);
		
		currentHP = GetClientHealth(victim);
		
		if(currentHP <= 0){
			ForcePlayerSuicide(victim);
		}
		
		return Plugin_Handled;
		
	}
	
	if(armor <= -1){
		ClearSyncHud(victim, hHudText);
		armor = 0;
		PrintHintText(victim, "Your armor is now DESTROYED !");
		
		return Plugin_Handled;
	}
	
	return Plugin_Stop;
}

Last edited by Arkarr; 06-21-2013 at 07:34.
Arkarr is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Old 06-21-2013 , 10:23   Re: [SDK hooks] public Action:OnTakeDamage
Reply With Quote #4

Probably something like this.

PHP Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{    
    
    if(
armor >= 1){
    
        
intdamage RoundFloat(damage);
    
        
armor-=intdamage;
    
        
ClearSyncHud(victimhHudText);
    
        if(
armor <= -1){
            
armor 0;
            
PrintHintText(victim"Your armor is now DESTROYED !");
        }
        else{
            
SetHudTextParams(-0.750.9045.040151249255);
            
ShowSyncHudText(victimhHudText"Armor : %i"armor);
        }
    
        
// Block damage
        
return Plugin_Handled;
    }
    
    
// Allow damage
    
return Plugin_Continue;

__________________
DJ Tsunami is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-21-2013 , 10:38   Re: [SDK hooks] public Action:OnTakeDamage
Reply With Quote #5

Quote:
Originally Posted by DJ Tsunami View Post
Probably something like this.

PHP Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{    
    
    if(
armor >= 1){
    
        
intdamage RoundFloat(damage);
    
        
armor-=intdamage;
    
        
ClearSyncHud(victimhHudText);
    
        if(
armor <= -1){
            
armor 0;
            
PrintHintText(victim"Your armor is now DESTROYED !");
        }
        else{
            
SetHudTextParams(-0.750.9045.040151249255);
            
ShowSyncHudText(victimhHudText"Armor : %i"armor);
        }
    
        
// Block damage
        
return Plugin_Handled;
    }
    
    
// Allow damage
    
return Plugin_Continue;


Excellent !!! Thank you so much !

Last edited by Arkarr; 06-21-2013 at 10:40. Reason: failed my link...
Arkarr 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 12:38.


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