Raised This Month: $ Target: $400
 0% 

please help with sound plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hopan
Junior Member
Join Date: Dec 2008
Location: Lithuania
Old 02-06-2009 , 19:02   please help with sound plugin
Reply With Quote #1

Hello every body :-)

I just started scripting and i wanted some help with this plugin that im trying to create.
The purpose of this plugin is simple:
Play 4 diferent sounds for 4 diferent kill types, for example:

I do 2 kills, it plays double-kill.wav
I do 3 kills, it plays triple-kill.wav
I do 10 kills, it plays monster-kill.wav
I do 20 kills, it plays mega-kill.wav

There are only 4 sound files.The plugin compiles find.
The sounds download perfectly.
But i get an error when compiling.And i dont think i can hear them when i kill the amount of people that are listed below to play the sound to all of the players.
Can some one help me out with this source code?
Thank you for eny help, im just a starter :-O
P.S. - Sorry if my english is bad, or i said something you didin't understand.
If i sed something you didin't understand please tell me, and i will try to explain what i ment :-)

Double P.S. The original source code is not my.

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

#define PLUGIN_NAME ""
#define PLUGIN_VERSION ""
#define PLUGIN_AUTHOR "" 


new kills[33] = {0,...};
new deaths[33] = {0,...};
new kill[33][24];

#define LEVELS 4
#define TASK_CLEAR_KILL    100

new levels[4] = {2, 3, 10, 20};

new sounds[4][] = 
{
"hpn/double-kill", 
"hpn/triple-kill",  
"hpn/monster-kill",
"hpn/mega-kill"
};

public plugin_init() {
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
    return PLUGIN_CONTINUE;
}

public client_connect(id) {
    kills[id] = 0;
    deaths[id] = 0;
}

public clear_kill(taskid)
 {
    new id = taskid-TASK_CLEAR_KILL;
    kill[id][0] = 0;
 }

public plugin_precache() {
precache_sound("hpn/double-kill.wav")
precache_sound("hpn/triple-kill.wav")
precache_sound("hpn/monster-kill.wav")
precache_sound("hpn/mega-kill.wav")
}
hopan is offline
Send a message via Skype™ to hopan
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 #2

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
hopan
Junior Member
Join Date: Dec 2008
Location: Lithuania
Old 02-07-2009 , 07:16   Re: please help with sound plugin
Reply With Quote #3

Ok, thank you very mutch for helping me, and thank you for the tips :-)
hopan is offline
Send a message via Skype™ to hopan
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 02-07-2009 , 07:24   Re: please help with sound plugin
Reply With Quote #4

I forgot something
PHP Code:
if( !killer || !victim )
        return; 
If you make a suicide for example, the streak will keep going next round, so:
PHP Code:
if( killer == victim )
        
g_Killsvictim ] = 0
__________________

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


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