AlliedModders

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

abdobiskra 12-21-2015 10:34

emit_sound
 
How do I make sounds order not random?
PHP Code:

new Sounds[3][64] = {"son/sound0.wav""son/sound1.wav""son/sound2.wav"}
............
...........
emit_sound(playerCHAN_VOICESounds[random_num(0sizeof(Sounds) - 1)], 1.0ATTN_NORM0PITCH_NORM


addons_zz 12-21-2015 12:36

Re: emit_sound
 
Code:
#define MAX_SOUNDS 3 new g_current_sound = MAX_SOUNDS - 1 new Sounds[MAX_SOUNDS][64] = {"son/sound0.wav", "son/sound1.wav", "son/sound2.wav"} ............ stock next_sound_to_play() {     g_current_sound = ( g_current_sound + 1 ) % MAX_SOUNDS     return g_current_sound } ............ emit_sound(player, CHAN_VOICE, Sounds[next_sound_to_play()], 1.0, ATTN_NORM, 0, PITCH_NORM)

abdobiskra 12-22-2015 07:19

Re: emit_sound
 
Thank you for your interaction :)
PHP Code:

new which 0;
new 
Sounds[3][64] = {"son/sound0.wav""son/sound1.wav""son/sound2.wav"}
..............
................
emit_sound(playerCHAN_VOICESounds[which = (which 1) % 3], 1.0ATTN_NORM0PITCH_NORM


Arkshine 12-22-2015 08:35

Re: emit_sound
 
This should be more correct: [which++ % sizeof(Sounds)] if you want to start from 0.

abdobiskra 12-22-2015 13:08

Re: emit_sound
 
Arkshine

When i add more than 3 sounds become Random ! can you fix it ?

addons_zz 12-22-2015 14:10

Re: emit_sound
 
1 Attachment(s)
Quote:

Originally Posted by abdobiskra (Post 2375199)
When i add more than 3 sounds become Random !

Does not make sense that. Could you show your full code? (attach the file)


Update:

If you want to save a function call, use this:
Code:
#include <amxmodx> #include <fun> #define VERSION "1.0" #define NEXT_SOUND_TO_PLAY() \     g_current_sound = ( g_current_sound + 1 ) % sizeof Sounds new Sounds[ 3 ][ 64 ] = { "son/sound0.wav", "son/sound1.wav", "son/sound2.wav" } new g_current_sound = -1 public plugin_init() {     register_plugin( "Test", VERSION, "Addons zz" );         register_concmd( "amx_next", "next", ADMIN_CFG, "Test" ) } public next() {     NEXT_SOUND_TO_PLAY()     server_print( "^n^n^nHERE: %s^n^n^n", Sounds[ g_current_sound ] ) }

abdobiskra 12-22-2015 23:11

Re: emit_sound
 
addons_zz

Quote:

Could you show your full code?
Code:
#include <amxmodx> #define MSG_POS_X 2457 // #define MSG_POS_Y 4096 // new which = 0; new szSoundsCount[5][64] = {"fvox/one.wav", "fvox/two.wav", "fvox/three.wav", "fvox/four.wav", "fvox/five.wav"}// Here the problem can not add more than 3 sounds ! public plugin_init() { register_message(SVC_TEMPENTITY, "hud_text_msg") } public plugin_precache() { for(new i = 0; i < sizeof szSoundsCount; i++) precache_sound(szSoundsCount[i]) } public hud_text_msg() { if (get_msg_arg_int(1) == TE_TEXTMESSAGE && get_msg_arg_int(3) == MSG_POS_X && get_msg_arg_int(4) == MSG_POS_Y) emit_sound(0, CHAN_VOICE, szSoundsCount[which++ % sizeof(szSoundsCount)], 1.0, 1.0, 0, 100)     }

this hud message
http://aghl.ru/forum/download/file.php?id=3497&t=1

Here's the problem

https://www.youtube.com/watch?v=d-FoqjpGsxM


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

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