Error in Code

This is probably a really simple fix.
I get this error code:



[ERROR] addons/spawnspec/lua/autorun/cl_intro.lua:2: attempt to call global 'activemap' (a nil value)
  1. func - addons/spawnspec/lua/autorun/cl_intro.lua:2
   2. unknown - lua/includes/extensions/net.lua:32


When running this:


net.Receive( "SpawnFOV", function( len )	 
	if activemap() == "ttt_minecraft_b5" then
	plyPos = net.ReadVector(-2124.893311, 399.857788, 1182.543335)
	plyAng = net.ReadAngle(25.320227, -14.572645, 0.000000)
	elseif activemap() == "ttt_clue_se" then
		plyPos = net.ReadVector(33.211891, 458.652588, 296.782440)
		plyAng = net.ReadAngle(15.771698, -63.144417, 0.000000)
	elseif activemap() == "ttt_community_bowling_v5a" then
		plyPos = net.ReadVector(1627.979248, 1348.835449, 303.732056)
		plyAng = net.ReadAngle(6.557766, -142.084824, 0.000000)
	elseif activemap() == "ttt_rooftops_a2" then
		plyPos = net.ReadVector(-580.010315, -1593.101074, 1118.506592)
		plyAng = net.ReadAngle(24.864820, 51.642372, 0.000000)
	elseif activemap() == "ttt_67thway_v14" then
		plyPos = net.ReadVector(283.739288, 1945.326294, 234.155838)
		plyAng = net.ReadAngle(1.092958, -100.148743, 0.000000)
	else return true
end end ) 

function getcurrentmap()
activemap = game.GetMap()
end 

Use the function before receiving the net.
Also you are using a function argument on a variable.

Replace



if activemap() == "ttt_minecraft_b5" then


With



if game.GetMap() == "ttt_minecraft_b5" then


Even if he called the right function, it’s not returning anything.



function activemap()
	return game.GetMap()
end


Putting that before the net should work. You could save the processing power of having to call game.GetMap() each time by just making it a local variable in the net.



net.Receive( "SpawnFOV", function( len )
	local curmap = game.GetMap()
	if curmap == "ttt_minecraft_b5" then
...


This worked for me. I didn’t even need the activemap function at all. Thank you!