• Couldn't find 'cl_init.lua'
    12 replies, posted
I've been making a gamemode just to expand my knowledge towards LUA in doing so i encountered a problem when trying to add external files. ERROR: [CODE] [AddCSLuaFile] Couldn't find 'cl_init.lua' (@gamemodes/gamedotrpg/gamemode/init.lua (line 1)) [AddCSLuaFile] Couldn't find 'shared.lua' (@gamemodes/gamedotrpg/gamemode/init.lua (line 2)) Couldn't include file 'shared.lua' (File not found) (@gamemodes/gamedotrpg/gamemode/init.lua (line 3)) Couldn't include file 'admins.lua' (File not found) (@gamemodes/gamedotrpg/gamemode/init.lua (line 4)) [/CODE] It confuses me how it works 1 minute then fails to work the next. i have imported them like so: [CODE] AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") include("Admins.lua") [/CODE]
are they empty? if they're empty they don't get found
[QUOTE=PortalGod;45678672]are they empty? if they're empty they don't get found[/QUOTE] No, they are not empty, the cl_init & admins.lua have lines of code inside as does the shared [editline]13th August 2014[/editline] Heres the code inside each file init.lua [CODE]AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") include("Admins.lua") function GM:PlayerInitialSpawn( ply ) ply:SetTeam ( 1 ) getRank( ply ) //if table.HasValue(Admins, ply:SteamID()) then if ply.IsAdmin() then ply:SetTeam( 2 ) end end hook.Add( "PlayerInitialSpawn", "LoadStats", function( ply ) if ply:GetPData( "LEVEL" ) == nil then ply:SetPData( "LEVEL", 1 ) ply:SetNWInt( "LEVEL", 1 ) else ply:SetNWInt( "LEVEL", ply:GetPData() ) end end) function getRank(ply) if table.HasValue(Admins, ply:SteamID()) then ply.PrintMessage( HUD_PRINTCONSOLE, "Your rank is Admin "..ply:GetPData( "LEVEL" ) ) else ply.PrintMessage( HUD_PRINTCONSOLE, "Your rank is Player" ) end end function setLevel( ply, text, public ) local x = ply:SteamID() if( string.sub( text, 1, 8) == "!getrank" ) then ply:PrintMessage( HUD_PRINTTALK, "Your rank is admin." ) ply:PrintMessage( HUD_PRINTTALK, "Your rank is player." ) end end hook.Add( "PlayerSay", "setLevel", setLevel ) [/CODE] cl_init [CODE]include('shared.lua') function hideHUD( name ) if name == "CHudHealth" or name == "CHudBattery" then return false end end hook.Add("HUDShouldDraw","hideHUD", hideHUD) -- Heads Up Display Drawing function RPHUD() level = LocalPlayer():GetNWInt( "LEVEL" ) expGain = 100 expNeed = 1000 li = expNeed/expGain draw.RoundedBox( 0, 0, surface.ScreenHeight()-25, surface.ScreenWidth(), 25, Color(125, 125, 155, 200)) draw.RoundedBox( 0, 0, surface.ScreenHeight()-25, surface.ScreenWidth()/li, 25, Color(255, 0, 0, 200)) draw.DrawText( "LEVEL ".. level .." ("..expGain.."/"..expNeed..")", HUDNumber, surface.ScreenWidth()/2, surface.ScreenHeight()-20, Color(255, 255, 255), TEXT_ALIGN_CENTER) end hook.Add("HUDPaint", "RPHUD", RPHUD)[/CODE] shared [CODE]GM.Name = "GameDotRPG" GM.Auther = "N/A" GM.Email = "N/A" GM.Website = "N/A" team.SetUp( 1, "User", Color( 255, 255, 255, 255 ) ) team.SetUp( 2, "Admin", Color( 25, 255, 25, 255) )[/CODE] Admins [CODE]--Add/Remove players from here keep in order --DO NOT REMOVE Admins = {} as this is the table that holds the values of SteamIDs --Copy and paste this for a template Admins[<number>] = "STEAMID HERE" -- Name of player Admins = {} Admins[1] = "STEAM_0:0:0" -- Offline/singleplayer client local meta = FindMetaTable( "Player" ) function meta:IsLevel(LR) if self:GetNWInt( "LEVEL" ) == LR then return true else return false end end function meta:SaveLevel() self:SetPData( "LEVEL", self:GetNWInt( "LEVEL" ) ) end function meta:SetLevel(v) self:SetNWInt( "LEVEL", v ) self:SaveLevel() self.PrintMessage( HUD_PRINTCONSOLE, "Your level has been updated" ) end[/CODE]
Make sure none of them have any Lua errors in them. Just scroll the console and look for any. Make sure all names are lowercase, including the ones in the include() function.
I am quite confused, i changed Admins.lua to admins.lua and there are no errors apart from the joining hook that checks if they are in a table that is stored inside admins.lua [CODE] function getRank(ply) if table.HasValue(Admins, ply:SteamID()) then ply.PrintMessage( HUD_PRINTCONSOLE, "Your rank is Admin "..ply:GetPData( "LEVEL" ) ) else ply.PrintMessage( HUD_PRINTCONSOLE, "Your rank is Player" ) end end [/CODE] the errors only show up when i edit & save code, however i can't use anything inside those files
Scroll to the very first lua error you see, way up there... it might have a side effect which causes [i]this[/i] error.
Couldn't include file 'shared.lua' (File not found) (@gamemodes/gamedotrpg/gamemode/cl_init.lua (line 1)) only error apart from ERROR: Trying to derive entity base_wire_entity from non existant entity base_gmodentity! that is spammed for about 50 lines
Call AddCSLuaFile( "shared.lua" ) before AddCSLuaFile( "cl_init.lua" ) The wire error is likely because your gamemode isn't derived from sandbox. IIRC base_gmodentity is a sandbox entity.
Doesnt do anything. Question: how do i derive the gamemode to sandbox, ive tryed "base" "sandbox"
DeriveGamemode("sandbox") in shared.lua, too
ah, well i cant do that because shared.lua cant be found [editline]13th August 2014[/editline] Im so confused because it gave no hint to it being ply.IsAdmin() before it jsut broke everything, why does it not tell you why its broken? I fixed it once but its broke again and not for the same reason
It's ply:IsAdmin() All methods use : Didn't catch that before. Also, HUDPaint is likely causing you errors too. The hook gets called before LocalPlayer() is valid. Stick this on the first line of your HUDPaint function. [LUA]if( not IsValid(LocalPlayer() ) ) then return end[/LUA] edit: Eek, grammar. Other than the possibility of these or something else causing errors I'm not sure how else I could help. :(
It still returns the same errors, im so confused, i wouldn't be suprised if u gave up. Earlier in the morning it worked, then it broke however i removed the piece of code that was breaking it, but it is still broken.
Sorry, you need to Log In to post a reply to this thread.