[HELP] - Couldn't include file 'sh_vitals.lua' (File not found)

Don’t know why at all but the file “cant be found” It runs initially i know that, but then it just stops. From what I’ve read this happens when there is a error in the code and the server doesn’t know what to do with it. I can’t find said error, I can’t find why there would be a error as this file uses the same format as another file I’m using, I checked I’m not using duplicating functions or anything like that!


local meta = FindMetaTable("Player")

/*=======================================
		Adding to Vitals!!
=======================================*/
function meta:AddHunger( amounth )
	local current_hunger = self:GetHunger()
	self:SetHunger( current_hunger + amount )
	self:SaveVitalsTXT()
end

function meta:AddThrist( amountt )
	local current_thirst = self:GetThirst()
	self:SetThirst( current_thirst + amount )
	self:SaveVitalsTXT()
end

function meta:AddFatigue( amountf )
	local current_fatigue = self:GetFatigue()
	self:SetFatigue( current_fatigue + amount )
	self:SaveVitalsTXT()
end

/*=======================================
		Taking From Vitals!!
=======================================*/

function meta:TakeHunger(amounth)
	local current_hunger = self:GetHunger()
	self:SetHunger( current_hunger - amount )
	self:SaveVitalsTXT()
end

function meta:TakeThirst(amountt)
	local current_thirst = self:GetThirst()
	self:SetThirst( current_thirst - amount )
	self:SaveVitalsTXT()
end

function meta:TakeFatigue(amountf)
	local current_fatigue = self:GetFatigue()
	self:SetFatigue( current_fatigue - amount )
	self:SaveVitalsTXT()
end

/*=======================================
		Setting Vitals!!
=======================================*/
 
function meta:SetHunger( amounth )
	self:SetNWInt( "hunger", tonumber( amounth ) )
	self:SaveVitalsTXT()
end

function meta:SetThirst( amountt )
	self:SetNWInt( "thirst", tonumber( amountt ) )
	self:SaveVitalsTXT()
end

function meta:SetFatigue( amountf )
	self:SetNWInt( "fatigue", tonumber( amountf ) )
	self:SaveVitalsTXT()
end

/*=======================================
		Vitals TXT Exists
=======================================*/

function meta:vitalsExists()
	local f = file.Exists(self:vitalsPath(), "DATA")
	return f
end

/*=======================================
		Folders CreateDir
=======================================*/

function meta:vitalsCreate()
	local b = file.CreateDir( self:vitalsFolders() )
	file.Write( self:vitalsPath() )
	
	self:SetHunger( 100 )
	self:SetThirst( 100 )
	self:SetFatigue( 100 )
	
	self:SaveVitalsTXT()
end

/*=======================================
		Folders CheckDir
=======================================*/

function meta:vitalsCheck()
	local f = self:vitalsExists()
	if f then
		self:vitalsRead()
	else
		self:vitalsCreate()
	end
end

/*=======================================
		Folders Read
=======================================*/

function meta:vitalsRead()	
	local str = file.Read( self:vitalsPath(), "DATA" )
	local tab =	util.KeyValuesToTable( str )
	self:SetHunger( tab.hunger )
	self:SetThirst( tab.thirst )
	self:SetFatigue( tab.fatigue )
end

/*=======================================
		Folders Path
=======================================*/

function meta:vitalsPath()
	return self:vitalsFolders() .. "vitals.txt"
end

/*=======================================
		Folders
=======================================*/

function meta:vitalsFolders()
	return "print4life/players/"..self:ShortSteamID().."/"
end

/*=======================================
		Saving META
=======================================*/

function meta:SaveVitalsTXT()
	local hng  = self:GetHunger()
	local thr  = self:GetThirst()
	local fat  = self:GetFatigue()
	
	local vit = {
				hunger = hng,
				thirst = thr,
				fatigue = fat
				}
	local sav  = util.TableToKeyValues( vit )
	local f = file.Write( self:vitalsPath(), sav )
end

/*=======================================
		Getting Vitals!
=======================================*/
 
function meta:GetHunger()
	return self:GetNWInt( "hunger" )
end

function meta:GetThirst()
	return self:GetNWInt( "thirst" )
end

function meta:GetFatigue()
	return self:GetNWInt( "fatigue" )
end

/*=======================================
	   Getting Vitals to String!
=======================================*/

function meta:GetHungerString()
	local hungerS = tostring( self:GetNWInt( "hunger" ) )
	
	return hungerS
end

function meta:GetThirstString()
	local thirstS = tostring( self:GetNWInt( "thirst" ) )
	
	return thirstS
end

function meta:GetFatigueString()
	local fatigueS = tostring( self:GetNWInt( "fatigue" ) )
	
	return fatigueS
end

anybody that can help please do :smiley:

this is obviously a shared file so I included it in both the cl_init and the init!

keep in mind I’m new to lua this code format sucks and will eventually be revised!

Is the error on the server side or client side? If it’s client side you need to first send it to client with http://wiki.garrysmod.com/page/Global/AddCSLuaFile from the server.

I’ll try that I didn’t think I would need to do that :stuck_out_tongue:

Ok tried it, just says [AddCSLuaFile] cant find ‘sh_vitals.lua’

Also it seems its server and client side error :slight_smile:

Where is the file located?

its located in the same file as the init and the cl_init

Ok I found a temporary fix it’ll work for now :stuck_out_tongue: