AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   random sound (https://forums.alliedmods.net/showthread.php?t=181750)

Intouchable 04-01-2012 14:53

random sound
 
I have this code
PHP Code:


new zm_miss_sounds[][] = {     -1,    { "umbrella_swarm/armored/miss/claw_miss_1.wav""umbrella_swarm/armored/miss/claw_miss_2.wav", },    { "umbrella_swarm/fake/miss/claw_miss_1.wav""umbrella_swarm/fake/miss/claw_miss_2.wav", },    { "umbrella_swarm/dasd/miss/claw_miss_1.wav""umbrella_swarm/dasd/miss/claw_miss_2.wav", }} 

and this

PHP Code:

emit_sound(idCHAN_WEAPONzm_miss_sounds[cInfo[id][Class]][0], volumeattnflagpitch

How to do with array to select random sounds? If my class is 1, then he select umbrella_swarm/armored/miss/claw_miss_1.wav", "umbrella_swarm/armored/miss/claw_miss_2.wav" one sound random. How to do?

claudiuhks 04-01-2012 15:41

Re: random sound
 
PHP Code:

new const g_cSounds[ ][ ] = { "ffrmc/dinwad.wav""etc/exxxfrsca.wav" };

// g_cSounds[ 0 ] will be equal with "ffrmc/dinwad.wav"
// g_cSounds[ 1 ] will be equal with "etc/exxxfrsca.wav"
// g_cSounds[ 0 ][ 0 ] will be equal with 'f'
// g_cSounds[ 0 ][ 1 ] will be equal with 'f'
// g_cSounds[ 0 ][ 2 ] will be equal with 'r'

client_cmdiClient"spk %s"g_cSoundsrandom_num0sizeof g_cSounds ) ] );

// sizeof g_cSounds will be equal with 2 --- ... -1 ... will be equal with 1 ... so we'll have random between 0 and 1 


Intouchable 04-02-2012 01:52

Re: random sound
 
What you wrote i don't need this, because my code not like yours. I wrote
PHP Code:


new zm_miss_sounds[][] = {     
-
1,    
{  
"umbrella_swarm/armored/miss/claw_miss_1.wav",  "umbrella_swarm/armored/miss/claw_miss_2.wav", }, // 1lvl
{  "umbrella_swarm/fake/miss/claw_miss_1.wav",  "umbrella_swarm/fake/miss/claw_miss_2.wav", }, // 2lvl
{  "umbrella_swarm/dasd/miss/claw_miss_1.wav",  "umbrella_swarm/dasd/miss/claw_miss_2.wav", } // 3lvl!


I was mean if zombie is 1lvl he get random these sounds
PHP Code:

{  "umbrella_swarm/armored/miss/claw_miss_1.wav",  "umbrella_swarm/armored/miss/claw_miss_2.wav", } // 1lvl 

If zombie is 2lvl then he get random these sounds
PHP Code:

{  "umbrella_swarm/fake/miss/claw_miss_1.wav",  "umbrella_swarm/fake/miss/claw_miss_2.wav", }, // 2lvl 

and etc...

P.S. I don't know how to get random sound from zombies lvl...

EpicMonkey 04-02-2012 03:06

Re: random sound
 
http://forums.alliedmods.net/showpos...67&postcount=4

Doc-Holiday 04-02-2012 03:11

Re: random sound
 
Untested

PHP Code:

#include <amxmodx>

const MAX_PLAYERS 32;

enum _:ZOMBIE_LEVELS
{
    
ZOMBIE_LEVEL_NONE,
    
ZOMBIE_LEVEL_ONE,
    
ZOMBIE_LEVEL_TWO,
    
ZOMBIE_LEVEL_THREE
}

new const 
zmMissSounds[][] = 
{     
    
"claw_miss_1.wav",
    
"claw_miss_2.wav"
};

new const 
zmZombieLevels[ZOMBIE_LEVELS][] =
{
    
"NONE",
    
"umbrella_swarm/armored/miss/"//Level 1
    
"umbrella_swarm/fake/miss/"//Level 2
    
"umbrella_swarm/dasd/miss/"  //Level 3
};

new 
g_iZombieLevel[MAX_PLAYERS 1];

public 
plugin_init()
{
    
register_clcmd("say /test""cmdTest");
    
register_clcmd("say /level""cmdLevel");
}

public 
cmdLevel(id)
{
    switch(
g_iZombieLevel[id])
    {
        case 
ZOMBIE_LEVEL_NONE:
        {
            
g_iZombieLevel[id] = ZOMBIE_LEVEL_ONE;
        }
        case 
ZOMBIE_LEVEL_ONE:
        {
            
g_iZombieLevel[id] = ZOMBIE_LEVEL_TWO;
        }
        case 
ZOMBIE_LEVEL_TWO:
        {
            
g_iZombieLevel[id] = ZOMBIE_LEVEL_THREE;
        }
        case 
ZOMBIE_LEVEL_THREE:
        {
            
g_iZombieLevel[id] = ZOMBIE_LEVEL_ONE;
        }
    }
    
client_print(idprint_chat"Your level is now %d"g_iZombieLevel[id]);
}

public 
cmdTest(id)
{
    
client_cmd(id"spk %s/%s"zmZombieLevels[g_iZombieLevel[id]], zmMissSounds[random_num(0sizeof(zmMissSounds))]);


type /level to increase your level 1,2,3

type /test to hear random sound between the two.

Intouchable 04-02-2012 04:12

Re: random sound
 
Sry, but don't like this i just need sounds only.. Now look.
PHP Code:

new const ZMClasses[][] = {
      
"noob zombie",
      
"bla zombie",
      
"ouch zombie"
}

new 
zm_miss_sounds[][] = {        
{  
"umbrella_swarm/armored/miss/claw_miss_1.wav",  "umbrella_swarm/armored/miss/claw_miss_2.wav", }, // noob zombie random sounds when he miss! first sounds
{  "umbrella_swarm/fake/miss/claw_miss_1.wav",  "umbrella_swarm/fake/miss/claw_miss_2.wav", }, // bla zombie random sounds when he miss! second sounds 
{  "umbrella_swarm/dasd/miss/claw_miss_1.wav",  "umbrella_swarm/dasd/miss/claw_miss_2.wav", } // ouch zombie random SOUNDS! third sounds


If i'am the noob zombie i would have these 2 sounds random when i miss with knife, where I wrote first sound array, if i'am bla zombie i woud have second 3 sounds random when i miss... Can write example how to select noob, bla and ouch zombies sound random?

claudiuhks 04-02-2012 05:33

Re: random sound
 
For first zombie, zm_miss_sounds[ 0 ] and zm_miss_sounds[ 1 ] -> zm_miss_sounds[ random_num( 0, 1 ) ]
For second zombie, zm_miss_sounds[ 2 ] and zm_miss_sounds[ 3 ] -> zm_miss_sounds[ random_num( 2, 3 ) ]

->

PHP Code:

new zm_miss_sounds[][] = {        
"umbrella_swarm/armored/miss/claw_miss_1.wav",  "umbrella_swarm/armored/miss/claw_miss_2.wav"// noob zombie random sounds when he miss! first sounds
"umbrella_swarm/fake/miss/claw_miss_1.wav",  "umbrella_swarm/fake/miss/claw_miss_2.wav",  // bla zombie random sounds when he miss! second sounds 
"umbrella_swarm/dasd/miss/claw_miss_1.wav",  "umbrella_swarm/dasd/miss/claw_miss_2.wav" // ouch zombie random SOUNDS! third sounds



Intouchable 04-02-2012 06:40

Re: random sound
 
Quote:

Originally Posted by claudiuhks (Post 1680422)
For first zombie, zm_miss_sounds[ 0 ] and zm_miss_sounds[ 1 ] -> zm_miss_sounds[ random_num( 0, 1 ) ]
For second zombie, zm_miss_sounds[ 2 ] and zm_miss_sounds[ 3 ] -> zm_miss_sounds[ random_num( 2, 3 ) ]

->

PHP Code:

new zm_miss_sounds[][] = {        
"umbrella_swarm/armored/miss/claw_miss_1.wav",  "umbrella_swarm/armored/miss/claw_miss_2.wav"// noob zombie random sounds when he miss! first sounds
"umbrella_swarm/fake/miss/claw_miss_1.wav",  "umbrella_swarm/fake/miss/claw_miss_2.wav",  // bla zombie random sounds when he miss! second sounds 
"umbrella_swarm/dasd/miss/claw_miss_1.wav",  "umbrella_swarm/dasd/miss/claw_miss_2.wav" // ouch zombie random SOUNDS! third sounds



thanks that i need it! :P

tuty 04-02-2012 07:08

Re: random sound
 
if you want to use emit_sound with random sounds :arrow:

Code:
emit_sound( id, CHAN_VOICE, zm_miss_sounds[ random_num( 0, charsmax( zm_miss_sounds ) ) ], VOL_NORM, ATTN_NORM, 0, PITCH_NORM )

Doc-Holiday 04-02-2012 09:49

Re: random sound
 
Quote:

Originally Posted by tuty (Post 1680452)
if you want to use emit_sound with random sounds :arrow:

Code:
emit_sound( id, CHAN_VOICE, zm_miss_sounds[ random_num( 0, charsmax( zm_miss_sounds ) ) ], VOL_NORM, ATTN_NORM, 0, PITCH_NORM )

He wants each level to have its own sound which is exactly what i posted.... so he has no idea what he is doing.

You originally said levels not names of zombies... change the level enum to a class name enum and use it that way... other wise good luck what i posted works. and its easier then hard coding 1-2 this zombie 3-4 this one ect.


All times are GMT -4. The time now is 21:14.

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