Raised This Month: $ Target: $400
 0% 

emit_sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 12-21-2015 , 10:34   emit_sound
Reply With Quote #1

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
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 12-21-2015 , 12:36   Re: emit_sound
Reply With Quote #2

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)
addons_zz is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 12-22-2015 , 07:19   Re: emit_sound
Reply With Quote #3

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
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-22-2015 , 08:35   Re: emit_sound
Reply With Quote #4

This should be more correct: [which++ % sizeof(Sounds)] if you want to start from 0.
__________________
Arkshine is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 12-22-2015 , 13:08   Re: emit_sound
Reply With Quote #5

Arkshine

When i add more than 3 sounds become Random ! can you fix it ?
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 12-22-2015 , 14:10   Re: emit_sound
Reply With Quote #6

Quote:
Originally Posted by abdobiskra View Post
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 ] ) }
Attached Files
File Type: sma Get Plugin or Get Source (next_sound_sequencial.sma - 474 views - 1.3 KB)
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 12-22-2015 at 15:48. Reason: spelling fixes
addons_zz is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 12-22-2015 , 23:11   Re: emit_sound
Reply With Quote #7

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


Here's the problem

https://www.youtube.com/watch?v=d-FoqjpGsxM
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
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 18:05.


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