Lots of problems writing a gamemode

So, I took a lot of general Lua tutorials off the website, and then I took a few derma/vgui and gamemode tutorials off the wiki. After that, I tried to write the basic backbone of a custom darkrp type gamemode. After the basics were done and I thought it might work, I ran it and it had a list of problems:

  • It said it was made by Garry Newman.
  • It said it was called base gamemode or something like that.
  • None of my derma menus worked.
  • It gave me some weapons that I didn’t say to give me and didn’t give me some weapons I didn’t say not to.
  • It didn’t recognize my attempted admin status.
  • Couldn’t open the spawn menu.
  • None of the console commands I made worked.
    Then I figured I must have messed up pretty bad. I can’t figure why any of these are happening really and I’m not sure where to go from here. I thought then that maybe someone here could help me with my problem if i posted the code so here it is:


AddCDLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "admins.lua"

include( 'shared.lua' )
include( 'admins.lua' )

function GM:PlayerInitialSpawn( ply )
	ply:ConCommand( "modelselect" )
	admincheck( ply )

function GM:PlayerLoadout( ply )
	if ply:Team() == 1 then
		ply:Give( "weapon_physcannon" )
	elseif ply:Team() == 2 then
		ply:Give( "weapon_physcannon" )

function gocitizen( ply )
	ply:SetTeam( 1 )

function gocook( ply )
	ply:SetTeam( 2 )

concommand.Add( "changejob_citizen", gocitizen )
concommand.Add( "changejob_cook", gocook ) 


include( 'shared.lua' )

function modelselect()
	local model = {}
	model[1] = "models/Humans/Group01/Female_01.mdl"
	model[2] = "models/Humans/Group01/Female_02.mdl"
	model[3] = "models/Humans/Group01/Female_03.mdl"
	model[4] = "models/Humans/Group01/Female_04.mdl"
	model[5] = "models/Humans/Group01/Female_06.mdl"
	model[6] = "models/Humans/Group01/Female_07.mdl"
	model[7] = "models/Humans/Group01/Male_01.mdl"
	model[8] = "models/Humans/Group01/male_02.mdl"
	model[9] = "models/Humans/Group01/male_03.mdl"
	model[10] = "models/Humans/Group01/Male_04.mdl"
	model[11] = "models/Humans/Group01/Male_05.mdl"
	model[12] = "models/Humans/Group01/male_06.mdl"
	model[13] = "models/Humans/Group01/male_07.mdl"
	model[14] = "models/Humans/Group01/male_08.mdl"	
	model[15] = "models/Humans/Group01/male_09.mdl"
	model[16] = "models\Humans/Group03m/male_09.mdl"
	model[17] = "models\Humans/Group02/Female_01.mdl"
	model[18] = "models\Humans/Group02/Female_02.mdl"
	model[19] = "models\Humans/Group02/Female_03.mdl"
	model[20] = "models\Humans/Group02/Female_04.mdl"
	model[21] = "models\Humans/Group02/Female_06.mdl"
	model[22] = "models\Humans/Group02/Female_07.mdl"
	model[23] = "models\Humans/Group02/Male_01.mdl"
	model[24] = "models\Humans/Group02/male_02.mdl"
	model[25] = "models\Humans/Group02/male_03.mdl"
	model[26] = "models\Humans/Group02/Male_04.mdl"
	model[27] = "models\Humans/Group02/Male_05.mdl"
	model[28] = "models\Humans/Group02/male_06.mdl"
	model[29] = "models\Humans/Group02/male_07.mdl"
	model[30] = "models\Humans/Group02/male_08.mdl"
	model[31] = "models\Humans/Group02/male_09.mdl"
	model[32] = "models\Humans/Group03/Female_01.mdl"	
	model[33] = "models\Humans/Group03/Female_02.mdl"
	model[34] = "models\Humans/Group03/Female_03.mdl"
	model[35] = "models\Humans/Group03/Female_04.mdl"
	model[36] = "models\Humans/Group03/Female_06.mdl"
	model[37] = "models\Humans/Group03/Female_07.mdl"
	model[38] = "models\Humans/Group03/Male_01.mdl"		
	model[39] = "models\Humans/Group03/male_02.mdl"
	model[40] = "models\Humans/Group03/male_03.mdl"
	model[41] = "models\Humans/Group03/Male_04.mdl"
	model[42] = "models\Humans/Group03/Male_05.mdl"
	model[43] = "models\Humans/Group03/male_06.mdl"		
	model[44] = "models\Humans/Group03/male_07.mdl"			
	model[45] = "models\Humans/Group03/male_08.mdl"
	model[46] = "models\Humans/Group03/male_09.mdl"		
	model[47] = "models\Humans/Group03m/Female_01.mdl"	
	model[48] = "models\Humans/Group03m/Female_02.mdl"	
	model[49] = "models\Humans/Group03m/Female_03.mdl"	
	model[50] = "models\Humans/Group03m/Female_04.mdl"
	model[51] = "models\Humans/Group03m/Female_06.mdl"
	model[52] = "models\Humans/Group03m/Female_07.mdl"
	model[53] = "models\Humans/Group03m/Male_01.mdl"
	model[54] = "models\Humans/Group03m/male_03.mdl"		
	model[55] = "models\Humans/Group03m/Male_04.mdl"		
	model[56] = "models\Humans/Group03m/Male_05.mdl"
	model[57] = "models\Humans/Group03m/male_06.mdl"
	model[58] = "models\Humans/Group03m/male_07.mdl"
	model[59] = "models\Humans/Group03m/male_08.mdl"
	local frame = vgui.Create( "DFrame" )
	local IconList = vgui.Create( "DPanelList", frame )
	frame:SetSize( 220, 200 )
	frame:SetTitle( "Choose Your Model" )
	IconList:EnableVerticalScrollbar( true )
	IconList:SetPadding( 4 )
	IconList:SetPos( 10, 30 )
	IconList:SetSize( 200, 160 )
	for k,v in pairs(model) do
	local icon = vgui.Create( "SpawnIcon", IconList )
	icon:SetModel( v )
	IconList:AddItem( icon )
	icon.DoClick = function( icon )
			surface.PlaySound( "ui/buttonclickrelease.wav" ) 
			RunConsoleCommand( "cl_playermodel", v )

function job_menu()
	local frame = vgui.Create( "DFrame" )
	frame:SetSize( 220, 200 )
	frame:SetTitle( "Choose Your Job" )
	local citizen = vgui.Create( "DButton", frame )
	citizen:SetSize( 30, 10 )
	citizen:SetPos( 10, 10 )
	citizen:SetText( "Citizen" )
	citizen.DoClick function()
		RunConsoleCommand( "changejob_citizen" )
	local cook = vgui.Create( "DButton", frame )
	cook:SetSize( 30, 10 )
	cook:SetPos( 50, 10 )
	cook:SetText( "Cook" )
	cook.DoClick function()
		RunConsoleCommand( "changejob_cook" )

concommand.Add( "changemodel", modelselect )
concommand.Add( "changejob", job_menu )


GM.Name = "ShinyRP"
Gm.Author = "Smitten"
GM.Email = "Smittenburrito@yahoo.com"
GM.Website = "N/A"

team.SetUp( 1, "Citizen", Color( 50, 255, 50, 255 ) ) 
team.SetUp( 2, "Cook", Color( 230, 100, 120 ) )


function admincheck( ply )
	if ( ply:SteamID() == "STEAM_0:1:16506575" ) then
		ply:PrintMessage( HUD_PRINTTALK, "Welcome Smitten, You're connected under the IP address: "..ply:IPAddress() )
		ply:Give( "gmod_tool" )
		ply:Give( "weapon_physgun" )

I know it must be pretty bad, and i know there’s a lot there but it would be VERY VERY much appreciated if someone could take a look.

The very first line in init.lua

AddCDLuaFile() Is not a function, D should be S

Everything else looks ok from a scan.

Thank you for pointing that out, lol I wasn’t looking for spelling mistakes. Though, surprisingly, it didn’t seem fix anything :frown:

Whats the foldername of your gamemode? If it has a space in it, remove the space and it shall work.

These files are in garrysmod/gamemodes/ShinyRP/gamemode

In the console, type gamemode_reload. Tell me what the error is.

Reloading Gamemode..
ShinyRP/gamemode/init.lua:5: ')' expected (to close '(' at line 3) near 'include'
********** COULDN'T LOAD GAMEMODE!! **********

There was a problem opening the gamemode file 'ShinyRP/gamemode/init.lua'

Registering gamemode 'ShinyRP' derived from 'base'
ScriptEnforce is disabled
Reloading Gamemode..
ShinyRP/gamemode/cl_init.lua:100: '=' expected near 'function'
********** COULDN'T LOAD GAMEMODE!! **********

There was a problem opening the gamemode file 'ShinyRP/gamemode/cl_init.lua'

Registering gamemode 'ShinyRP' derived from 'base'

Well I feel kinda stupid

Line 3 of init.lua:

AddCSLuaFile( "admins.lua")

Line 100 of cl_init.lua:

citizen.DoClick = function()

Well now, a lot of problems are fixed but some still remain.

  • It says its called ShinyRP but its still by Garry Newman.
  • My console commands work but they don’t run on spawn.
  • There’s some derma size relation issues that I can fix.
  • People don’t respawn when they change model/job, is there a way to do this without running kill through the script?
  • A lot of the spawn icons in the changemodel menu are shown as errors.

function gocitizen( ply )
	ply:SetTeam( 1 )

function gocook( ply )
	ply:SetTeam( 2 )

function GM:PlayerInitialSpawn( ply )
	ply:ConCommand( "changemodel" )
	admincheck( ply )

Thank you for your help :smile:.
Now the problem is it saying its by Garry, if that even is a problem.

You have

Gm.Author = "Smitten"

When lua is case sensitive.

GM.Author = "Smitten"

Wow thank you! :smile:
One more problem that you really don’t have to help with because I didn’t mention it originally until now, is there a command I can put in the buttons on the derma menus that close them automatically when you click a button?

I guess you would do

	cook.DoClick function()
		RunConsoleCommand( "changejob_cook" )

Thank you so much!

Your welcome.