Raised This Month: $ Target: $400
 0% 

check if player dies


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cstrike37
Member
Join Date: Jan 2012
Old 09-23-2012 , 00:03   check if player dies
Reply With Quote #1

how do you check if the player dies?

example if he dies a sound will play.
cstrike37 is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 09-23-2012 , 01:51  
Reply With Quote #2

Search
Doc-Holiday is offline
cstrike37
Member
Join Date: Jan 2012
Old 09-23-2012 , 02:24   Re: check if player dies
Reply With Quote #3

i got this
Code:
public DeathMsg()
{
	new kid = read_data(1)
	new vid = read_data(2)
	
	if( kid == vid )
		return PLUGIN_CONTINUE;
	if( !g_bIsVip[ vid ] )
		return PLUGIN_CONTINUE;
	new pnum, players[32]
	get_players( players, pnum )
	for( new i, tid; i < pnum; i++ )
	{
		tid = players[i]
		client_cmd(tid, "spk %s", die_spk[ random( 2 ) ]); 

	}

	return PLUGIN_CONTINUE;
}
But the sound wont play when the player kills himself. It only plays when you got killed by a gun or from a fall

Last edited by cstrike37; 09-23-2012 at 02:31.
cstrike37 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-23-2012 , 03:10   Re: check if player dies
Reply With Quote #4

PHP Code:
#include <amxmodx>
#include <hamsandwich>

#define PLUGIN ""
#define VERSION "0.0.1"

new const g_szDeathSounds[][] = 
{
    
"",
    
"",
    
"",
    
""
}

public 
plugin_init()
{
    
RegisterHam(Ham_Killed"player""OnCBasePlayer_Killed_Post"true)
}

public 
plugin_precache()
{
    for(new 
iisizeof(g_szDeathSounds); i++)
    {
        
precache_soundg_szDeathSounds[i] )
    }
}

public 
OnCBasePlayer_Killed_PostidiAttackeriGib )
{
    new 
players[32], num
    get_players
(playersnum"ch")
    for(new 
iplayeri<numi++)
    {
        
player players[i]
        if( !
is_user_connecting(player) )
        {
            
client_cmd(id"spk %s"g_szDeathSoundsrandomsizeof(g_szDeathSounds) ) ])
        }
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-23-2012 at 03:10.
ConnorMcLeod is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 09-23-2012 , 08:36   Re: check if player dies
Reply With Quote #5

Quote:
Originally Posted by cstrike37 View Post
i got this
Code:
public DeathMsg()
{
	new kid = read_data(1)
	new vid = read_data(2)
	
	if( kid == vid )
		return PLUGIN_CONTINUE;
	if( !g_bIsVip[ vid ] )
		return PLUGIN_CONTINUE;
	new pnum, players[32]
	get_players( players, pnum )
	for( new i, tid; i < pnum; i++ )
	{
		tid = players[i]
		client_cmd(tid, "spk %s", die_spk[ random( 2 ) ]); 

	}

	return PLUGIN_CONTINUE;
}
But the sound wont play when the player kills himself. It only plays when you got killed by a gun or from a fall
did you try to understand that code at all? if(kid == vid) return PLUGIN_CONTINUE returns out of the function if the player killed himself. -if killer equals victim
Or search past that one bit of code?
1. These variable names are worse than MINE! -And that's saying something. (vid, kid, tid) how about victimID, killerID, tempID?
2. It includes things you don't need (or mentioned nothing of) g_bIsVip[vid]
3. If you're only indexing the players array once (to get the tempID) You don't need to store it in a variable. Just directly call players[i] but this is only true if you call it once. otherwise cache it as you have here.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz 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 08:21.


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