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

Trying to "Random Case" in sounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 10-13-2017 , 16:36   Trying to "Random Case" in sounds
Reply With Quote #1

Im trying to put some sound in the countdown, it's working but the sound are switching between folders...
Is like countdown 8.mp3 from the folder "misc/elitckycount" and then the countdown 7.mp3 takes it from the other folder "misc/elitckycount2"

I want to make this function works but not like that, im trying to get a RANDOM COUNTDOWN but from the same sounds folder...

If the countdown is going from 10,9,8,7... i want all the sounds play but just from the folder "misc/elitckycount" and if the rounds ends and there is a new round, and a new countdown, randomize it between "misc/elitckycount" or "misc/elitckycount2" but all the sounds from one folder ( i can't get it in my brain how to make that works :/

PHP Code:
if (g_iCountdownCount g_fCountdownTime) {
        for (
int iClient 1iClient MaxClientsiClient++) {
            if (
IsClientInGame(iClient)) {
                
int iTimeDelta iCountdownTimeFloor g_iCountdownCount;
                
PrintCenterText(iClient"\n  %t""Start Countdown"iTimeDelta, (iTimeDelta == 1) ? "" "s");
                
IntToString(iTimeDeltaszSound15);
                
IntToString(iTimeDeltaszSound215);
                switch(
GetRandomInt(1,2))
                {
                    case 
1:
                    {
                        
ClientCommand(iClient"play *misc/elitckycount/%s.mp3"szSound);    
                    }
                    case 
2:
                    {
                        
ClientCommand(iClient"play *misc/elitckycount2/%s.mp3"szSound2);
                    }
                }
            }
        } 
__________________
Elitcky is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 10-13-2017 , 21:25   Re: Trying to "Random Case" in sounds
Reply With Quote #2

Change the name to elitckycount1, elitckycount2, elitckycount3, etc.

Then you can do something like this:

PHP Code:
if (g_iCountdownCount g_fCountdownTime) { 
    for (
int iClient 1iClient MaxClientsiClient++) { 
        if (
IsClientInGame(iClient)) { 
            
int iTimeDelta iCountdownTimeFloor g_iCountdownCount
            
PrintCenterText(iClient"\n  %t""Start Countdown"iTimeDelta, (iTimeDelta == 1) ? "" "s"); 
            
IntToString(iTimeDeltaszSound15);
            
int rand GetRandomInt(1,2);
            
ClientCommand(iClient"play *misc/elitckycount%i/%s.mp3"randszSound);     
        } 
    }

EDIT: Nvm I think I've misunderstood the question, are you just trying to play 10 sounds in order? Not really sure what you mean.

Last edited by hmmmmm; 10-13-2017 at 21:27.
hmmmmm is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 10-14-2017 , 01:19   Re: Trying to "Random Case" in sounds
Reply With Quote #3

Exactly trying to play 10 sounds in order by the Countdown integer but i want to have a random play sound between those 2 folders... all the 10 sounds from folder1 until the end of the countdown, and if there is a new round, make a random choice between the folders, and again start the countdown with the 10 sounds from the selected folder.

The problem now is like the countdown goes down but it takes sounds from both folders.
Example: The sound 10 9 8, from folder1 (with a men voice) and then it plays the 7 and 6 from folder2 ( girl voice) and then its just random sounds countdown to 0

I tried to explain it (
__________________

Last edited by Elitcky; 10-14-2017 at 01:20.
Elitcky is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 10-14-2017 , 01:48   Re: Trying to "Random Case" in sounds
Reply With Quote #4

I think I get what you mean. Issue is probably that you're selecting the random folder every time the countdown goes down. You should select 1 random folder when the countdown starts then save it and play from that folder only until next time countdown starts.

If you need more help, try posting some more code.
hmmmmm is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 10-14-2017 , 08:48   Re: Trying to "Random Case" in sounds
Reply With Quote #5

Quote:
Originally Posted by hmmmmm View Post
Issue is probably that you're selecting the random folder every time the countdown goes down. You should select 1 random folder when the countdown starts then save it and play from that folder only until next time countdown starts.
That is exactly the problem...

PHP Code:
public void OnMapStart()
{
    
AddFilesFromFolder("sound/misc/elitckycount/");
    
AddFilesFromFolder("sound/misc/elitckycount2/");
    
    
// COUNT SOUND 1
    
PrecacheSoundAny("*misc/elitckycount/10.mp3");
    
PrecacheSoundAny("*misc/elitckycount/9.mp3");
    
PrecacheSoundAny("*misc/elitckycount/8.mp3");
    
PrecacheSoundAny("*misc/elitckycount/7.mp3");
    
PrecacheSoundAny("*misc/elitckycount/6.mp3");
    
PrecacheSoundAny("*misc/elitckycount/5.mp3");
    
PrecacheSoundAny("*misc/elitckycount/4.mp3");
    
PrecacheSoundAny("*misc/elitckycount/3.mp3");
    
PrecacheSoundAny("*misc/elitckycount/2.mp3");
    
PrecacheSoundAny("*misc/elitckycount/1.mp3");
    
    
// COUNT SOUND 2
    
PrecacheSoundAny("*misc/elitckycount2/10.mp3");
    
PrecacheSoundAny("*misc/elitckycount2/9.mp3");
    
PrecacheSoundAny("*misc/elitckycount2/8.mp3");
    
PrecacheSoundAny("*misc/elitckycount2/7.mp3");
    
PrecacheSoundAny("*misc/elitckycount2/6.mp3");
    
PrecacheSoundAny("*misc/elitckycount2/5.mp3");
    
PrecacheSoundAny("*misc/elitckycount2/4.mp3");
    
PrecacheSoundAny("*misc/elitckycount2/3.mp3");
    
PrecacheSoundAny("*misc/elitckycount2/2.mp3");
    
PrecacheSoundAny("*misc/elitckycount2/1.mp3");
}

public 
Action ShowCountdownMessage(Handle hTimerany iTarget)
{
    
char szSound[16];
    
char szSound2[16];
    
    
int iCountdownTimeFloor RoundToFloor(g_fCountdownTime);
    
g_iCountdownCount++;
    
    if (
g_iCountdownCount g_fCountdownTime) {
        for (
int iClient 1iClient MaxClientsiClient++) {
            if (
IsClientInGame(iClient)) {
                
int iTimeDelta iCountdownTimeFloor g_iCountdownCount;
                
PrintCenterText(iClient"\n  %t""Start Countdown"iTimeDelta, (iTimeDelta == 1) ? "" "s");
                
//iTimeDelta is the CountDown! from 10 to 0 and that i equals it to szSound
                //so when iTimeDelta is 5 the sound is 5.mp3
                
IntToString(iTimeDeltaszSound15);
                
IntToString(iTimeDeltaszSound215);
                switch(
GetRandomInt(1,2))
                {
                    case 
1:
                    {
                        
ClientCommand(iClient"play *misc/elitckycount/%s.mp3"szSound);    
                    }
                    case 
2:
                    {
                        
ClientCommand(iClient"play *misc/elitckycount2/%s.mp3"szSound2);
                    }
                }
            }
        }
        return 
Plugin_Continue;
    }
    else {
        
g_iCountdownCount 0;
        
g_iInitialTerroristsCount GetTeamClientCount(CS_TEAM_T);
        for (
int iClient 1iClient MaxClientsiClient++) {
            if (
IsClientInGame(iClient))
                
PrintCenterText(iClient"\n  %t""Round Start");
        }
        
//EmitSoundToAll(SOUND_GOGOGO);
        
g_hShowCountdownMessage INVALID_HANDLE;
        
Call_HNS_OnCountdownEnd();
        return 
Plugin_Stop;
    }
}

void AddFilesFromFolder(char path[PLATFORM_MAX_PATH])
{
    
DirectoryListing dir OpenDirectory(pathtrue);
    if (
dir != INVALID_HANDLE)
    {
        
PrintToServer("Success directory!!!");
        
char buffer[PLATFORM_MAX_PATH];
        
FileType type;
        
        while (
dir.GetNext(bufferPLATFORM_MAX_PATHtype))
        {
            if (
type == FileType_File && (StrContains(buffer".mp3"false) != -|| (StrContains(buffer".wav"false) != -1)) && !(StrContains(buffer".ztmp"false) != -1))
            {
                
//Here you can precache sounds for everyfile checked, buffer is the full name of the file checked, (example: music.mp3)
                
AddFileToDownloadsTable("sound/misc/elitckycount/10.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount/9.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount/8.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount/7.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount/6.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount/5.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount/4.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount/3.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount/2.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount/1.mp3");
                
                
AddFileToDownloadsTable("sound/misc/elitckycount2/10.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount2/9.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount2/8.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount2/7.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount2/6.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount2/5.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount2/4.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount2/3.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount2/2.mp3");
                
AddFileToDownloadsTable("sound/misc/elitckycount2/1.mp3");
            }
        }
    }

that is the way i precache the sounds and well reproduce them
__________________

Last edited by Elitcky; 10-14-2017 at 08:49.
Elitcky is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 10-14-2017 , 19:48   Re: Trying to "Random Case" in sounds
Reply With Quote #6

You need to save it when ShowCountdownMessage is first called. Can you show that part specifically.
hmmmmm is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 10-15-2017 , 19:48   Re: Trying to "Random Case" in sounds
Reply With Quote #7

Quote:
Originally Posted by hmmmmm View Post
You need to save it when ShowCountdownMessage is first called. Can you show that part specifically.
PHP Code:
public void OnRoundStart(Event hEvent, const char[] sNamebool dontBroadcast)
{
    if (!
g_bEnabled)
        return;
    
    
g_bBombFound false;
    
    
float fFraction g_fCountdownTime RoundToFloor(g_fCountdownTime);
    
g_fRoundStartTime GetGameTime();
    
g_fCountdownOverTime g_fRoundStartTime g_fCountdownTime 0.1;
    
    
g_iTerroristsDeathCount 0;
    
g_iInitialTerroristsCount GetTeamClientCount(CS_TEAM_T);
    
    
RemoveHostages();
    
    if (
g_fCountdownTime 0.0 && (g_fCountdownOverTime GetGameTime() + 0.1) < g_fCountdownTime 1.0) {
        if (
g_hStartCountdown != null) {
            
KillTimer(g_hStartCountdown);
            
g_hStartCountdown null;
        }
        if (!
g_bRespawnMode)
            
g_hStartCountdown CreateTimer(fFractionStartCountdown);
        else
            
Call_HNS_OnCountdownEnd();
    } else
        
Call_HNS_OnCountdownEnd();
    return;

PHP Code:
public Action StartCountdown(Handle hTimer)
{
    
g_hStartCountdown INVALID_HANDLE;
    for (
int iClient 1iClient MaxClientsiClient++) {
        
CreateTimer(0.1FirstCountdownMessageiClient);
    }
    if (
g_hShowCountdownMessage != INVALID_HANDLE) {
        
KillTimer(g_hShowCountdownMessage);
        
g_iCountdownCount 0;
    }
    
g_iCountdownCount 0;
    
g_hShowCountdownMessage CreateTimer(1.0ShowCountdownMessage_TIMER_REPEAT);

welp ? :C
__________________
Elitcky is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 10-16-2017 , 04:25   Re: Trying to "Random Case" in sounds
Reply With Quote #8

Try this, only changed the relevant functions:
PHP Code:
int g_iRandomNum[MAXPLAYERS 1];

public 
Action StartCountdown(Handle hTimer)
{
    
g_hStartCountdown INVALID_HANDLE;
    
    for (
int iClient 1iClient MaxClientsiClient++) {
        
CreateTimer(0.1FirstCountdownMessageiClient);
        
g_iRandomNum[iClient] = GetRandomInt(12); // Picks a random number for every client when CountdownMessage first starts
    
}
    
    if (
g_hShowCountdownMessage != INVALID_HANDLE) {
        
KillTimer(g_hShowCountdownMessage);
        
g_iCountdownCount 0;
    }
    
    
g_iCountdownCount 0;
    
g_hShowCountdownMessage CreateTimer(1.0ShowCountdownMessage_TIMER_REPEAT);
}

public 
Action ShowCountdownMessage(Handle hTimerany iTarget)
{
    
char szSound[16];
    
char szSound2[16];

    
int iCountdownTimeFloor RoundToFloor(g_fCountdownTime);
    
g_iCountdownCount++;

    if (
g_iCountdownCount g_fCountdownTime) {
        for (
int iClient 1iClient MaxClientsiClient++) {
            if (
IsClientInGame(iClient)) {
                
int iTimeDelta iCountdownTimeFloor g_iCountdownCount;
                
PrintCenterText(iClient"\n  %t""Start Countdown"iTimeDelta, (iTimeDelta == 1) ? "" "s");
                
//iTimeDelta is the CountDown! from 10 to 0 and that i equals it to szSound
                //so when iTimeDelta is 5 the sound is 5.mp3
                
ClientCommand(iClient"play *misc/elitckycount%i/%i.mp3"g_iRandomNum[iClient], iTimeDelta); // uses saved random number to choose between 2 folders
            
}
        }
        
        return 
Plugin_Continue;
    }
    else {
        
g_iCountdownCount 0;
        
g_iInitialTerroristsCount GetTeamClientCount(CS_TEAM_T);
        
        for (
int iClient 1iClient MaxClientsiClient++) {
            if (
IsClientInGame(iClient))
                
PrintCenterText(iClient"\n  %t""Round Start");
        }
        
        
//EmitSoundToAll(SOUND_GOGOGO);
        
g_hShowCountdownMessage INVALID_HANDLE;
        
Call_HNS_OnCountdownEnd();
        
        return 
Plugin_Stop;
    }

You might have to add a 1 to end of first folder, or modify code for special case when its == 1 to not append number.

Last edited by hmmmmm; 10-16-2017 at 04:26.
hmmmmm 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 19:11.


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