AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   HeadShot Sounds (https://forums.alliedmods.net/showthread.php?t=126443)

Mifuntm 05-09-2010 10:13

HeadShot Sounds
 
1 Attachment(s)
Hi!
I have plugin for random headshot sounds, but plugin play this sounds for every player connected to server. I'ts possible to change plugin for playback sounds only for killer and victim?

Thanks! and sorry about my english.

reinert 05-09-2010 10:51

Re: HeadShot Sounds
 
Sorry, i forgot what read_data(?) is victim but killer is 1...
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN    "HS Sounds by Mroz!k"
#define AUTHOR    "Mroz!k"
#define VERSION    "1.0"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("DeathMsg","hs","a","3=1")
}

public 
hs(id)
{

    new 
killer read_data(1)

    new 
rand random_num(05)
    switch(
rand) {
        case 
0: {
            
client_cmd(killer"stopsound")
            
client_cmd(killer"spk cyr4x/bezdech")
        }
        case 
1: {
            
client_cmd(killer"stopsound")
            
client_cmd(killer"spk cyr4x/cyr4x_001")
        }
        case 
2: {
            
client_cmd(killer"stopsound")
            
client_cmd(killer"spk cyr4x/cyr4x_006")
        }
        case 
3: {
            
client_cmd(killer"stopsound")
            
client_cmd(killer"spk cyr4x/mk")
        }
        case 
4: {
            
client_cmd(killer"stopsound")
            
client_cmd(killer"spk cyr4x/zobacz")
        }

    }
}

public 
plugin_precache()
{
    
precache_sound("cyr4x/bezdech.wav")
    
precache_sound("cyr4x/cyr4x_001.wav")
    
precache_sound("cyr4x/cyr4x_006.wav")
    
precache_sound("cyr4x/mk.wav")
    
precache_sound("cyr4x/zobacz.wav")


now it will only play for killer

hleV 05-09-2010 11:19

Re: HeadShot Sounds
 
He wants it for victim too.

master4life 05-09-2010 11:46

Re: HeadShot Sounds
 
http://wiki.amxmodx.org/Half-Life_1_...vents#DeathMsg

read_data( 1 ) is Killer and read_data( 2 ) is Victim

but if you want try this,

PHP Code:

#include < amxmodx >

new const g_szSounds[ ][ ] = {
    
"cyr4x/bezdech.wav",
    
"cyr4x/cyr4x_001.wav",
    
"cyr4x/cyr4x_006.wav",
    
"cyr4x/mk.wav",
    
"cyr4x/zobacz.wav"
}

public 
plugin_init()
    
register_event"DeathMsg""EventDeathMsg""a""3=1" );

public 
plugin_precache( )
    for( new 
0sizeof g_szSoundsi++ )    
        
precache_soundg_szSounds] );

public 
EventDeathMsg( ) {
    new 
iKiller read_data), iVictim read_data);

    
client_cmdiKiller"stopsound" ); client_cmdiVictim"stopsound" );
    
client_cmdiKiller"spk %s"g_szSoundsrandomsizeof g_szSounds ) ] );
    
client_cmdiVictim"spk %s"g_szSoundsrandomsizeof g_szSounds ) ] );



Mifuntm 05-09-2010 11:55

Re: HeadShot Sounds
 
Quote:

Originally Posted by master4life (Post 1175567)
http://wiki.amxmodx.org/Half-Life_1_...vents#DeathMsg

read_data( 1 ) is Killer and read_data( 2 ) is Victim

but if you want try this,

PHP Code:

#include < amxmodx >

new const g_szSounds[ ][ ] = {
    
"cyr4x/bezdech.wav",
    
"cyr4x/cyr4x_001.wav",
    
"cyr4x/cyr4x_006.wav",
    
"cyr4x/mk.wav",
    
"cyr4x/zobacz.wav"
}

public 
plugin_init()
    
register_event"DeathMsg""EventDeathMsg""a""3=1" );

public 
plugin_precache( )
    for( new 
0sizeof g_szSoundsi++ )    
        
precache_soundg_szSounds] );

public 
EventDeathMsg( ) {
    new 
iKiller read_data), iVictim read_data);

    
client_cmdiKiller"stopsound" ); client_cmdiVictim"stopsound" );
    
client_cmdiKiller"spk %s"g_szSoundrandomsizeof g_szSound ) ] );
    
client_cmdiVictim"spk %s"g_szSoundrandomsizeof g_szSound ) ] );






Code:

Your plugin failed to compile! Read the errors below:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

/groups/amxmodx/tmp3/textuDThRy.sma(22) : error 017: undefined symbol "g_szSound"
/groups/amxmodx/tmp3/textuDThRy.sma(22) : error 072: "sizeof" operator is invalid on "function" symbols
/groups/amxmodx/tmp3/textuDThRy.sma(22) : error 029: invalid expression, assumed zero
/groups/amxmodx/tmp3/textuDThRy.sma(22) : fatal error 107: too many error messages on one line

Compilation aborted.
4 Errors.


reinert 05-09-2010 13:35

Re: HeadShot Sounds
 
g_szSound


to


g_szSounds

xPaw 05-09-2010 13:48

Re: HeadShot Sounds
 
fixed a lil.
Code:
#include < amxmodx > new const g_szSounds[ ][ ] = {     "cyr4x/bezdech.wav",     "cyr4x/cyr4x_001.wav",     "cyr4x/cyr4x_006.wav",     "cyr4x/mk.wav",     "cyr4x/zobacz.wav" } public plugin_init()     register_event( "DeathMsg", "EventDeathMsg", "a", "3=1" ); public plugin_precache( )     for( new i = 0; i < sizeof g_szSounds; i++ )            precache_sound( g_szSounds[ i ] ); public EventDeathMsg( ) {     new iKiller = read_data( 1 ), iVictim = read_data( 2 ); //  client_cmd( iKiller, "stopsound" ); // not needed //  client_cmd( iVictim, "stopsound" );         new iSound = random_num( 0, sizeof g_szSounds );         client_cmd( iKiller, "spk %s", g_szSounds[ iSound ] );     client_cmd( iVictim, "spk %s", g_szSounds[ iSound ] ); }

Mifuntm 05-09-2010 15:30

Re: HeadShot Sounds
 
Code:

#include < amxmodx >

new const g_szSounds[ ][ ] = {
    "cyr4x/bezdech.wav",
    "cyr4x/cyr4x_001.wav",
    "cyr4x/cyr4x_006.wav",
    "cyr4x/mk.wav",
    "cyr4x/zobacz.wav"
}

public plugin_init()
    register_event( "DeathMsg", "EventDeathMsg", "a", "3=1" );

public plugin_precache( )
    for( new i = 0; i < sizeof g_szSounds; i++ )   
        precache_sound( g_szSounds[ i ] );

public EventDeathMsg( ) {
    new iKiller = read_data( 1 ), iVictim = read_data( 2 );

//  client_cmd( iKiller, "stopsound" ); // not needed
//  client_cmd( iVictim, "stopsound" );
   
    new iSound = random_num( 0, sizeof g_szSounds );
   
    client_cmd( iKiller, "spk %s", g_szSounds[ iSound ] );
    client_cmd( iVictim, "spk %s", g_szSounds[ iSound ] );
}





work nice :)

Thanks!


All times are GMT -4. The time now is 03:37.

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