Raised This Month: $51 Target: $400
 12% 

Play Sound - spk vs emit_sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
asdian
Member
Join Date: Sep 2016
Location: Indonesia
Old 02-09-2023 , 19:44   Play Sound - spk vs emit_sound
Reply With Quote #1

i'm creating character vox sounds with multi-language support. thus the file directory goes like this:

Code:
sound\vox\sc\buffclass22s4ct\character\win1.wav
where "sc" stands for "simplified chinese"

i want to use client_cmd(id, "spk %s", sound) because it can 'stack' with other sounds simultaneously but it won't work (edit* no sound/won't play). using emit_sound() does works (edit* play just fine) but in my understanding it can't 'stack' with other sounds that have same channel. i don't want to relocate all the files because lazy, it has like 30-ish characters with 4 different languages each.

what's the different between the two? is client_cmd(id, "spk %s", sound) have directory limitation?

i'm using amxmodx 1.8.10

thanks in advance!

Last edited by asdian; 02-11-2023 at 05:45. Reason: unclear statement
asdian is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-09-2023 , 23:22   Re: Play Sound - spk vs emit_sound
Reply With Quote #2

IIRC, emit_sound plays a sound in the map from a specific location (based on the entity). Only people near that entity will hear the sound. When you use the "spk" client command, it plays solely on that person's computer (i.e. it doesn't sound like it's comping from a specific location in the map and nobody else can hear it unless you're sending it to multiple people).

Regarding "sound stacking", I swear it would actually be the other way around. Would probably need to test it to verify. Also, sounds used with emit_sound need to be precached so that they are available in the engine's sound table (according to the function documentation).

Also, AMX Mod X 1.8.10 is a version number that has never existed. Do you mean version 1.10.0 (the latest dev version)?
__________________
fysiks is online now
asdian
Member
Join Date: Sep 2016
Location: Indonesia
Old 02-10-2023 , 00:58   Re: Play Sound - spk vs emit_sound
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
IIRC, emit_sound plays a sound in the map from a specific location (based on the entity). Only people near that entity will hear the sound. When you use the "spk" client command, it plays solely on that person's computer (i.e. it doesn't sound like it's comping from a specific location in the map and nobody else can hear it unless you're sending it to multiple people).

Regarding "sound stacking", I swear it would actually be the other way around. Would probably need to test it to verify. Also, sounds used with emit_sound need to be precached so that they are available in the engine's sound table (according to the function documentation).

Also, AMX Mod X 1.8.10 is a version number that has never existed. Do you mean version 1.10.0 (the latest dev version)?
omg yes, 1.10 is what i meant xD

i'll wait for your test result
asdian is offline
AnimalMonster
Senior Member
Join Date: May 2020
Old 02-10-2023 , 12:10   Re: Play Sound - spk vs emit_sound
Reply With Quote #4

I have an idea! I knew that you could send spk sounds with less volume and other shits using () or i think that it only worked for mp3s idk but if you can use that then you can create some kind of algorithm or system that will check for players in a certain area and based on distance, if there's walls between the player and the other player, distance between the wall and add some kind of multiplier, etc

https://gamebanana.com/scripts/8576

Last edited by AnimalMonster; 02-10-2023 at 12:11.
AnimalMonster is offline
asdian
Member
Join Date: Sep 2016
Location: Indonesia
Old 02-10-2023 , 20:17   Re: Play Sound - spk vs emit_sound
Reply With Quote #5

Quote:
Originally Posted by AnimalMonster View Post
I have an idea! I knew that you could send spk sounds with less volume and other shits using () or i think that it only worked for mp3s idk but if you can use that then you can create some kind of algorithm or system that will check for players in a certain area and based on distance, if there's walls between the player and the other player, distance between the wall and add some kind of multiplier, etc

https://gamebanana.com/scripts/8576
what i want is playing my audio files using spk command. but it looks like it have directory limitation not as the same as emit_sound. in that link it seems doesn't support multilingual audio

Last edited by asdian; 02-10-2023 at 20:22.
asdian is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-11-2023 , 01:32   Re: Play Sound - spk vs emit_sound
Reply With Quote #6

Quote:
Originally Posted by asdian View Post
but it looks like it have directory limitation
What does that mean? I don't think I've ever encountered anything that I would describe as a "directory limitation".
__________________
fysiks is online now
asdian
Member
Join Date: Sep 2016
Location: Indonesia
Old 02-11-2023 , 05:43   Re: Play Sound - spk vs emit_sound
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
What does that mean? I don't think I've ever encountered anything that I would describe as a "directory limitation".
as written on the thread, when i'm using spk it have no sound/won't play. but when i'm using emit_sound it will play just fine, within same file, same directory.

so im guessing spk have kind of directory limitation
asdian is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 02-19-2023 , 05:57   Re: Play Sound - spk vs emit_sound
Reply With Quote #8

When playing with spk you don't need to specify the sound folder afaik and also try with / instead of \.
You can also check my dota 2 kill announcer.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
AnimalMonster
Senior Member
Join Date: May 2020
Old 02-19-2023 , 07:18   Re: Play Sound - spk vs emit_sound
Reply With Quote #9

Quote:
Originally Posted by asdian View Post
what i want is playing my audio files using spk command. but it looks like it have directory limitation not as the same as emit_sound. in that link it seems doesn't support multilingual audio
Just put all the multilingual audios into one .wav file and do it like "spk sound(s10e14)". And the directory limitation is that you can only put them into the folder sound/. but i can be kinda hard since you have to put percentage and i don't think that floating points are allowed.

I have something like this in mind:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <xs>

const MaxSoundAtOnce 2;
const 
MaxSoundLen 128;

enum SoundData
{
    
SD_Sound[MaxSoundLen], // String
    
Float:SD_Start// Percentage/100
    
Float:SD_End// Percentage/100
    
Float:SD_Duration// Seconds
    
Float:SD_Volume// Percentage/100
    
Float:SD_Distance
}

enum PlayerData
{
    
Float:PD_Pos,
    
Float:PD_Volume,
    
Float:PD_StartTime,
    
PD_Id
}

new 
g_Sounds[][SoundData] = {
    {
"hello"0.01.02.01.0100.0}
}

new 
g_PlayerSound[MAX_PLAYERS 1][MaxSoundAtOnce][PlayerData],
    
g_iPlaying[MAX_PLAYERS 1],
    
g_iChangeSound[MAX_PLAYERS 1][2]; // {Which, With}

public plugin_init()
{
    
register_clcmd("say hello""cmdStart");
}

public 
cmdStart(id)
{
    if(
g_iPlaying[id] == MaxSoundAtOnce)
    {
        if(
g_iChangeSound[id][0] == MaxSoundAtOnce)
            
g_iChangeSound[id][0] = 0;

        
g_iChangeSound[id][1] = 0;
    }
    else
    {
        
g_PlayerSound[id][g_iPlaying[id]][PD_Volume] = g_Sounds[0][SD_Volume];
        
g_PlayerSound[id][g_iPlaying[id]][PD_StartTime] = get_gametime();
        
g_PlayerSound[id][g_iPlaying[id]][PD_Id] = 0;
        
g_iPlaying[id]++;
    }
}

public 
client_PreThink(pId)
{
    if(!
g_iPlaying[pId])
        return;

    new 
players[MAX_PLAYERS], numidiz;
    
get_players(playersnum"i");

    new 
Float:startPossoundFloat:volume;
    new 
Float:distanceFloat:flVec[3], Float:flVec2[3];

    static 
Float:gametimegametime get_gametime();

    for(
0MaxSoundAtOncei++)
    {
        for(
0numz++)
        {
            
id players[z];

            
sound g_PlayerSound[id][i][PD_Id];

            if(
sound == -1)
                continue;

            if(
g_iChangeSound[i][0] == && g_iChangeSound[i][1] > -1)
            {
                
client_cmd(id"spk ^"%s(v0)^""g_Sounds[sound][SD_Sound]);
                
g_PlayerSound[id][i][PD_Volume] = g_Sounds[g_iChangeSound[id][1]][SD_Volume];
                
g_PlayerSound[id][i][PD_StartTime] = gametime;
                
g_PlayerSound[id][i][PD_Id] = g_iChangeSound[id][1];
                
g_iChangeSound[id][1] = -1;
                continue;
            }

            
startPos g_Sounds[sound][SD_Start];

            
g_PlayerSound[id][i][PD_Pos] = startPos gametime g_PlayerSound[id][i][PD_StartTime];

            if(
g_PlayerSound[id][i][PD_Pos] >= g_Sounds[sound][SD_Duration])
            {
                
g_PlayerSound[id][i][PD_Id] = -1;
                
g_iPlaying[id]--;
                continue;
            }

            
startPos g_PlayerSound[id][i][PD_Pos] / g_Sounds[sound][SD_Duration] * 100.0;

            if(
id == pId)
            {
                
volume g_PlayerSound[id][i][PD_Volume] * g_Sounds[sound][SD_Volume] * 100.0;
            }
            else
            {
                
pev(idpev_originflVec);
                
pev(pIdpev_originflVec2);

                if((
distance xs_vec_distance(flVecflVec2)) > g_Sounds[sound][SD_Distance])
                {
                    
client_cmd(id"spk ^"%s(v0)^""g_Sounds[sound][SD_Sound]);
                    continue;
                }

                
volume = (g_PlayerSound[id][i][PD_Volume] * g_Sounds[sound][SD_Volume]) * distance/g_Sounds[sound][SD_Distance] * 100.0;
            }

            
client_cmd(id"spk ^"%s(v%.2fs%.2fe%.2f)^""g_Sounds[sound][SD_Sound], volumestartPosstartPos+1.0);
        }
    }

Edit: P.S. It's an idea code not exactly a working one i assume.

Last edited by AnimalMonster; 02-19-2023 at 09:26.
AnimalMonster is offline
asdian
Member
Join Date: Sep 2016
Location: Indonesia
Old 02-27-2023 , 00:20   Re: Play Sound - spk vs emit_sound
Reply With Quote #10

Quote:
Originally Posted by AnimalMonster View Post
Just put all the multilingual audios into one .wav file and do it like "spk sound(s10e14)". And the directory limitation is that you can only put them into the folder sound/. but i can be kinda hard since you have to put percentage and i don't think that floating points are allowed.

I have something like this in mind:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <xs>

const MaxSoundAtOnce 2;
const 
MaxSoundLen 128;

enum SoundData
{
    
SD_Sound[MaxSoundLen], // String
    
Float:SD_Start// Percentage/100
    
Float:SD_End// Percentage/100
    
Float:SD_Duration// Seconds
    
Float:SD_Volume// Percentage/100
    
Float:SD_Distance
}

enum PlayerData
{
    
Float:PD_Pos,
    
Float:PD_Volume,
    
Float:PD_StartTime,
    
PD_Id
}

new 
g_Sounds[][SoundData] = {
    {
"hello"0.01.02.01.0100.0}
}

new 
g_PlayerSound[MAX_PLAYERS 1][MaxSoundAtOnce][PlayerData],
    
g_iPlaying[MAX_PLAYERS 1],
    
g_iChangeSound[MAX_PLAYERS 1][2]; // {Which, With}

public plugin_init()
{
    
register_clcmd("say hello""cmdStart");
}

public 
cmdStart(id)
{
    if(
g_iPlaying[id] == MaxSoundAtOnce)
    {
        if(
g_iChangeSound[id][0] == MaxSoundAtOnce)
            
g_iChangeSound[id][0] = 0;

        
g_iChangeSound[id][1] = 0;
    }
    else
    {
        
g_PlayerSound[id][g_iPlaying[id]][PD_Volume] = g_Sounds[0][SD_Volume];
        
g_PlayerSound[id][g_iPlaying[id]][PD_StartTime] = get_gametime();
        
g_PlayerSound[id][g_iPlaying[id]][PD_Id] = 0;
        
g_iPlaying[id]++;
    }
}

public 
client_PreThink(pId)
{
    if(!
g_iPlaying[pId])
        return;

    new 
players[MAX_PLAYERS], numidiz;
    
get_players(playersnum"i");

    new 
Float:startPossoundFloat:volume;
    new 
Float:distanceFloat:flVec[3], Float:flVec2[3];

    static 
Float:gametimegametime get_gametime();

    for(
0MaxSoundAtOncei++)
    {
        for(
0numz++)
        {
            
id players[z];

            
sound g_PlayerSound[id][i][PD_Id];

            if(
sound == -1)
                continue;

            if(
g_iChangeSound[i][0] == && g_iChangeSound[i][1] > -1)
            {
                
client_cmd(id"spk ^"%s(v0)^""g_Sounds[sound][SD_Sound]);
                
g_PlayerSound[id][i][PD_Volume] = g_Sounds[g_iChangeSound[id][1]][SD_Volume];
                
g_PlayerSound[id][i][PD_StartTime] = gametime;
                
g_PlayerSound[id][i][PD_Id] = g_iChangeSound[id][1];
                
g_iChangeSound[id][1] = -1;
                continue;
            }

            
startPos g_Sounds[sound][SD_Start];

            
g_PlayerSound[id][i][PD_Pos] = startPos gametime g_PlayerSound[id][i][PD_StartTime];

            if(
g_PlayerSound[id][i][PD_Pos] >= g_Sounds[sound][SD_Duration])
            {
                
g_PlayerSound[id][i][PD_Id] = -1;
                
g_iPlaying[id]--;
                continue;
            }

            
startPos g_PlayerSound[id][i][PD_Pos] / g_Sounds[sound][SD_Duration] * 100.0;

            if(
id == pId)
            {
                
volume g_PlayerSound[id][i][PD_Volume] * g_Sounds[sound][SD_Volume] * 100.0;
            }
            else
            {
                
pev(idpev_originflVec);
                
pev(pIdpev_originflVec2);

                if((
distance xs_vec_distance(flVecflVec2)) > g_Sounds[sound][SD_Distance])
                {
                    
client_cmd(id"spk ^"%s(v0)^""g_Sounds[sound][SD_Sound]);
                    continue;
                }

                
volume = (g_PlayerSound[id][i][PD_Volume] * g_Sounds[sound][SD_Volume]) * distance/g_Sounds[sound][SD_Distance] * 100.0;
            }

            
client_cmd(id"spk ^"%s(v%.2fs%.2fe%.2f)^""g_Sounds[sound][SD_Sound], volumestartPosstartPos+1.0);
        }
    }

Edit: P.S. It's an idea code not exactly a working one i assume.
nice idea. but putting put all the 4 multilingual audios into one .wav file for 10 total files from 30+ characters each is too much time to consume i think
asdian is offline
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 23:38.


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