Ulysses

General => Developers Corner => Topic started by: BlackSanta on August 11, 2013, 08:03:27 PM

Title: Triggering a sound when a player joins.
Post by: BlackSanta 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.
Title: Re: Triggering a sound when a player joins.
Post by: JamminR on August 11, 2013, 08:30:00 PM
Couldn't you use this?
http://forums.ulyssesmod.net/index.php/topic,6036.0.html
Title: Re: Triggering a sound when a player joins.
Post by: BlackSanta 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!
Title: Re: Triggering a sound when a player joins.
Post by: JamminR 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.
Title: Re: Triggering a sound when a player joins.
Post by: BlackSanta 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?
Title: Re: Triggering a sound when a player joins.
Post by: Megiddo on August 12, 2013, 05:12:03 AM
Can you share what you have so far?
Title: Re: Triggering a sound when a player joins.
Post by: BlackSanta 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.