Function Arguments expected

I´ve got an Error, I know this Error, but I don´t know how to solve it. That´s the Error:

[ERROR] addons/tttsuicidecounter/lua/autorun/suicidecount.lua:5: function arguments expected near ‘…’

  1. unknown - addons/tttsuicidecounter/lua/autorun/suicidecount.lua:0

That´s the Code:

[lua]if ( SERVER ) then
util.AddNetworkString(“SuicideMusic”)
util.AddNetworkString(“SuicideMessage”)

function GAMEMODE:OnPlayerHitGround( ply, inWater, onFloater )
    if speed > 1 && !inWater then
	    SuicideBroadcast("Suicide-Counter: ", Color(255,255,255), player:Nick..."ist in den Tod gestürzt")
		net.Start("SuicideMusic")
	    											
		
    end
end

function SuicideBroadcast(tbl)
    net.Start("SuicideMessage")
    net.WriteTable(tbl)
    net.Broadcast()

end

end

if CLIENT then
net.Receive(“SuicideMusic”, function(len)
local Music = net.ReadString()
local ply = LocalPlayer()

	ply.Music = CreateSound(ply, "SuperSvenPeterBros.wav")
	ply.Music:Play()
end)

net.Receive("SuicideMusic_Remove", function(len)
	local ply = LocalPlayer()
	ply.Music:Stop()
end)	

end[/lua]

If you need to know it: The Script shall print a Message into the Chat, when a Player has died by Fall Damage. The Message shall be shown with a Sound Effect.

“player:Nick…” should be "player:Nick() … "

Oh my God. Thanks. xD

[editline]16th September 2017[/editline]

Well. It worked. But now there is another problem:

[ERROR] addons/tttsuicidecounter/lua/autorun/suicidecount.lua:5: ‘)’ expected near ‘…’

  1. unknown - addons/tttsuicidecounter/lua/autorun/suicidecount.lua:0

But where is the ‘)’ missing?

I don’t know what text editor you’re using, but there are ones which will highlight where brackets start and end, and you should be able to easily find where brackets are missing with that

Your code is just a fuckin train wreck so have some properly formatted code.


if (SERVER) then
	util.AddNetworkString("SuicideMusic")
	util.AddNetworkString("SuicideMessage") 
	util.AddNetworkString("SuicideMusic_Remove")
	
	local function SuicideBroadcast(tbl)
		net.Start("SuicideMessage")
			net.WriteTable(tbl)
		net.Broadcast()
	end

	hook.Add("OnPlayerHitGround", "Suicide", function(ply, inWater, onFloater)
		if inWater then return end
		
		SuicideBroadcast({"Suicide-Counter: ", color_white, ply:Nick() .. " ist in den Tod gestürzt"})
		
		net.Start("SuicideMusic")
		net.Send(ply)
	end)
else
	net.Receive("SuicideMusic", function(len)
		local ply = LocalPlayer()
		
		ply.Music = CreateSound(ply, "SuperSvenPeterBros.wav")
		ply.Music:Play()
	end)

	net.Receive("SuicideMusic_Remove", function(len)
		local ply = LocalPlayer()
		ply.Music:Stop()
	end)
end

I am using Notepad++ and of course I checked all the brackets of the code. But I couldn´t find a “standalone Bracket”

[editline]16th September 2017[/editline]

Yes, you are right. I stopped coding Lua for over a month now and everytime I start with lua again, my code is so confusing. But thx.

[editline]16th September 2017[/editline]

The Round started and the Cosole printed this error without a break:

[ERROR] addons/tttsuicidecounter/lua/autorun/suicidecount.lua:14: attempt to call method ‘Nick’ (a nil value)

  1. v - addons/tttsuicidecounter/lua/autorun/suicidecount.lua:14
  2. unknown - lua/includes/modules/hook.lua:84

Look for something wrong on line 14.

Well that would be this one:

SuicideBroadcast({"Suicide-Counter: ", color_white, player:Nick() … “ist in den Tod gestürzt”})

But I cannot see any mistakes. The Error refers to “player:Nick()” if I read the Error correctly.

You’re getting close. Check where “player” is defined.

If I understand you correctly “player” is defined as “ply” in the hook´s function:

“function(ply, inWater, onFloater)”

But that’s where “ply” is defined, not “player”.

I finally solved it. The console doesn´t print any errors now. But it still does not work. And I don´t why and how.

[editline]16th September 2017[/editline]

Finally it works. But the whole script shall trigger only if the player reaches the speed of 600. The Script right triggers everytime when a player hit the ground. How can I change that ?
Would it be enough if I do it like that:

[lua] hook.Add(“OnPlayerHitGround”, “Suicide”, function(ply, inWater, onFloater)
if inWater then return end
if speed > 600 then
SuicideBroadcast({"Suicide-Counter: “, color_white, ply:Nick() … " ist in den Tod gestürzt”})

    print( "Broadcast check" )
   
    net.Start("SuicideMusic")
    net.Send(ply)
   end
end)[/lua]