Cl_init.lua not working

Hey

Everytime i put some code in the cl_init.lua, the entity doenst want to list in the entities tab.

init.lua


AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_init.lua" )
include( "shared.lua" )
util.AddNetworkString("OpenPoliceMenu") 
util.AddNetworkString("SpawnCar") 

local doAgain = 0

function ENT:Initialize()
	self:SetModel("models/props/cs_assault/TicketMachine.mdl")
	
	self:PhysicsInit(SOLID_VPHYSICS)
    self:SetMoveType(MOVETYPE_VPHYSICS)
    self:SetSolid(SOLID_VPHYSICS)
	local phys = self:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end
end

function ENT:Use( ply, caller)
	if ( ply:IsPlayer()) then
		if doAgain == 0 then
			ply:ChatPrint("Hej")
			if ply:Team() == TEAM_POLICE then
				ply:ChatPrint("Hej2")
				net.Start("OpenPoliceMenu")
				net.Send(activator)
				doAgain = 1
				timer.Simple(2, function()
					doAgain = 0
				end)
			else
				ply:ChatPrint("You are not a police")
				if ply:Team() == TEAM_SWATLEADER then
					ply:ChatPrint("You are a swat")
				else
					ply:ChatPrint("You are not a swat")
				end
			end
		end
	end
end

Cl_init.lua


net.Receive( "myMessage", function( length, client )
	print( "I got it!" )
end )

There is no errors

What does your shared.lua file look like?

EDIT: This is working for me:

cl_init.lua
[lua]include(‘shared.lua’)

function ENT:Draw()
self:DrawModel() --This isn’t needed, just part of my copy/paste
end

net.Receive( “myMessage”, function( length, client )
print( “I got it!” )
end )[/lua]

init.lua
[lua]AddCSLuaFile( “shared.lua” )
AddCSLuaFile( “cl_init.lua” )
include( “shared.lua” )
util.AddNetworkString(“OpenPoliceMenu”)
util.AddNetworkString(“SpawnCar”)

local doAgain = 0

function ENT:Initialize()
self:SetModel(“models/props/cs_assault/TicketMachine.mdl”)

self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
	phys:Wake()
end

end

function ENT:Use( ply, caller)
if ( ply:IsPlayer()) then
if doAgain == 0 then
ply:ChatPrint(“Hej”)
if ply:Team() == TEAM_POLICE then
ply:ChatPrint(“Hej2”)
net.Start(“OpenPoliceMenu”)
net.Send(activator)
doAgain = 1
timer.Simple(2, function()
doAgain = 0
end)
else
ply:ChatPrint(“You are not a police”)
if ply:Team() == TEAM_SWATLEADER then
ply:ChatPrint(“You are a swat”)
else
ply:ChatPrint(“You are not a swat”)
end
end
end
end
end[/lua]

shared.lua
[lua]ENT.Type = ‘anim’; – Gotta h
ENT.Base = ‘base_gmodentity’; – Make sure you have a base, although I’m pretty sure it would return errors if you didn’t

ENT.PrintName = ‘Test_Entity’;
ENT.Author = ‘Luyten’;
ENT.Category = ‘Drugz’; – You might need to throw it into a category if you haven’t

ENT.Spawnable = true;[/lua]

What exactly are you adding to cl_init?

Going to point out that you haven’t pooled the Network String “myMessage” but that shouldn’t be causing this issue.

I found out that i forgot to put include(shared.lua) in the cl_init. But i cant get the derma window to open.

cl_init.lua



include("shared.lua")

net.Receive("OpenPoliceMenu", function()
	local Frame = vgui.Create( "DFrame" )
	Frame:SetPos( 5, 5 )
	Frame:SetSize( 300, 150 )
	Frame:SetTitle( "Name window" )
	Frame:SetVisible( true )
	Frame:SetDraggable( false )
	Frame:ShowCloseButton( true )
	Frame:MakePopup()
end)


init.lua is the same as in the first post.