Author Topic: UJoin Sounder  (Read 12951 times)

0 Members and 1 Guest are viewing this topic.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
UJoin Sounder
« on: November 28, 2008, 03:37:11 PM »
Description:
Plays a sound to people who join your server

Current Version: v1

Features:
  • Doesn't require ULib or ULX
  • If more than one sound is in the table, picks a random one to play.
  • Only plays the sound once they've obtained Steam authorization
  • Won't follow them to every server, only servers that have this installed will play

Installation:
  • Create file/Copy the following code into <your_server_path>gmod/lua/autorun/Ujoin_sounder.lua

Code: [Select]
--Quick dirty script for playing sounds to players who join your server.
--Edit to your hearts content. Rewrite it better. I'm not going major release with it.
--See below where to edit/add sounds. If you use CUSTOM ones, make sure your player has them (Forcedownload, etc)
--I used GCFScape for looking at what sounds are available. You may use Google.

local UJoin_Sound_Ver = "[UJoin Sound] - v1 loaded"

if SERVER then
   local UJoin_sounds = { }
--=========EDIT HERE===========================================================
-- *Note* There is a ~255 character limit to one full sound path. Place trailing comma.
   UJoin_sounds = {
        "/vo/canals/shanty_gotword.wav",
        "/vo/canals/boxcar_becareful_c.wav",
        "/vo/canals/gunboat_getin.wav",
        "/vo/canals/matt_goodluck.wav",
        "/vo/canals/matt_tearringuprr_b.wav",
        "/vo/coast/male01/youmadeit.wav",
                  }
--==========Don't edit below here (unless you know how) ========================

   MsgN( UJoin_Sound_Ver )
   AddCSLuaFile( "autorun/UJoin_Sounder.lua" )
   function Send_Some_Sound( ply, steamid )
            umsg.Start( "UJoin_sound", ply )
            umsg.String( UJoin_sounds[ math.random( 1, table.getn( UJoin_sounds ) ) ] )
            umsg.End()
   end
   hook.Add("PlayerAuthed", "SendASound", Send_Some_Sound)

else
    MsgN( UJoin_Sound_Ver )

    function UJoin_Play_sound( um )
             UJoin_snd = um:ReadString()
             util.PrecacheSound( UJoin_snd )
             surface.PlaySound( UJoin_snd )
    end
    usermessage.Hook("UJoin_sound", UJoin_Play_sound )
end


Very simple script at the request of a few I've seen in the threads here at Ulyssesmod.net
I've included a few fun sample sounds that I thought would work as greetings.
Other than GCFScape, I've found no comprehensive list of sound paths on the web. If you know/find one, please post the LINK here.

*NOTE* - This will not work in singleplayer or offline servers.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: UJoin Sounder
« Reply #1 on: November 30, 2008, 04:44:54 AM »
Sweet. Good work.
Experiencing God's grace one day at a time.

Offline benbrooks

  • Newbie
  • *
  • Posts: 28
  • Karma: 2
Re: UJoin Sounder
« Reply #2 on: November 30, 2008, 05:27:27 AM »
Very nice :)

I use custom sound entrances for certain people in my server, I use a modified version of Gjoin

Offline stockley5

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: UJoin Sounder
« Reply #3 on: December 07, 2008, 06:17:40 AM »
Wow! Thanks JamminR, going to try this out tonight, thanks again

Stockley5

Offline tku92

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: UJoin Sounder
« Reply #4 on: March 23, 2009, 07:11:02 PM »
Do you know anyway to make this so it could possibly play the sound while the game is loading instead of after the player is in the server, i probably sound crazy but ive seen it before and i really wish i knew how to do it.

Offline Bulaba0

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: UJoin Sounder
« Reply #5 on: April 16, 2009, 08:28:10 PM »
What's the directory the files read from?

The file's directory is sound/example.wav


Would it read it...
As in "sound/example.wav"
or "/example.wav"
Which would work?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UJoin Sounder
« Reply #6 on: April 17, 2009, 08:16:04 PM »
Source engine by default looks for all sound files, whether from the gcf package or actually in the directory, from /sound
So, /example.wav should work. Might not need the slash /

Do you know anyway to make this so it could possibly play the sound while the game is loading instead of after the player is in the server, i probably sound crazy but ive seen it before and i really wish i knew how to do it.
Not using Lua. Lua doesn't start until player joins server, or starts singleplayer.
There is a way to do it as part of a menu, but I don't know it. Try the Valve developer wiki.
« Last Edit: April 17, 2009, 08:19:38 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bulaba0

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: UJoin Sounder
« Reply #7 on: April 18, 2009, 07:39:20 AM »
Yeah, I figured it out, and thanks for the clarification, it works beautifully.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UJoin Sounder
« Reply #8 on: April 18, 2009, 08:27:50 AM »
Remember, your players will have to have the custom sound also to hear it. This script will not automatically send it to them.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline spike_wess

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: UJoin Sounder
« Reply #9 on: November 16, 2009, 01:20:07 PM »
Could someone help me understand how I could make it so when certain players connect, it plays the sound for them only, say for example, I connect to the server. It would say spike has connected.



Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UJoin Sounder
« Reply #10 on: November 16, 2009, 01:52:02 PM »
Know Lua or GLua?
Your request complicates the simplicty of the script.
As it stands now, it plays only to the player, not everyone else.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline spike_wess

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: UJoin Sounder
« Reply #11 on: November 16, 2009, 04:07:22 PM »
yeah sorry i haven't slept for 2 days now.

I re read it and i know what it dose now, im having a problem with it though, its not playing a sound to people that connect, its in the lua/autorun folder..

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UJoin Sounder
« Reply #12 on: November 16, 2009, 07:12:15 PM »
Have you edited any of the sounds?
Do people connecting get any kind of message saying it's loaded?
Do they get any kind of usermessage error regarding UJoin?
Did you name it UJoin_Sounder.lua? That filename is required.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline spike_wess

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: UJoin Sounder
« Reply #13 on: November 16, 2009, 10:51:39 PM »
Yeah i have not edited it, and the name is correct.

i haven't seen any errors.

Offline spike_wess

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: UJoin Sounder
« Reply #14 on: November 17, 2009, 09:34:19 AM »
Sorry for the double post, but i figured it out, just was wondering now.

What would i put as the sound, since im using exosounds for players to download the sounds.

exosounds/sound.mp3 ?