Trying to GetTeamName, throwing an error. Any help?

Hey, so I’m working on a damage log addon. Problem is when I go to grab the gamemodes team name, I’m getting this error.

Here is the actual code…



function player_take_damage( victim, attacker, healthLeft, damageTaken, weapon, team, teamo )
	if attacker:IsPlayer() then --Make sure player is hurt by another player, rather than the world or console.
		player_name = victim:Name() --Get the Vicims name
		attacker_name = attacker:Name() --Get attackers name
		weapon = attacker:GetActiveWeapon() 
		team = victim:team.GetName(victim:Team()) -- Get victims 
		teamo = attacker:team.GetName(attacker:Team()) -- Get attacker team
		damage = damageTaken --Get the damage Dealt
		time = os.time() --Get the time of the event
		
		if ( weapon ~= NULL ) then
			weapon = weapon:GetClass()
		else
			weapon = "Suicide"
		end

		umsg.Start( "player_hurt_info" );------------------------
			umsg.String(player_name)-----------------------------
			umsg.String(attacker_name)-----------Sending the Data to 
			umsg.String(weapon)
			umsg.String(team)
			umsg.String(teamo)
			umsg.Long(damage)---------------be recieved by client
			umsg.Long(time)--------------------------------------
		umsg.End();----------------------------------------------
	end
end
hook.Add( "PlayerHurt", "playerHurt", player_take_damage )


Anyone know what I’m doing wrong? Any help would be greatly appreciated.

That clearly isn’t the code in question because TeamGetName isn’t even inside that code

TeamGetName is not a gmod thing

team.GetName is however and is used in the code you’ve posted

That’s what I meant. Team.GetName.

In the code, how should it be put?

(1) This is wrong:[lua]
– Wrong
team = victim:team.GetName(victim:Team())

– Correct
team = team.GetName(victim:Team())/lua umsg is deprecated. Use the net library instead.
(3) You can save data by sending numbers instead of strings, because the client can look them up on its own.[lua]
– server
hook.Add(“PlayerHurt”, “whatever”, function(victim, attacker, health, dmg)
local weap = IsValid(attacker) and attacker:GetActiveWeapon() or NULL

umsg.Start("player_hurt_info")
	umsg.Entity(victim)
	umsg.Entity(attacker)
	umsg.Entity(weap)
	-- you can probably make this a short rather than a long
	-- unless you expect players to take more than 32,000 damage at once
	umsg.Short(dmg)
umsg.End()

end)

– client
usermessage.Hook(“player_hurt_info”, function(msg)
local victim = msg:ReadEntity()
local attacker = msg:ReadEntity()
local weap = msg:ReadEntity()
local dmg = msg:ReadShort()

local vname = victim:Nick()
local vteam = team.GetName(victim:Team())
local aname = attacker:IsPlayer() and attacker:Nick() or attacker:GetClass()
local ateam = attacker:IsPlayer() and team.GetName(attacker:Team()) or "World"

print(string.format("[%s] %s did %i damage to [%s] %s with %s at %i!",
	ateam, aname, dmg, vteam, vname, weap:GetClass(), os.time()
))

end)
[/lua]