Hud Errors

I recently updated my hud to 2.4 and when I want someone I get this


[ERROR] addons/darkrpmodification/lua/darkrp_modules/hudreplacement/cl_hudreplacement.lua:332: attempt to call method 'RPIsInSight' (a nil value)
  1. DrawWantedInfo - addons/darkrpmodification/lua/darkrp_modules/hudreplacement/cl_hudreplacement.lua:332
   2. DrawEntityDisplay - addons/darkrpmodification/lua/darkrp_modules/hudreplacement/cl_hudreplacement.lua:376
    3. unknown - addons/darkrpmodification/lua/darkrp_modules/hudreplacement/cl_hudreplacement.lua:419

332: if not pos:RPIsInSight({localplayer, ply}) then return end
376: if ply.DarkRPVars.wanted then DrawWantedInfo(ply) end
419: DrawEntityDisplay()
Can someone help me convert that to darkrp 2.5?

RPIsInSight -> isInSight

[editline]31st January 2014[/editline]

Also, not related to the error but, for your DarkRPVars it would be safer to use ply:getDarkRPVar(“wanted”) than ply.DarkRPVars.wanted (not just the “wanted” var but all of them).

k thanks now line 376 and 419 need to to be converted

[editline]31st January 2014[/editline]

Anyone else?

No they don’t. They should be fine. The error isn’t a list of bad lines, it’s a stack trace.

Line 419 calls DrawEntityDisplay() which then reaches line 376 which calls DrawWantedInfo(ply) which reaches 332 then errors. Fix the error on 332 (as shown in my previous post) then everything should work fine.

Ok I am getting this now


 [ERROR] addons/darkrpmodification/lua/darkrp_modules/hudreplacement/cl_hudreplacement.lua:376: '<name>' expected near '('
  1. unknown - addons/darkrpmodification/lua/darkrp_modules/hudreplacement/cl_hudreplacement.lua:0


[editline]31st January 2014[/editline]

This is the line


 	if ply.DarkRPVars.wanted then DrawWantedInfo(ply) end 

We’ll need a couple lines before and after as it’s not on that line.


/*---------------------------------------------------------------------------
The Entity display: draw HUD information about entities
---------------------------------------------------------------------------*/
local function DrawEntityDisplay()
	local shootPos = LocalPlayer():GetShootPos()
	local aimVec = LocalPlayer():GetAimVector()

	for k, ply in pairs(player.GetAll()) do
		if not ply:Alive() then continue end
		local hisPos = ply:GetShootPos()

		ply.DarkRPVars = ply.DarkRPVars or {}
		if ply.DarkRPVars.wanted then DrawWantedInfo(ply) end
		if GAMEMODE.Config.globalshow and ply ~= LocalPlayer() then
			DrawPlayerInfo(ply)
		-- Draw when you're (almost) looking at him
		elseif not GAMEMODE.Config.globalshow and hisPos:Distance(shootPos) < 400 then
			local pos = hisPos - shootPos
			local unitPos = pos:GetNormalized()
			if unitPos:Dot(aimVec) > 0.95 then
				local trace = util.QuickTrace(shootPos, pos, LocalPlayer())
				if trace.Hit and trace.Entity ~= ply then return end
				DrawPlayerInfo(ply)
			end
		end
	end

	local tr = LocalPlayer():GetEyeTrace()

	if tr.Entity:isKeysOwnable() and tr.Entity:GetPos():Distance(LocalPlayer():GetPos()) < 200 then
		tr.Entity:drawOwnableInfo()
	end
end