AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   add 3 commands on a key (https://forums.alliedmods.net/showthread.php?t=82526)

One 12-24-2008 22:20

add 3 commands on a key
 
Hey,

i have to add a .wav file to a plugin , on the attack2 key,but this key are used for another things. by click on attack2 a hudmessage willbe show & another command. now i dont know how can i add to this key a .wav file:(

can anyone help me? i fund nothin in tuts :(

thanks

Dores 12-25-2008 06:27

Re: add 3 commands on a key
 
Do you mean something like this?
Code:
#include <fakemeta> public plugin_init() { //    [...]     register_forward( FM_CmdStart, "Forward_CmdStart", 1 ); } public Forward_CmdStart( id, uc_handle, seed ) {     static Button ; Button = get_uc( uc_handle, UC_Buttons ); //    or:     static Button ; get_uc( uc_handle, UC_Buttons, Button );         if( ( Button & IN_ATTACK2 ) )     {         // .wav file played.         emit_sound( id, blabla, "sound/something.wav", ... );                 // HUD message.         set_hudmessage();         show_hudmessage( id, "LoL" );                 // Other command.         client_cmd( "blabla" );     } }

One 12-25-2008 09:57

Re: add 3 commands on a key
 
Hey,

Yeah.....Thanks.

One 12-25-2008 10:11

Re: add 3 commands on a key
 
PHP Code:

            if(buttons&IN_ATTACK2) {
                if(
bad[id-1][0] == && bad[id-1][1] >= BAD_VERBRAUCH)
                
emit_soundid1"sound/something.wav", ... );
                    
bad_on(id)
            }
            else if(
bad[id-1][0] == 1)
                
bad_off(id)
        } 

hmmm? whats wrong here? :-D

Dores 12-25-2008 10:47

Re: add 3 commands on a key
 
I didn't actually used the full functions in my code. Those were just examples to give you the idea.
You must use an existing .wav file with emit_sound.
http://www.amxmodx.org/doc/index.htm...emit_sound.htm

You must set arguments in the set_hudmessage() native:
http://www.amxmodx.org/funcwiki.php?...sage&go=search

You must set who to show the message to and what type of a message to show in client_print():
http://www.amxmodx.org/funcwiki.php?...sage&go=search

A more proper way will be something like:
PHP Code:

if(buttons&IN_ATTACK2) {
                if(
bad[id-1][0] == && bad[id-1][1] >= BAD_VERBRAUCH)
                
emit_soundidCHAN_AUTO"sound/something_that_exists.wav"VOL_NORMATTN_NORM0PITCH_NORM );
                    
bad_on(id)
            }
            else if(
bad[id-1][0] == 1)
                
bad_off(id)
        } 


One 12-25-2008 12:19

Re: add 3 commands on a key
 
Hey,

thanks, the hud message & the command are added. i needed just the sound to add.

ill try it .

thanks

One 12-28-2008 02:11

Re: add 3 commands on a key
 
Hey,

ich tryed to add a sound to this but... :-(

PHP Code:

player_showteam(id) {
    new 
teams[32], turbos[32]
    if(
team[id-1] == 0) {
        
set_hudmessage(OTHER_R,OTHER_G,OTHER_B,0.02,0.25,0,0.1,5.0,0.0,0.0)
        
copy(teams,127,"You are a FLEER..")
        
        if(
turbo[id-1][1] >= TURBO_VERBRAUCH)
            
format(turbos,31,"^n%sTurbo: %d%^nRightMouse to use!",turbo[id-1][0] == ?  "+" "-",turbo[id-1][1] )
    }
    else if(
team[id-1] == 1) {
        
set_hudmessage(FAENGER_R,FAENGER_G,FAENGER_B,0.02,0.25,0,0.1,5.0,0.0,0.0)
        
copy(teams,127,"You have to CATCH,Go ,Go ,Go...")
    }
    
    
show_hudmessage(id,"%s %s",teams,turbos)
    
    if(
boost_show[id-1] == true) {
        
set_hudmessage(OTHER_R,OTHER_G,OTHER_B,-1.0,0.55,0,0.1,5.0,0.0,0.0,1)
        
show_hudmessage(id,"Shoot to boost ^n!")
    } 

the sound should be played by attack2.( TURBO_VERBRAUCH )

i tryed with :
PHP Code:

new g_turbo_sound 

PHP Code:

            g_turbo_sound precache_sound("sound/catchmod/turbo.wav"

but itsnot func. :-( anyone any idea?

xPaw 12-28-2008 07:04

Re: add 3 commands on a key
 
leave the precache like this
PHP Code:

precache_sound("sound/catchmod/turbo.wav"); 

and add in code
PHP Code:

client_cmd(id"speak ^"sound/catchmod/turbo.wav^" "); 


Dores 12-28-2008 07:16

Re: add 3 commands on a key
 
Better yet, create a global constant variable:
PHP Code:

new const g_szSound[] = "sound/catchmod/turbo.wav";

public 
plugin_precache()
{
    
precache_soundg_szSound );
}

// [...]

// Now add this where you want the sound to be played:
emit_soundidCHAN_AUTOg_szSoundVOL_NORMATTN_NORM0PITCH_NORM ); 


Hawk552 12-28-2008 19:46

Re: add 3 commands on a key
 
Quote:

Originally Posted by xPaw (Post 734377)
leave the precache like this
PHP Code:

precache_sound("sound/catchmod/turbo.wav"); 

and add in code
PHP Code:

client_cmd(id"speak ^"sound/catchmod/turbo.wav^" "); 


This is a bad idea as other clients won't hear it if you run the "speak" command on a single player.


All times are GMT -4. The time now is 09:05.

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