Raised This Month: $ Target: $400
 0% 

Play a sound when player dies


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xnn
Junior Member
Join Date: Jun 2006
Old 06-20-2006 , 10:52   Play a sound when player dies
Reply With Quote #1

Hi there. As you can see, I'm new around here. Just started to learn a little about AMXX and I want to make a plugin for a friend of mine. Here we go.

What I want is this: play a sound when player with the name "x" dies...it sounds fairly easy, but I can't get it working Any help would be appreciated. Here's what I've done so far:

Code:
#include <amxmodx>

new PLUGIN[]="kenny's death"
new AUTHOR[]="xenon"
new VERSION[]="1.0"

public plugin_init() {
    register_plugin(PLUGIN,AUTHOR,VERSION)
    register_event("DeathMsg", "k_die", "a")
}

public k_die() {
   new victim = read_data(2)
   new player[] = "kenny"
   if(get_user_name(victim,player,5)) {
	client_cmd(0,"stopsound")
	client_cmd(0,"spk misc/kenny1")
   }
   return PLUGIN_HANDLED
}

public plugin_precache()
{
  precache_sound("misc/kenny1.wav")
 
  return PLUGIN_CONTINUE
}
I did something. But, when ANY player dies, I hear that sound. It's the opposite of what I want. I need that all players hear the sound when I die.
xnn is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 06-20-2006 , 14:38  
Reply With Quote #2

Replace
Code:
   if(get_user_name(victim,player,5)) {
with
Code:
   new name[8]    get_user_name(victim,name,7)    if(equal(name, player)) {
VEN is offline
xnn
Junior Member
Join Date: Jun 2006
Old 06-20-2006 , 14:51  
Reply With Quote #3

Thanks alot man, that did the thing. But, what should I use to replace client_cmd for sending that command (spk misc/kenny1) to ALL the players connected to the server?

I've tried to add this line to the public_init function, but didn't work
Code:
register_event("SendAudio", "k_die", "a")
xnn is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 06-20-2006 , 15:11  
Reply With Quote #4

You already have that: client_cmd(0, ... mean that it's sent to all players. To execute command on the certain client you have to pass an player's index, in your case it's: client_cmd(victim, ...
VEN is offline
xnn
Junior Member
Join Date: Jun 2006
Old 06-20-2006 , 15:26  
Reply With Quote #5

Yep, it works just fine. Thanks alot, VEN. Cheers.
xnn is offline
Reply


Thread Tools
Display Modes

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:04.


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