Raised This Month: $ Target: $400
 0% 

Precaching and playing sound from ini


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
deadman909
Veteran Member
Join Date: Oct 2008
Old 07-18-2011 , 11:36   Re: Precaching and playing sound from ini
Reply With Quote #1

Just use this one.

Music goes in the fallowing directory: sound/misc/loading/
Meaning it goes in the folder called: loading

You may have to create the folders misc and than loading if you dont already have them.

PHP Code:
#include <amxmodx>
#define Maxsounds 5
#define DEBUG 0

new soundlist[Maxsounds][64]
new 
soundCount 0

public plugin_init() {
    
register_plugin("Loading Music","0.9","Andrax2000")
    return 
PLUGIN_CONTINUE
}

public 
plugin_precache() {
        new 
dh
        
new nameFull[64], name[64], nameExt[32]

        
dh open_dir("sound/misc/loading"nameFull63)

        do
    {
                
strtok(nameFull,name,63,nameExt,31,'.')
                if (
equali(nameExt"mp3")) {
#if DEBUG==1
                        
server_print("[AMXX LOADING MUSIC] Found %s "nameFull)
#endif
                        
soundlist[soundCount] = name
                        soundCount
++
                }
        }
    while(
soundCount<Maxsounds && next_file(dhnameFull63))
        
    
close_dir(dh)
    
server_print("[AMXX LOADING MUSIC] Found %i mp3s"soundCount)
    for (new 
0soundCounti++)
    {
        
format(name63"sound/misc/loading/%s.mp3",soundlist[i])
#if DEBUG==1
        
server_print("[AMXX LOADING MUSIC] Precaching %s "name)
#endif
        
precache_generic(name)        
    }
    return 
PLUGIN_CONTINUE
}

public 
client_connect(id) {
    new 
i
    i 
random_num(0,soundCount-1)
    
client_cmd(id,"mp3 play sound/misc/loading/%s",soundlist[i])
    return 
PLUGIN_CONTINUE

__________________

deadman909 is offline
Send a message via MSN to deadman909 Send a message via Yahoo to deadman909
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-18-2011 , 11:43   Re: Precaching and playing sound from ini
Reply With Quote #2

Quote:
Originally Posted by deadman909 View Post
Just use this one.
Unnecessary 2nd loop for precache.
No .wav support.
All sounds must be in same folder, so if wanted to use an existing sound, players must have to download it again in new directory.
Bad method to copy string into sound list.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
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