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

Solved SDKHook_OnTakeDamageAlive remove damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 09-30-2017 , 10:58   SDKHook_OnTakeDamageAlive remove damage
Reply With Quote #1

Hi,
In my OnTakeDamageAlive I have it so when someone damages another player, the victim is supposed to suicide.

Code:
PHP Code:
public Action OnTakeDamageAlive(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3], int damagecustom) {
    if(!
IsValidClient(victim) || !IsValidClient(inflictor))
        return 
Plugin_Handled;
    
    
damage 0.0;
    
ForcePlayerSuicide(victim);
    
    return 
Plugin_Handled;

But when the victim gets slain, it shows the attacker as an assist. How can I prevent this? I thought it would be enough to set damage to 0?
__________________

Last edited by condolent; 10-07-2017 at 08:02.
condolent is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 09-30-2017 , 11:32   Re: SDKHook_OnTakeDamageAlive remove damage
Reply With Quote #2

Try this:
damage *= 0;
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 09-30-2017 , 12:56   Re: SDKHook_OnTakeDamageAlive remove damage
Reply With Quote #3

To change the damage value you need to return return Plugin_Changed;
Which also means you probably need to kill them on the next frame, using RequestFrame.
Mitchell is offline
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 09-30-2017 , 17:45   Re: SDKHook_OnTakeDamageAlive remove damage
Reply With Quote #4

Quote:
Originally Posted by Mitchell View Post
To change the damage value you need to return return Plugin_Changed;
Which also means you probably need to kill them on the next frame, using RequestFrame.
So it would be like this, then?
PHP Code:
public Action OnTakeDamageAlive(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3], int damagecustom) { 
    if(!
IsValidClient(victim) || !IsValidClient(inflictor)) 
        return 
Plugin_Handled
     
    
damage *= 0
    
RequestFrame(KillTheDudevictim);
     
    return 
Plugin_Changed
}  

public 
void KillTheDude(int client) {
    
ForcePlayerSuicide(client);

I've never used gameframes before so this might be completely wrong xd

edit
Forgot to use BraveFoxs tip!
__________________

Last edited by condolent; 09-30-2017 at 17:54.
condolent is offline
NgBUCKWANGS
Senior Member
Join Date: Dec 2014
Old 09-30-2017 , 19:21   Re: SDKHook_OnTakeDamageAlive remove damage
Reply With Quote #5

You should be able to also say
PHP Code:
RequestFrame(ForcePlayerSuicidevictim); 
But if "KillTheDude" is already defined and in use elsewhere, it's cool.
NgBUCKWANGS is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 09-30-2017 , 20:48   Re: SDKHook_OnTakeDamageAlive remove damage
Reply With Quote #6

you should pass the clients userid or serial to the request frame function although it may be unlikely it COULD happen that the player leaves between the frames. Also you could just set the damage to 0.0

Last edited by xerox8521; 09-30-2017 at 20:49.
xerox8521 is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 09-30-2017 , 21:17   Re: SDKHook_OnTakeDamageAlive remove damage
Reply With Quote #7

This should also work

Spoiler

Last edited by Timocop; 09-30-2017 at 21:32.
Timocop is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 09-30-2017 , 21:18   Re: SDKHook_OnTakeDamageAlive remove damage
Reply With Quote #8

Quote:
Originally Posted by xerox8521 View Post
you should pass the clients userid or serial to the request frame function although it may be unlikely it COULD happen that the player leaves between the frames. Also you could just set the damage to 0.0
The idea is to kill the player (by forcing sucide) if he takes any damage, to make the attacker not show up as killing the player. With that being said you can just change the attacker to equal the victim and multiplying the damage to the victim's health.

Edit:
Quote:
Originally Posted by Timocop View Post
This should also work

PHP Code:
public Action OnTakeDamageAlive(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3], int damagecustom) { 
    if(!
IsValidClient(victim) || !IsValidClient(inflictor)) 
        return 
Plugin_Handled
     
    
damage 0.0;
    
AcceptEntityInput(victim"Kill"); //Entitys get removed and clients get killed in the next frame.
     
    
return Plugin_Changed

are you trying to crash the server? Because "Kill" on players and the world is what crashes servers.

Last edited by Mitchell; 09-30-2017 at 21:19.
Mitchell is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 09-30-2017 , 21:23   Re: SDKHook_OnTakeDamageAlive remove damage
Reply With Quote #9

Last time i tested it (long time ago) the "kill" input causes suicide on clients, and IsValidClient() check avoids non clients to get killed.

Edit: Just tested it, doesnt work. I think i mixed it up with the kill cmd lol.

Last edited by Timocop; 09-30-2017 at 21:31.
Timocop is offline
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 10-01-2017 , 12:19   Re: SDKHook_OnTakeDamageAlive remove damage
Reply With Quote #10

Quote:
Originally Posted by NgBUCKWANGS View Post
You should be able to also say
PHP Code:
RequestFrame(ForcePlayerSuicidevictim); 
But if "KillTheDude" is already defined and in use elsewhere, it's cool.
Doesn't work, that gives me a syntax error/invalid function call error when compiling
__________________
condolent 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 17:52.


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