Raised This Month: $ Target: $400
 0% 

please help with sound plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 02-07-2009 , 04:41   Re: please help with sound plugin
Reply With Quote #1

The precache works fine because you cached the sounds.
You didn't heard any sound because you have no kill event or anything else.

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

#define MAX_LEVELS    4

new g_LevelsMAX_LEVELS ] = { 231020 };
new 
g_SoundsMAX_LEVELS ][ ] =
{
    
"hpn/double-kill"
    
"hpn/triple-kill",  
    
"hpn/monster-kill",
    
"hpn/mega-kill"
};

new 
g_Kills33 ];

public 
plugin_init()
    
register_event"DeathMsg""hook_death""a" );

public 
plugin_precache()
{
    
// more optimizated this way, since you've defined the sounds already
    // new i is equal to new i = 0, because any variable has the 0 value
    
for( new iMAX_LEVELSi++ )
        
precache_soundg_Sounds] );
}

public 
hook_death()
{
    new 
killer read_data);
    new 
victim read_data);
    
    if( !
killer || !victim )
        return;
    
    
// check for TK
    
if( get_user_teamkiller ) == get_user_teamvictim ) )
        return;
        
    
g_Killskiller ] += 1;
    
g_Killsvictim ] = 0;
    
    for( new 
iMAX_LEVELSi++ )
    {
        
// check if the curent player's kills are the same as your level
        
if( g_Killskiller ] == g_Levels] )
        {
            
// to make the thing more simple, i've created a stock, wich you can see bellow
            // if you want only the player to hear the sound
            // play_sound( killer, g_Sounds[ i ] );
            
            
playsound0g_Sounds] );
        }
    }
}

playsoundidsound[ ] )
{
    new 
Buffer128 ];
    
formatexBuffersizeof Buffer 1"spk %s"sound );
    
    if( 
id )
        
client_cmdidBuffer );
    else
    {
        new 
g_maxplayers get_maxplayers();
        for( new 
1<= g_maxplayersi++ )
        {
            
// skip if a player is not connected
            
if( !is_user_connected) )
                continue;
            
// skip bots
            
if( is_user_bot) )
                continue;
                
            
client_cmdiBuffer );
        }
    }

- More info about deathmsg: http://wiki.amxmodx.org/Advanced_Scripting_(AMX_Mod_X)#Events.2FMessa ges and http://wiki.amxmodx.org/Half-Life_1_...vents#DeathMsg
- More info about for and other loops: http://wiki.amxmodx.org/index.php/Pawn_Tutorial#Looping
- I've explain a bit about for-loop here: http://forums.alliedmods.net/showthr...008#post733008
__________________

anakin_cstrike 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 01:41.


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