ULX

Author Topic: Triggering a sound when a player joins.  (Read 2571 times)

0 Members and 2 Guests are viewing this topic.

Offline BlackSanta

  • Newbie
  • *
  • Posts: 15
  • Karma: -1
Triggering a sound when a player joins.
« on: August 11, 2013, 08:03:27 PM »
Hi,

I was wondering if someone would be so kind as to, well, create a script that would play a specific sound when a certain steam ID joins. I would most appreciate it.

Thanks.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Triggering a sound when a player joins.
« Reply #1 on: August 11, 2013, 08:30:00 PM »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline BlackSanta

  • Newbie
  • *
  • Posts: 15
  • Karma: -1
Re: Triggering a sound when a player joins.
« Reply #2 on: August 11, 2013, 08:41:00 PM »
Wanna know the sad part? Ive seen that addon before, never realized it played sound. Thank you for your help!

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Triggering a sound when a player joins.
« Reply #3 on: August 11, 2013, 08:57:38 PM »
You'd have to do a bit of editing for particular steamID and sound only, but I could have sworn I've seen that same discussion around here somewhere.
At the least, that release should give you a basic idea framework for your own code.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline BlackSanta

  • Newbie
  • *
  • Posts: 15
  • Karma: -1
Re: Triggering a sound when a player joins.
« Reply #4 on: August 11, 2013, 09:43:11 PM »
Well after a good few hours of tweaking around, ive gotten no where. I cant seem to figure out how to make it only play when my steam id connects. Help?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Triggering a sound when a player joins.
« Reply #5 on: August 12, 2013, 05:12:03 AM »
Can you share what you have so far?
Experiencing God's grace one day at a time.

Offline BlackSanta

  • Newbie
  • *
  • Posts: 15
  • Karma: -1
Re: Triggering a sound when a player joins.
« Reply #6 on: August 12, 2013, 08:33:04 AM »
I'll be perfectly honest, I have destroyed this code so horribly that the only way you could help is if I showed you the original.

The ZIP comes with 2 files, this is sv_player.lua

// server side apple
AddCSLuaFile( "cl_player.lua"  )

//Spawn
function FirstSpawn( ply )
   timer.Create( "server_spawn_timer_wait", 3, 1, function()
colour1 = ply:Team()
spawn1 = ply:Nick()
   umsg.Start( "player_spawn")
   umsg.String(spawn1)
   umsg.Short(colour1)
   umsg.End()
Msg("Player " .. spawn1 .. " has joined the server.\n")
end)
end
 
hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", FirstSpawn )

 
//Disconnect
function PlayerDisconnect( ply )
colour3 = ply:Team()
spawn3 = ply:Nick()
   umsg.Start( "player_disconnect")
   umsg.String(spawn3)
   umsg.Short(colour3)
   umsg.End()
Msg("Player " .. spawn3 .. " has left the server.\n")
end
 
hook.Add( "PlayerDisconnected", "playerDisconnected", PlayerDisconnect )



This is cl_player.lua


// client side apple

// Spawn
function player_spawn( data )
local name1 = data:ReadString()
local nickteamcolour1 = team.GetColor(data:ReadShort())
   chat.AddText( Color( 255, 0, 255 ), "[Server] ", nickteamcolour1, name1, Color( 255, 255, 255 ), " has joined in the server." )
   surface.PlaySound( "garrysmod/save_load1.wav" )
end
usermessage.Hook("player_spawn", player_spawn)

// Disconnect
function player_disconnect( data )
local name3 = data:ReadString()
local nickteamcolour3 = team.GetColor(data:ReadShort())
   chat.AddText( Color( 255, 0, 255 ), "[Server] ", nickteamcolour3, name3, Color( 255, 255, 255 ), " has left the server." )
   surface.PlaySound( "garrysmod/save_load2.wav" )
end
usermessage.Hook("player_disconnect", player_disconnect)





Again, thanks for any help.