Can't change server name & end of round music for TTT

First of all, I can’t change my dedicated server name even though I’ve added this in the server.cfg.


hostname="[GЯ] GetRekt TTT - Custom Maps/FastDL/Good Admins/1hit Knife -SMALL DOWNLOAD-"

I’ve restarted the server yes.

My second problem is getting my code for end of round music to work. This is a lua file called “end round music.lua” in the lua/autorun folder.


resource.AddFile("sound/getrekt/endround/Halo Theme Mjolnir Mix.mp3")
resource.AddFile("sound/getrekt/endround/Stand Up.mp3")
resource.AddFile("sound/getrekt/endround/Run To The Hills.mp3")
resource.AddFile("sound/getrekt/endround/Take No Prisoners.mp3")

local function PlayMusic(wintype)
	if wintype == WIN_INNOCENT then
		int = math.random(0,1)
		if int == 0 then
			BroadcastLua('surface.PlaySound("sound/getrekt/endround/i_win/Halo Theme Mjolnir Mix.mp3")')
		elseif int == 1 then
			BroadcastLua('surface.PlaySound("sound/getrekt/endround/i_win/Stand Up.mp3")')
		end

   elseif wintype == WIN_TRAITOR then
		int = math.random(0,1)
		if int == 0 then
			BroadcastLua('surface.PlaySound("sound/getrekt/endround/t_win/Take No Prisoners.mp3")')
		elseif int == 1 then
			BroadcastLua('surface.PlaySound("sound/getrekt/endround/t_win/Run To The Hills.mp3")')
		end
		
	end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)

Any help?

It’s supposed to be


hostname "[GЯ] GetRekt TTT - Custom Maps/FastDL/Good Admins/1hit Knife -SMALL DOWNLOAD-"

thanks, I’ll try that.

Edit: yeah It’s working now thanks. But I still need help on my other problem.

Max, Im not quite sure about this and Its actually just shot in the dark :stuck_out_tongue:

But:

  1. Have you added the sounds to your garrysmod/sound folder? (you probably have :D)
  2. shouldn’t

resource.AddFile("sound/getrekt/endround/Halo Theme Mjolnir Mix.mp3")

and


BroadcastLua('surface.PlaySound("sound/getrekt/endround/i_win/Halo Theme Mjolnir Mix.mp3")')

be the same? so you also have to add “I_win” to the resource.Addfile? (Im not quite sure about this)

Also a good tip if you get it to work. You should probably also add somekind of music wintype == WIN_TIMELIMIT :slight_smile:

Hope you find an answer :slight_smile:

[If you are posting a Lua error you’re getting - then POST THE FULL ERROR AND THE CODE. Make sure you are posting the FIRST error you’re getting - not the last error.

Do not post huge scripts and expect people to fix them. If you wrote the script then you should know why it doesn’t work. If you’re editing someone’s script and can’t get it to work then don’t! Learn how to code!](http://forum.facepunch.com/showthread.php?t=1250283)

I Know that garry have set these rules Matt, But I dont see a problem to help other people in need, If I e.g. Know something that could help this guy and make him happy the next 2 or 3 days?

Uh, it’s impossible to help because he didn’t provide us with any information. Just a huge script.

I’m not getting any lua errors. The code just won’t run. And this isn’t a huge wall of text, it’s really just a few lines of code. Last time I checked you’re not a mod, so get over yourself. If the mods think this thread is bad then they can close it for all I care, but you don’t have any right to come in here saying that shit.

Anyway, thank you Morten for being helpful. Yeah I realized the paths were wrong and I’m gonna try the new code. But I also think another problem is that I’m trying to pick a random number between 0 and 1 to decide which song to play, but I believe the random generator will also return decimals which I don’t want. I’ll test this theory too.

There are no mods that check this section, which is why I’m such a hot head about this stuff all the time.

math.random returns integers.

You really don’t help yourself by not posting any console logs, you can also try putting prints in your function to debug it and make sure it’s even being called at all.

Are there debug commands to force T or Innocent win? Otherwise I’ll have to wait for some friends to help me test this.

Also how would I add prints into the code?

It’s not that Matt doesn’t want to help him, he feels as if there is a lack of informative to provide help.

Of course, helping others is never bad a thing, but it’s always nice to have as much to go off as you can. Like, if you don’t post an error or any indication of what could be wrong, then the helpers won’t know where to start.

Your lua file has spaces in it therefore does not run.

Dude try to use f*cking google. Everything that you need can be found.
http://forum.facepunch.com/showthread.php?t=1309391&p=42267015&viewfull=1#post42267015 - That code what you need

http://forum.facepunch.com/showthread.php?t=1259939&p=40221416&viewfull=1#post40221416 - Thats about “code for me please”
If you have 0 knowledge LUA, this place is not for you. For sure. Just try to understand that.

God you are fucking pretentious. I use Google all the time, I’m no idiot. Posting on a forum for help is my last resort.

[editline]21st October 2013[/editline]

What does that mean? Song names should have no spaces? I was actually kind of worried about that.

Sound files with spaces may produce problems though, I never tried though so I am not sure

Ah.

[editline]21st October 2013[/editline]

So I take it this should work:

forcedownloads.lua


resource.AddFile ("sound/getrekt/standup.mp3")
resource.AddFile ("sound/getrekt/halotheme.mp3")
resource.AddFile ("sound/getrekt/takenoprisoners.mp3")
resource.AddFile ("sound/getrekt/runtothehills.mp3")

endroundmusic.lua


local function PlayMusic(waype)
	if waype == WIN_INNOCENT then
		a = math.random(0,1)
		if a == 0 then
			BroadcastLua('surface.PlaySound("getrekt/halotheme.mp3")')
		elseif a == 1 then
			BroadcastLua('surface.PlaySound("getrekt/standup.mp3")')
		end

   elseif waype == WIN_TRAITOR then
		b = math.random(0,1)
		if b == 0 then
			BroadcastLua('surface.PlaySound("getrekt/takenoprisoners.mp3")')
		elseif b == 1 then
			BroadcastLua('surface.PlaySound("getrekt/runtothehills.mp3")')
		end
		
	end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)

I removed the spaces in the lua file names and the song names, and shortened the path because it was too long anyway.

[editline]21st October 2013[/editline]

Now the client doesn’t even download the files.
???

Did you actually rename the mp3’s themselves?

Okay, now the client downloads the sound but I get this error in the console when I try to play them:


[LC ULib ERROR] Received invalid sound

[editline]21st October 2013[/editline]

Yes.

simple as that the sound is not valid what else do you want us to say? check file names
and why the hell does ulib errors while surface.playsound is not part of the ulib?

The file names are correct. When I play the sound it says


You played sound getrekt/runtothehills.mp3
[LC ULib ERROR] Received invalid sound

If the sound didn’t exist it would say this:


That sound doesn't exist on the server!

I’ve heard in other places that it could be a problem with the bitrate, is that so?