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

Player Suicide


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-11-2012 , 21:05   Player Suicide
Reply With Quote #1

So i'm trying to catch an event (along with many others) of a player committing suicide. (he grenade, fall, kill in console, etc) and i can't get it to work.

Searching led me nowhere.
My code:
PHP Code:
 //init
register_event("DeathMsg""Event_Death""a")

public 
Event_Death() 
{
    new 
attackerID read_data(1)
    new 
victimID read_data(2)
    new 
headshot read_data(3)
    new 
weapon[32]; read_data(4weaponcharsmax(weapon) )
        
    if(
attackerID == || victimID == attackerID)
        
// stuff and things for Suicide
    
else if(cs_get_user_team(victimID) == cs_get_user_team(attackerID))
        
// stuff and things for Team Attack
    
else
                
// stuff and things for normal death

    
if(headshot)
        
// stuff and things for headshot

any ideas, friends?
I saw code laying around somewhere that it would throw 0 as attacker on suicide. but this method proves ineffective.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 06-11-2012 , 21:25   Re: Player Suicide
Reply With Quote #2

Code:
if( attacker == victim ) {      // suicide? }

Pretty sure that's how you would do that.

EDIT: That works for kill in console(spoiler).

A fall isn't considered suicide because they die from the ground(I think it's considered world spawn, but I'm not sure)

For a grenade you'd probably need to check the owner of the grenade and compare it with who died.


Spoiler
Attached Files
File Type: sma Get Plugin or Get Source (test_suicide_check.sma - 438 views - 427 Bytes)
__________________
Hi.

Last edited by Kreation; 06-11-2012 at 21:43.
Kreation is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-11-2012 , 21:27   Re: Player Suicide
Reply With Quote #3

Quote:
Originally Posted by Kreation View Post
Code:
if( attacker == victim ) {      // suicide? }

Pretty sure that's how you would do that.

Although, it appears you've tried that.
that doesn't return a fall death anyway.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 06-11-2012 , 21:33   Re: Player Suicide
Reply With Quote #4

your plugin work for me
__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 06-11-2012 at 21:45.
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-12-2012 , 00:47   Re: Player Suicide
Reply With Quote #5

Quote:
Originally Posted by rak View Post
your plugin work for me
if it works for you it could be the workings....but its strange that it wouldn't send a negative number.

Code:
giveFrags(victimID, -1, "PLAYER_SUICIDE")
Spoiler


*facepalm* i'm a fucking idiot

-problem solved-
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-12-2012 at 01:25. Reason: you're never going to kill yourself with a knife.
Liverwiz is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-12-2012 , 01:56   Re: Player Suicide
Reply With Quote #6

http://www.amxmodx.org/funcwiki.php?go=func&id=381

This is same as fakemeta FM_ClientKill

Call it : user_kill(id) or dllfunc(DLLFunc_ClientKill, id)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 06-12-2012 at 01:58.
ConnorMcLeod is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 06-12-2012 , 07:07   Re: Player Suicide
Reply With Quote #7

Code:
#include <amxmodx> public plugin_init()     register_event("DeathMsg", "OnDeathMsg", "a"); public OnDeathMsg() {     new killer = read_data(1);     new victim = read_data(2);     if (killer && killer != victim)         return;     // Player (victim) suicided }

Last edited by hleV; 06-12-2012 at 07:08.
hleV is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-12-2012 , 11:47   Re: Player Suicide
Reply With Quote #8

Quote:
Originally Posted by hleV View Post
Code:
#include <amxmodx> public plugin_init()     register_event("DeathMsg", "OnDeathMsg", "a"); public OnDeathMsg() {     new killer = read_data(1);     new victim = read_data(2);     if (killer && killer != victim)         return;     // Player (victim) suicided }
This is wrong, fall damage death gonna pass this check, should only check killer == victim, and if weapon is not a grenade, so client_kill is best method imo.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 06-12-2012 at 11:49.
ConnorMcLeod is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-12-2012 , 12:10   Re: Player Suicide
Reply With Quote #9

Quote:
Originally Posted by ConnorMcLeod View Post
http://www.amxmodx.org/funcwiki.php?go=func&id=381

This is same as fakemeta FM_ClientKill

Call it : user_kill(id) or dllfunc(DLLFunc_ClientKill, id)
No offense, but i do not like this method. when the user types kill it sends a deathMSG of the killer being the victim (killer == victim) which is just as easy to check in DeathMsg() as anything else. This way just adds one more function, one more forward/hook, and 10 more lines of code. Just unneccesary. IMHO


Quote:
Originally Posted by ConnorMcLeod View Post
This is wrong, fall damage death gonna pass this check, should only check killer == victim, and if weapon is not a grenade, so client_kill is best method imo.
only thing that needs to be fixed is
Code:
if( !! killer .....
As to make sure the killer is not 0
Fall damage will then be accepted; and it DOES work with typing kill in console (tested)

Though i don't think he read my code, meaning if i was an idiot...this would just confuse me.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-12-2012 at 12:15.
Liverwiz is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 06-12-2012 , 12:17   Re: Player Suicide
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post
This is wrong, fall damage death gonna pass this check, should only check killer == victim, and if weapon is not a grenade, so client_kill is best method imo.
But he wants to include deaths from falling. I don't see any flaw in my code.

Last edited by hleV; 06-12-2012 at 12:19.
hleV 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 06:51.


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