AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to detect a player suicide, like a fall? (https://forums.alliedmods.net/showthread.php?t=64397)

waage 12-14-2007 20:20

How to detect a player suicide, like a fall?
 
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?

Drak 12-14-2007 20:40

Re: How to detect a player suicide, like a fall?
 
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)

Arkshine 12-14-2007 20:44

Re: How to detect a player suicide, like a fall?
 
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 }

waage 12-15-2007 00:36

Re: How to detect a player suicide, like a fall?
 
Thanks a lot, both of you.
It's working!

Lee 12-15-2007 13:11

Re: How to detect a player suicide, like a fall?
 
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 }


All times are GMT -4. The time now is 11:08.

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