AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Play a sound when player dies (https://forums.alliedmods.net/showthread.php?t=30005)

xnn 06-20-2006 10:52

Play a sound when player dies
 
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.

VEN 06-20-2006 14:38

Replace
Code:
   if(get_user_name(victim,player,5)) {
with
Code:
   new name[8]    get_user_name(victim,name,7)    if(equal(name, player)) {

xnn 06-20-2006 14:51

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")

VEN 06-20-2006 15:11

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, ...

xnn 06-20-2006 15:26

Yep, it works just fine. Thanks alot, VEN. Cheers.


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

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