AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Grenade Kill (https://forums.alliedmods.net/showthread.php?t=84568)

Mifuntm 01-28-2009 06:25

Grenade Kill
 
Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
 
new g_Enable
 
public plugin_init()
{
        register_plugin("Grenade Kill", "1.0", "hleV")
 
        g_Enable = register_cvar("gk_enable", "1")
 
        register_event("DeathMsg", "playerDeath", "a", "1>0")
}
 
public playerDeath()
{
        new killer = read_data(1)
        new victim = read_data(2)
        new weapon[8]
        read_data(4, weapon, 7)
 
        if (get_pcvar_num(g_Enable) && killer != victim && equal(weapon, "grenade"))
                client_cmd(0, "spk misc/grenadekill")
}
 
public plugin_precache()
        precache_sound("misc/grenadekill.wav")



This plugin work fine but if someone get killed by HeGrenade sound "grenadekill.wav" its playing for all players connected to the server.
Please help, and change code to playback sound only for victim.
example: if i get killed by HeGrenade plugin play this sound but only for me.
Thanks.

One 01-28-2009 06:32

Re: Grenade Kill
 
Hey,

PHP Code:

#include <amxmodx>
#include <amxmisc>
 
new g_Enable
 
public plugin_init()
{
        
register_plugin("Grenade Kill""1.0""hleV")
 
        
g_Enable register_cvar("gk_enable""1")
 
        
register_event("DeathMsg""playerDeath""a""1>0")
}
 
public 
playerDeath()
{
        new 
killer read_data(1)
        new 
victim read_data(2)
        new 
weapon[8]
        
read_data(4weapon7)
 
        if (
get_pcvar_num(g_Enable) && killer != victim && equal(weapon"grenade"))
                
client_cmd(victim"spk misc/grenadekill")
}
 
public 
plugin_precache()
        
precache_sound("misc/grenadekill.wav"


ianglowz 01-28-2009 06:34

Re: Grenade Kill
 
Change this:

PHP Code:

client_cmd(0"spk misc/grenadekill"

To

PHP Code:

client_cmd(victim"spk misc/grenadekill"


Dores 01-28-2009 09:51

Re: Grenade Kill
 
Quote:

Originally Posted by One (Post 751548)
Hey,

PHP Code:

#include <amxmodx>
#include <amxmisc>
 
new g_Enable
 
public plugin_init()
{
        
register_plugin("Grenade Kill""1.0""hleV")
 
        
g_Enable register_cvar("gk_enable""1")
 
        
register_event("DeathMsg""playerDeath""a""1>0")
}
 
public 
playerDeath()
{
        new 
killer read_data(1)
        new 
victim read_data(2)
        new 
weapon[8]
        
read_data(4weapon7)
 
        if (
get_pcvar_num(g_Enable) && killer != victim && equal(weapon"grenade"))
                
client_cmd(0"spk misc/grenadekill")
}
 
public 
plugin_precache()
        
client_cmd(0"speak ^"misc/grenadekill.wav^" "


This is completely wrong.
You must precache the sound for the plugin that is going to use it.
You can't execute client commands on plugin_precache, as no players are connected when precaching.

All he needs to do is what ianglowz said:
Code:
client_cmd(victim, "spk misc/grenadekill.wav");

One 01-28-2009 09:54

Re: Grenade Kill
 
Hey,

oh damn.thats right. idk why i changed precache :-O:shock: sry ma bad.ill edit ma post now :-D & ty

Dores 01-28-2009 10:00

Re: Grenade Kill
 
Also, it's spk, not speak, and you don't need to put quotes(") around the sound.

Mifuntm 01-28-2009 10:45

Re: Grenade Kill
 
Thanks ianglowz work fine for me :)

One 01-28-2009 10:54

Re: Grenade Kill
 
Quote:

Originally Posted by Dores (Post 751605)
Also, it's spk, not speak, and you don't need to put quotes(") around the sound.

Hey,

u mean me?

PHP Code:

#include <amxmodx>
#include <amxmisc>
 
new g_Enable
 
public plugin_init()
{
        
register_plugin("Grenade Kill""1.0""hleV")
 
        
g_Enable register_cvar("gk_enable""1")
 
        
register_event("DeathMsg""playerDeath""a""1>0")
}
 
public 
playerDeath()
{
        new 
killer read_data(1)
        new 
victim read_data(2)
        new 
weapon[8]
        
read_data(4weapon7)
 
        if (
get_pcvar_num(g_Enable) && killer != victim && equal(weapon"grenade"))
                
client_cmd(victim"spk misc/grenadekill")
}
 
public 
plugin_precache()
        
precache_sound("misc/grenadekill.wav"

I think its now right.. i edited ma first post:shock:

BOYSplayCS 01-28-2009 10:56

Re: Grenade Kill
 
Quote:

Originally Posted by Dores (Post 751605)
Also, it's spk, not speak, and you don't need to put quotes(") around the sound.

Yes, you should. It helps.

Dores 01-28-2009 11:11

Re: Grenade Kill
 
Quote:

Originally Posted by BOYSplayCS (Post 751628)
Yes, you should. It helps.

With what?


All times are GMT -4. The time now is 01:44.

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