AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   why doesn't the sound play? (https://forums.alliedmods.net/showthread.php?t=320940)

Watermelonnable 01-16-2020 19:10

why doesn't the sound play?
 
Hello! I'm trying to play a sound in a plugin. Literally just copied and pasted another of my working snippets and it doesn't do anything. This is what I did:

PHP Code:

new const g_szSound[1][FILELENGHT];

public 
plugin_precache()
{
    
amx_load_setting_string(SETTINGSFILE"Invisibility Cloak""SOUND"g_szSound[0], charsmax(g_szSound[]));
    
precache_sound(g_szSound[0]);
}

public 
plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
register_concmd("invisound""PlaySound"ADMIN_SLAY);
}

public 
PlaySound(id)
{
    
emit_sound(idCHAN_BODYg_szSound[0], 1.0ATTN_NORM0PITCH_NORM);


Suggestions? The sound is 2 seconds length and it's a wav converted from mp3

fysiks 01-16-2020 20:19

Re: why doesn't the sound play?
 
Try it with a default game sound to validate your code first. If that works then it's an issue with your .wav file.

Watermelonnable 01-16-2020 23:57

Re: why doesn't the sound play?
 
Quote:

Originally Posted by fysiks (Post 2680563)
Try it with a default game sound to validate your code first. If that works then it's an issue with your .wav file.

Yep, just tried it with another sound and it worked. Any idea of why does this happen?

redivcram 01-17-2020 06:29

Re: why doesn't the sound play?
 
In goldsource, sound files only work properly in mono and 22050kHz of sampling rate.


All times are GMT -4. The time now is 02:54.

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