Raised This Month: $ Target: $400
 0% 

How to detect a player suicide, like a fall?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
waage
Junior Member
Join Date: Dec 2007
Location: Sao Paulo/Brazil
Old 12-14-2007 , 20:20   How to detect a player suicide, like a fall?
Reply With Quote #1

I'm trying to create an event when the user commits a suicide, like HE explosion, falls, etc.

Changing the client_death function (miscstats.sma), I have already detected when he dies of a HE explosion, with this code:

Code:
 
if (killer == victim)
{
 new victim_name[32]
 get_user_name(victim, victim_name, 31)
 set_hudmessage(255, 0, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, -1)
 ShowSyncHudMsg(0, g_center1_sync, "%s has lost the will to live...", victim_name)
 play_sound("misc/suicide")
}
But I can't find how to detect when the player dies of a fall. Does anybody know?

Last edited by waage; 12-14-2007 at 20:24.
waage is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 12-14-2007 , 20:40   Re: How to detect a player suicide, like a fall?
Reply With Quote #2

Death by "worldspawn".
Code:
new Killer[32] read_data(4,Killer,31); if(equal(Killer,"worldspawn")) {      // They fell, crashed into a wall. Got hit by a door, etc. }
(This would go into the Death Event)
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-14-2007 , 20:44   Re: How to detect a player suicide, like a fall?
Reply With Quote #3

Code:
public client_death( killer, victim, wpnindex, hitplace, TK ) {     if( !killer && !wpnindex )         // falled }


or using event :


Code:
public pluglin_init() {     register_event( "DeathMsg", "eDeathMsg", "a" ); } public eDeathMsg() {     new iKiller = read_data(1);     new iVictim = read_data(2);         static sWeapon[16];     read_data( 4, sWeapon, sizeof( sWeapon ) - 1 );                 if( iKiller == iVictim && equal( sWeapon, "world", 5 ) )         // suicide             if( !iKiller && equal( sWeapon, "world", 5 ) )         // falled             if( !iKiller && equal( sWeapon, "door", 4 ) )         // door             if( !iKiller && equal( sWeapon, "trigger_hurt", 12 ) )         // trigger }
__________________

Last edited by Arkshine; 12-14-2007 at 21:11.
Arkshine is offline
waage
Junior Member
Join Date: Dec 2007
Location: Sao Paulo/Brazil
Old 12-15-2007 , 00:36   Re: How to detect a player suicide, like a fall?
Reply With Quote #4

Thanks a lot, both of you.
It's working!
waage is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 12-15-2007 , 13:11   Re: How to detect a player suicide, like a fall?
Reply With Quote #5

I'm not sure if you also wanted to detect when a player types 'kill' in console..

Code:
public client_kill(id) {     //player typed kill in console }
Lee 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 11:08.


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