Lua Help with gcombat

I’m trying to edit this code to fix the problem I’m having. The code follows:


function gcombat.validate( ent )




--->    if (ent:GetPhysicsObject():IsValid() and !ent:IsPlayer() and ent:GetClass() != "wreckedstuff" and !ent:IsWorld() and !ent:IsWeapon() and string.find(ent:GetClass(), "func_") != 1 ) then    <---
        if ent.cbt then return true else gcombat.registerent(ent) end
        return true
    end
    return false
end

And my problem with it is:


[addons\gcombat09\lua\autorun\server\sv_combatdamage.lua:16] attempt to index local 'ent' (a number value)


I am not that good at LUA scripting, but I’ve a basic understanding of it.
Help is appreciated!

This probably isn’t the right section because there is a lua forum on facepunch.

But the problem with the script is the value coming in called ‘ent’ is not an entity. What ever is calling the method is sending it a number and not an entity.

Yeah I noticed that as soon as I posted, anyhow… I’m posting the code that precedes the one i posted.



COMBATDAMAGEENGINE = 1

gcombat = {}

function gcombat.registerent( ent, health, armor )
	local h = ent:GetPhysicsObject():GetMass() * 4
	ent.cbt = {};
	ent.cbt.health = health or math.Clamp( h, 1, 4000 )
	ent.cbt.armor = armor or 8
	ent.cbt.maxhealth = health or math.Clamp( h, 1, 4000 )
end

function gcombat.validate( ent )

	if (ent:GetPhysicsObject():IsValid() and !ent:IsPlayer() and ent:GetClass() != "wreckedstuff" and !ent:IsWorld() and !ent:IsWeapon() and string.find(ent:GetClass(), "func_") != 1 ) then
		if ent.cbt then return true else gcombat.registerent(ent) end
		return true
	end
	return false
end

I don’t really see where the problem is :stuck_out_tongue:

Add the following after function gcombat.validate(ent)

[lua]
if ( !ValidEntity(ent) ) then
return false;
end;
[/lua]

that solved that problem, but now I’m getting another error:


[lua\includes\util.lua:176] attempt to index local 'object' (a number value)
T

and I can’t even find the file :S

Where is gcombat.validate() being called?

not sure what you’re asking for… but I’ll do my best

\addons\GCOMBAT09\lua\autorun\server\sv_combatdamage.lua
the script is trying to determine if the entity is a player or a prop or otherwise.