This is the error i get when i change teams
[CODE]
[ERROR] addons/prop hunt/gamemodes/fretta/gamemode/cl_hud.lua:182: attempt to call method 'GetPrintName' (a nil value)
1. OnHUDPaint - addons/prop hunt/gamemodes/fretta/gamemode/cl_hud.lua:182
2. HUDPaint - addons/prop hunt/gamemodes/fretta/gamemode/cl_hud.lua:256
3. unknown - addons/prop hunt/gamemodes/fretta/gamemode/cl_hud.lua:254
[/CODE]
This is the code I'm using
[CODE]
if ply:Team() == TEAM_HUNTERS && ply:Alive() then
if (ply:GetActiveWeapon():GetPrintName() != nil) then
draw.DrawText(ply:GetActiveWeapon():GetPrintName(), "shudfont69", ScrW()/1.29, ScrH()/1.16, Color(255,255,255,255))
end
end
[/CODE]
Try this:
[code]if ply:Alive() && ply:Team() == TEAM_HUNTERS then
local wep = ply:GetActiveWeapon()
if ( IsValid( wep )) then
draw.DrawText(wep.GetPrintName and wep:GetPrintName() or wep:GetClass(), "shudfont69", ScrW()/1.29, ScrH()/1.16, Color(255,255,255,255))
end
end[/code]
[QUOTE=code_gs;49574532]Try this:
[code]if ply:Alive() && ply:Team() == TEAM_HUNTERS then
local wep = ply:GetActiveWeapon()
if ( IsValid( wep )) then
draw.DrawText(wep.GetPrintName and wep:GetPrintName() or wep:GetClass(), "shudfont69", ScrW()/1.29, ScrH()/1.16, Color(255,255,255,255))
end
end[/code][/QUOTE]
damn i didnt think of making sure it checked if it was a valid weapon thanks!
Sorry, you need to Log In to post a reply to this thread.