Raised This Month: $ Target: $400
 0% 

Precaching and playing sound from ini


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
bibu
Veteran Member
Join Date: Sep 2010
Old 07-17-2011 , 16:20   Precaching and playing sound from ini
Reply With Quote #1

I am trying to play a sound when connecting to the server, stealed much stuff from this plugin:

http://forums.alliedmods.net/showthread.php?p=152101

To what I came:

PHP Code:
#define MAX_SONGS 10

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

/* in precache */

    
new songdir2[64]
    
get_configsdir(configsdir199)
    
format(configfile199"%s/mod/connect_music.ini"configsdir)
    
    new 
trash
    
for(new i=0i<MAX_SONGSi++)
    {
        
precached[i] = false
        read_file
(configfileisong[i], 63trash)
        if(!
equali(song[i][4], ""))
        {
            
format(songdir[i], 63,"mod/%s"song[i])
            
format(songdir263"sound/mod/%s"song[i])
            if(
file_exists(songdir2))
            {
                
precached[i] = true
                
                
if(containi(song[i], ".mp3" ) != -1)
                {
                    
precache_generic(songdir[i])
                }
                else
                {
                    
precache_sound(songdir[i])
                }
            }
        }
    }

/* end precache */

public client_connect(id)
{
    new 
trash
    
for(new i=0i<MAX_SONGSi++)
    {
        
read_file(configfileisong[i], 63trash)
        if(
containi(song[i],".mp3"))
        {
            
client_cmd(id"mp3 play ^"sound/%s^""songdir[i])
        }
        else if(
containi(song[i],".wav"))
        {
            
client_cmd(id"spk ^"%s^""songdir[i])
        }
    }

Inside of my configs/mod/music.ini:

Quote:
blue_win.wav
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
 



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