Raised This Month: $32 Target: $400
 8% 

Loading Music (easy to use directory version)


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands        Approver:   Brad (55)
AndraX2000
Member
Join Date: Mar 2006
Location: 39°57' N 83°14' W
Old 10-30-2006 , 09:31   Loading Music (easy to use directory version)
Reply With Quote #1

Code:
/* Loading Music (easy to use directory version)
by Andrew Penry (Andrax2000)
Praise or flame me at cs.wallworm.com Thurs & Sun 9PM EST

This plugin will randomly choose an mp3 from a directory on the server
and play it during the map load.

To use:
1. Compile & Copy, you know the drill
2. Create a directory called loading in <gamemod>/sound/misc/
3. Upload up to 5 mp3s into <gamemod>/sound/misc/loading/

Don't forget to mirror the mp3s on your sv_downloadurl sever.

If you want more than 5 mp3 you can change Maxsounds and recompile. I
would not recommed this, as it will take a long time for the clients to
download. Also note, most maps don't take a great deal of time to download
if you are using sv_downloadurl, so having 6 min long mp3s is pointless. I
recommend trimming the mp3s down to 1 min to make them take less download
time.

Inspired by my admin's frustrations with similar plugins that had the names
of the sounds hardcoded in, or required a config file, etc. I think that
this makes thing much simpler for the server admin.
Thanks to the groundwork layed by [OSA]Odin and eFrigid.
Thanks to arkshine for the precache_generic suggestion.

Important note:
Test that your mp3s work locally before uploading them to the server:
1. Place the mp3 in <gamemod>/sound/misc on YOUR LOCAL machine
2. Open up CS but do not connect to a server.
3. Type "mp3 play sound/misc/<name of mp3>" (note do not type .mp3 at the end)
4. If it plays, it's OK to upload, if not, the mp3 is incompatible with HL

HL seems to prefer mp3s encoded with LAME or Fraunhofer. It will not play
music encoded with mp3pro (the codec that Nero comes with) which use the .mp3
extentions even though they are technically not mp3 files.

Changelog:
v 0.9 Reduced code size by using a do...while loop
      Switched to precahce_generic to get rid of the RIFF/WAV warnings
v 0.8 Intital Release

Todo:
Add error checking. It may crash if there are no files in the loading dir.
Add a compile option to include the standard HL sounds into the random mix.
Possibly: Move randomness from client_connect to plugin_precache, so all
 clients hear the same sound, and only the current sound needs precached.
 That would have the advantage that the client would not need to download
 all the songs at once. The disadvantage it that sometimes the song won't
 play when it is first downloaded, so it may be several maps before the
 client starts hearing music. Would need much testing.
*/
#include <amxmodx>
The major difference between this and eFrigid's version, is that this requires no .ini file with a list of the songs. It simple precaches all mp3s found in sound/misc/loading, so a admin with ftp access just has to upload an mp3. No more giving random people ssh access just to add sounds to the loading screen.
Attached Files
File Type: sma Get Plugin or Get Source (loadingsounddir.sma - 16621 views - 3.6 KB)
AndraX2000 is offline
NomadCF
Member
Join Date: Oct 2006
Old 10-30-2006 , 09:52   Re: Loading Music (easy to use directory version)
Reply With Quote #2

would it be possible to make it loop continuously though all the music files ?
NomadCF is offline
Send a message via AIM to NomadCF
AndraX2000
Member
Join Date: Mar 2006
Location: 39°57' N 83°14' W
Old 10-30-2006 , 10:41   Re: Loading Music (easy to use directory version)
Reply With Quote #3

Quote:
Originally Posted by NomadCF View Post
would it be possible to make it loop continuously though all the music files ?
My gut instinct is that you would have to know the length of each mp3 and use a set_task to do that. I highly doubt I can easily get the length of the mp3.

You can make it loop through the single file it picks by replaying "mp3 play" with "mp3 loop"

I didn't do this by default because we have 10 sec announcements that we put in the loading folder, and having the same announcement loop for 2 minutes would be annoying.
AndraX2000 is offline
jopmako
Senior Member
Join Date: Jul 2006
Location: QQ:331537639
Old 10-31-2006 , 03:46   Re: Loading Music (easy to use directory version)
Reply With Quote #4

I suggest u don't execute commands to cilent in client_connect() immediately, that will not be execute some time.
this is i posted ago.
http://forums.alliedmods.net/showthr...=21345&page=36
use with less delay to do that with no problem.
__________________
QQ31537639

Last edited by jopmako; 10-31-2006 at 03:49.
jopmako is offline
Send a message via MSN to jopmako
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 10-31-2006 , 03:52   Re: Loading Music (easy to use directory version)
Reply With Quote #5

Quote:
Originally Posted by jopmako View Post
I suggest u don't execute commands to cilent in client_connect() immediately, that will not be execute some time.
Whats the reasoning behind this? IMHO there's nothing wrong with it.
__________________
Released six formerly private plugins. Not active here since ages.

Last edited by MaximusBrood; 10-31-2006 at 10:10.
MaximusBrood is offline
AndraX2000
Member
Join Date: Mar 2006
Location: 39°57' N 83°14' W
Old 10-31-2006 , 10:06   Re: Loading Music (easy to use directory version)
Reply With Quote #6

Quote:
Originally Posted by jopmako View Post
I suggest u don't execute commands to cilent in client_connect() immediately, that will not be execute some time.
I think what you are saying is: If the client_cmd is executed immediately in client_connect, it will not always execute.

If this is true, I can't imagine how many other plugins are broken.

I would consider adding a delay using set_task if and only if people on my server said that they were not able to hear the music. Also, the link you provided didn't actually go to your post, I had to hunt around for it. I also can't find where anyone has verified that using set_task has fixed the problem of some clients not playing. In that thread it seems that the real problem is with file formats.
AndraX2000 is offline
IdiotSavant
Senior Member
Join Date: Apr 2006
Old 11-10-2006 , 13:14   Re: Loading Music (easy to use directory version)
Reply With Quote #7

Has anyone tested this? Does it work? I have had several clans ask me how to setup loading songs and I end up having to configure their servers for loading songs. If this works it would be very beneficial to me.
__________________
IdiotSavant
"Make something idiot proof and they just build a better Idiot."

Like GunGame? Visit www.gungame.org today!
Earn Admin just by playing at GunGame.Org Servers!

Come visit our GunGame.Org server at 174.34.146.107:27015
IdiotSavant is offline
AndraX2000
Member
Join Date: Mar 2006
Location: 39°57' N 83°14' W
Old 11-10-2006 , 15:21   Re: Loading Music (easy to use directory version)
Reply With Quote #8

I used it on my server for about 3 weeks with no technical problems. I ended up turning it off in the end because some of my regular players didn't like my taste in music.

I would recommend using short mp3s and only a few of them, otherwise the precache load time can be a bit too long for new players.

If anyone else has tested it on thier server, I would love to hear about it.
AndraX2000 is offline
FR0NTLINE
AlliedModders Donor
Join Date: Apr 2006
Location: Riverside Cali
Old 11-12-2006 , 20:48   Re: Loading Music (easy to use directory version)
Reply With Quote #9

It works fine guys http://www.free-codecs.com/LameXP_download.htm. All your doing is converting your mp3 and uploading it to your sounds/misc/loading folder. Note it will still be labled as mp3 when you do it. Yet you will notice it's a smaller file mine extracted to my documents I used the killbill whistle because it's a small file and most people like it 8.3.6.113:27015 THANK YOU ANDRAX.
__________________

Last edited by FR0NTLINE; 11-12-2006 at 20:58.
FR0NTLINE is offline
Send a message via AIM to FR0NTLINE Send a message via MSN to FR0NTLINE Send a message via Yahoo to FR0NTLINE
FR0NTLINE
AlliedModders Donor
Join Date: Apr 2006
Location: Riverside Cali
Old 11-12-2006 , 23:35   Re: Loading Music (easy to use directory version)
Reply With Quote #10

Ok I know i've done this correctly but when i download a map i hear nothing until i'm actually joining the game for a few seconds thats when i hear my song. So I'm wondering how can i hear the song while downloading the map and sound files? Rather than just after the maps done?
__________________
FR0NTLINE is offline
Send a message via AIM to FR0NTLINE Send a message via MSN to FR0NTLINE Send a message via Yahoo to FR0NTLINE
Reply


Thread Tools
Display Modes

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 11:07.


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