Raised This Month: $ Target: $400
 0% 

Precaching and playing sound from ini


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-17-2011 , 21:01   Re: Precaching and playing sound from ini
Reply With Quote #1

PHP Code:
#define MAX_SONGS 10

new configsdir[200]
new 
configfile[200]
new 
song[MAX_SONGS][64]
new 
songdir[MAX_SONGS][64]
new 
bool:ismp3[MAX_SONGS]
new 
numsongs

public plugin_precache()
{
    new 
songdir2[64]
    
get_configsdir(configsdir199)
    
format(configfile199"%s/mod/connect_music.ini"configsdir)
    
    new 
fopen(configfile"rt")
    
    new 
temp[sizeof(song[]) + 1]
    while(
numsongs MAX_SONGS && !feof(f))
    {
        
fgets(ftempcharsmax(temp))
        
trim(temp)
        
        if(
temp[0])
        {
            
format(songdir263"sound/mod/%s"temp)
            
            if(
file_exists(songdir2))
            {
                if(
containi(temp".mp3") > 0)
                {
                    
ismp3[numsongs] = true
                    
                    precache_generic
(songdir2)
                    
copy(songdir[numsongs], 63songdir2)
                }
                else if(
containi(temp".wav") > 0)
                {
                    
formatex(songdir[numsongs], 63"mod/%s"temp)
                    
precache_sound(songdir[numsongs])
                }
                else
                {
                    continue
                }
                
                
numsongs++
            }
        }
    }
    
    
fclose(f)
}

public 
client_connect(id)
{
    if(
numsongs)
    {
        new 
random(numsongs)
        
client_cmd(id"%s ^"%s^""ismp3[i] ? "mp3 play" "spk"songdir[i])
    }

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 07-22-2011 at 09:08.
Exolent[jNr] 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 00:58.


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