• A blank gamemode, and yet errors are here.
    3 replies, posted
Okay, my last gamemode gave off errors where it couldn't find files, i thought it must be somewhere in my code so i'll just start a fresh one. without adding custom code i got errors... [CODE]Couldn't include file 'shared.lua' (File not found) (@gamemodes/game2/gamemode/cl_init.lua (line 1))[/CODE] when i save my init.lua: [CODE][AddCSLuaFile] Couldn't find 'cl_init.lua' (@gamemodes/game2/gamemode/init.lua (line 1)) [AddCSLuaFile] Couldn't find 'shared.lua' (@gamemodes/game2/gamemode/init.lua (line 2)) Couldn't include file 'shared.lua' (File not found) (@gamemodes/game2/gamemode/init.lua (line 4)) [/CODE] Now, heres the code: Init.lua: [CODE]AddCSLuaFile('cl_init.lua') AddCSLuaFile('shared.lua') include('shared.lua') function GM:PlayerInitialSpawn( ply ) ply:PrintMessage(HUD_PRINTTALK, 'You have entered the game.') end[/CODE] cl_init.lua: [CODE]include('shared.lua')[/CODE] shared.lua [CODE]GM.Name = "Game2" GM.Auther = "N/A" GM.Email = "N/A" GM.Website = "N/A" function GM:Initialize() end DeriveGamemode("sandbox") team.SetUp( 1, "User", Color( 255, 255, 255, 255 ) ) team.SetUp( 2, "Admin", Color( 25, 255, 25, 255) )[/CODE] <Game name>.txt [CODE]"Game2" { "base" "base" "title" "Game2" "maps" "^gt_" "menusystem" "1" "workshopid" "" }[/CODE] Please help, it wont let me add external files or even use the shared one.
you have the wrong folder set up or gmod cant read from it. it should be /pathtogmod/garrysmod/gamemodes/game2/gamemode/cl_init.lua and so on.
Yes, my directory is garrysmod/garrysmod/gamemodes/game2/gamemode/filename.lua and strangly it gives off the errors listed above
Since the files are NOT empty, you may be AddCSLuaFile'ing the wrong order... Basically, you're telling the client about cl_init.lure before you notify them of sh_init.lua ( this may or may not make a difference; I've seen cases where it has, and cases where it was something odd ). Here's what I do ( I don't like using "shared.lua", personal preference... ): init.lua [code]// // // AddCSLuaFile( "sh_init.lua" ) AddCSLuaFile( "cl_init.lua" ) include( "sh_init.lua" );[/code] cl_init.lua [code]// // // include( "sh_init.lua" ); [/code] sh_init.lua [code]// // // -- EVERYTHING.... Load order as follows: -- Shared code // Client / Server if ( CLIENT ) then else end -- Addons / Modules -- Content ( game-mode specific data such as vehicles, etc ) [/code] Essentially, instead of repeating code in init/cl_init, I set sh_init to include / AddCSLuaFile all game-mode files ( because the way shared code works, is it only executes on each realm so you can set if SERVER then .. else .. end to include files etc -- shared should always come first, then client/server, then addons then content ).. If you want to work with a simple system that will manage everything for you, take a look at my auto-loader: [url]https://bitbucket.org/Acecool/acecooldev_base/src/[/url] [url]https://bitbucket.org/Acecool/acecooldev_base/downloads[/url] Full-folder structure is here because bitbucket doesn't allow empty folders and files haven't been added everywhere yet ( just extract to the gm directory ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_redistributable/acecooldev_base_folder_struct.rar[/url] It is a skeletonized-developer-base game-mode which essentially only includes the autoloader ( to avoid having to mess with including files ever again ), useful functons / addon-hooks, useful CONSTs / Enumeration, etc... It includes documentation which tells you how to re-name the game-mode to use a different folder-name / base-name. It checks prefix / postfix on files to determine the realm the file should load in, it also changes active-realm for client/server/shared folders, and maps/ directories autoload maps/<map_name>/* in shared-mode at InitPostEntity and OnReloaded. It also supports "loadgm" console command which refreshes the game-mode ( useful for users that don't have access to auto-refresh because of OS, or if you drag-n-drop a new file into the game-mode... If you add a new file, loadgm once, then make a simple change in the file and save it; previously you'd have to add, auto-refresh 1-2 times, then edit it or each realm 1-2 times before saving it 1-2 times )...
Sorry, you need to Log In to post a reply to this thread.