The Hatmode without Sandbox gamemode.

Okey, so im making a little gamemode, and is not derived in sandbox. (Not sure if it has anything to do with it, but anyways…)

I’ve added the antlion hat (from the hat mode) to the entities and i’ve tried to spawn it… it spawns, i use it, and then this awful error burns my eyes from the console:



entities/antlion_head/cl_init.lua:24: attempt to call method 'GetRagdollEntity' (a nil value)


this is the code:
[lua]
include(“shared.lua”)

function ENT:Think()

if self.Entity:GetOwner():GetNWBool(“Camera”) == true then
if LocalPlayer() == not self.Entity:GetOwner() then
self.Entity:SetColor(255,255,255,255)
elseif LocalPlayer() == self.Entity:GetOwner() then
self.Entity:SetColor(255,255,255,255)
end

elseif self.Entity:GetOwner():GetNWBool(“Camera”) == false then
if LocalPlayer() == not self.Entity:GetOwner() then
self.Entity:SetColor(255,255,255,255)
elseif LocalPlayer() == self.Entity:GetOwner() then
self.Entity:SetColor(0,0,0,0)
end
end
end

function ENT:Draw()
local owner = self.Entity:GetOwner()

if owner:GetRagdollEntity() then
	owner = owner:GetRagdollEntity()
elseif not owner:Alive() then return end

local boneindex = owner:LookupBone("ValveBiped.Bip01_Head1")
if boneindex then
	local pos, ang = owner:GetBonePosition(boneindex)
	if pos and pos ~= owner:GetPos() then
		self.Entity:SetPos(pos + ang:Forward()*6 + ang:Right()*4)
		ang:RotateAroundAxis(ang:Up(),90)
		ang:RotateAroundAxis(ang:Forward(),270)
		ang:RotateAroundAxis(ang:Right(), 180)
		self.Entity:SetAngles(ang)
		self.Entity:DrawModel()
		return
	end


local attach = owner:GetAttachment(owner:LookupAttachment("eyes"))
if not attach then attach = owner:GetAttachment(owner:LookupAttachment("head")) end
if attach then
	self.Entity:SetPos(attach.Pos)
	self.Entity:SetAngles(attach.Ang)
	self.Entity:DrawModel()
end
end

end
[/lua]

I guess the player has to die first or you have to use Player:CreateRagdoll()

Your problem is you’re using “self.Entity:GetOwner()”. Using GetOwner() requires that you personally used SetOwner() to begin with, and I doubt that. You were trying to use GetRagdollEntity on a nil value. Try this
owner = self.Owner



attempt to index local "owner" (a nil value)


I’ve been smacking around a little, and figured it must be because the entity is using “base_gmodentity”, i’ve tried to spawn more entities that uses this type of base, and they all do the same thing. It keeps saying "ERROR: Trying to derive entity entity name from non existant entity base_gmodentity*, i believe i must “Steal” the entity from sandbox gamemode then! testing

[editline]12:36PM[/editline]



entities/antlion_head/init.lua:45: attempt to call method 'GetViewEntity' (a nil value)
entities/antlion_head/cl_init.lua:24: attempt to call method 'GetRagdollEntity' (a nil value)


still get the same errors+++, strange!