Addon issues

Hello… again. So, I made a Thread previous about this issue, I thought I had resolved the problem.
But I forgot that I was making a dermapanel, so I have to run it to get any run-time errors :confused:

However, I know have a better idea of what the problem is. So what I’m having problems with is the include function, things don’t appear to be working properly.
Now, I added the code

print( "[TUTORIAL] " .. v .. " has been added as question " .. QuestionQueue )

to see if they were actually added. According to console, they were. However, that’s only because it’s using the parameters, not the table. When I try to use the data from the parameters of the CreatePage function stored in a table local to the main file (cl_tutorial.lua), they don’t get stored properly inside the table somehow, and so I get errors when I try to use the variables within said table.

Here is the code of the functions and variables involved:


local ply = LocalPlayer()
local scale = ScrH() / 1080

local pages = {}

local queue = 1 -- Current page. This variable decides which page is being shown. Look into the CreatePage function, and in the "Main texts" in the frame.Paint function.
local tracker = 0

local CanClick = false
local CanTrackerChange = true

-- 'Command' functions.

local queueID = 0
function CreatePage( title, text, time )
	queueID = queueID + 1

	pages[queueID] = { title, text, time }
	print( "[TUTORIAL] " .. title .. " has been added as page " .. queueID )

local function StartCountDown( time )
	timer.Create("Countdown", time, 1, function()
		CanClick = true

local function EndCountDown()
	if ( timer.Exists("Countdown") ) then

function DrawQuestionnaire( AdminBool )
	AdminNetBool = net.ReadBool()

	if ( AdminBool == nil ) then
		AdminBool = false
		AdminBool = AdminBool

	if not ( AdminNetBool == nil ) then
		AdminBool = AdminNetBool

	local quest = vgui.Create("DFrame")
	quest:SetSize( 500 * scale, 800 * scale)
	quest:SetVisible( true )
	quest:SetDraggable( false )
	quest:SetBackgroundBlur( true )
	quest:SetSizable( false )
	quest:SetDeleteOnClose( true )

	if ( AdminBool == true ) then
		quest:ShowCloseButton( true )
		quest:ShowCloseButton( false )


	quest.Paint = function( s, w, h )
	    draw.RoundedBox( 0, 0, 0, w, h, Color( 150, 150, 150) )
	    draw.RoundedBox( 0, 0, 0, w, 0, Color(255, 255, 255) )

local QuestionQueue = 0
function CreateQuestion( text, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 )
	QuestionQueue = QuestionQueue + 1
	local ATable = { a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 }

	for k, v in pairs( ATable ) do
		if ( v == nil ) then
			table.remove( ATable, v )

	local box = vgui.Create("DComboBox", quest)
	box:SetPos( 470 * scale, (125 * QuestionQueue) * scale )
	box:SetSize( 120, 50 )
	box.Paint = function( s, w, h )
	    draw.RoundedBox( 0, 0, 0, w, h, Color( 180, 180, 180 ) )

	for k, v in pairs( ATable ) do
		box:AddChoice(v, nil, false)

		print( "[TUTORIAL] " .. v .. " has been added as question " .. QuestionQueue )

	local label = vgui.Create("DLabel", quest)
	label:SetPos( 20 * scale, (125 * QuestionQueue) )
	label:SetSize( 800, 50 )
	label:SetText( text )
	label:SetTextColor( Color( 150, 150, 150 ) )

local function DrawTutorialDerma()

	StartCountDown( pages[queue][3] )
	PrintTable( pages )

	local frame = vgui.Create("DFrame")
	frame:SetSize( 1200 * scale, 840 * scale )
	frame:SetVisible( true )
	frame:SetDraggable( false )
	frame:SetBackgroundBlur( true )
	frame:SetSizable( false )
	frame:SetDeleteOnClose( true )
	frame:ShowCloseButton( true )

	frame.Paint = function( s, w, h )

	    -- Layout
	    draw.RoundedBox( 3, 0, 0, w, h, Color(30, 30, 30) )
	    draw.RoundedBox( 3, 6 * scale, 6 * scale, (w - 12) * scale, (h - 12) * scale, Color( 70, 70, 70) )

	    draw.RoundedBox( 0, 435 * scale, 682 * scale, 350 * scale, 150 * scale, Color(90, 90, 90) )
	    draw.RoundedBox( 0, 106 * scale, 814 * scale, 990 * scale, 20 * scale, Color(90, 90, 90) )
	    -- Main Texts
	    draw.DrawText( pages[queue][1], "HeaderFont", 495 * scale, 35 * scale, Color(120, 120, 255), TEXT_ALIGN_LEFT )
	    draw.DrawText( pages[queue][2], "TextFont", 50 * scale, 100 * scale, Color(120, 120, 255), TEXT_ALIGN_LEFT )

	    -- Page Text
	    draw.DrawText( "Page " .. queue .. "/" .. #pages, "CenterPrintText", 10 * scale, 10 * scale, Color(120, 120, 255), TEXT_ALIGN_LEFT )

	    -- Timer
	    if ( CanClick == false ) then
	    	draw.DrawText( math.Round( timer.TimeLeft("Countdown") ), "TimeFont", 590 * scale, 744 * scale, Color(255, 0, 0), TEXT_ALIGN_LEFT)
	        draw.DrawText( "Done!", "TimeFont", 560 * scale, 744 * scale, Color(255, 0, 0), TEXT_ALIGN_LEFT)

    -- UI
    local Pbutton = vgui.Create("DButton", frame)
    Pbutton:SetSize( 100 * scale, 50 * scale )
    Pbutton:SetPos( 6 * scale, 784 * scale )
    Pbutton:SetText( "Previous" )

    Pbutton.Paint = function( s, w, h )
        draw.RoundedBox( 0, 0, 0, w, h, Color(170, 170, 170) )

    Pbutton.DoClick = function()
        if ( queue == 1 ) then
            queue = 1

        	CanClick = true
        	queue = queue - 1


    -- These are simply the 'next' and 'previous' buttons, not relevant.
    local Nbutton = vgui.Create("DButton", frame)
    Nbutton:SetSize( 100 * scale, 50 * scale )
    Nbutton:SetPos( 1094 * scale, 784 * scale )
    Nbutton:SetText( "Next" )

    Nbutton.Paint = function( s, w, h )
       if ( CanClick == false ) then
       	   draw.RoundedBox( 0, 0, 0, w, h, Color(115, 70, 70) )
       		draw.RoundedBox( 0, 0, 0, w, h, Color(170, 170, 170) )

    Nbutton.DoClick = function()

        if ( queue == #pages ) then

        if ( CanClick == true ) then
        	if ( queue == #pages ) then
        		queue = #pages

        		if ( tracker > queue ) then
        		    CanClick = true

        		    CanTrackerChange = false
        			CanClick = false

        			StartCountDown( pages[queue][3] )
        			CanTrackerChange = true
        		queue = queue + 1
        		if ( CanTrackerChange == true ) then
        			tracker = queue

net.Receive("CallQuestions", DrawQuestionnaire)
net.Receive("CallDerma", DrawTutorialDerma )


CreatePage("Welcome", [[
	Hello and welcome to *******  Vietnam RP Server. Before you begin you must -- I edited out the server name so I can avoid advertising.
	complete this brief tutorial. If you have any questions please feel free to type @ (Your Message) 
	in the chat box to our staff team. Join our teamspeak at ********** and our forums 
	at ********.com. And remember to have fun. 
	]], 15)

CreatePage("United States", [[
	You will first start off as a 23rd Enlisted Private. You will be tasked with the grunt work of 
	the operations located here in Vietnam. Going on patrols, standing watch and eliminating the 
	Viet Cong threat. You will take orders from NCO’s (Non-commissioned officers) and your CO’s 
	(Commissioned Officers). You will salute your CO’s. You will take orders from those higher then you and if you are deemed worthy raise in the ranks until you are called sir and addressed with the same respect expected of you towards your superiors. 
	]], 25)

CreatePage("United States Procedures", [[
	Your allies are the Canadians and all other Americans. Your enemies are the Cubans, 
	Russians and the Viet Cong. Be wary of civilians if they are armed they are to either be detained 
	or taken out by force. Anyone not allowed in the base is Kill on Sight or (KOS). Remember to 
	strip and gag all prisoners via typing /me strips and gangs. If you are called to debrief you must 
	]], 25)

CreatePage("Viet Cong", [[
	As a soldier in the Viet Cong you will start off at the lowest rank and will be tasked with 
	the same grunt work as the 23rd Enlisted Private. Going on scouting missions, preparing 
	ambushes and removing the hostile threat to your home land. You will take orders from your 
	elders and mentors.
	]], 25)

CreatePage("Viet Cong Procedures", [[
	You are allied with the Russians and Cubans. You are enemies with the Americans and 
	the Canadians. You can task civilians with attacking the United States through whatever means 
	including suicidal missions. All enemies are KOS. Their is no room for negotiation. If you are to 
	somehow detain a prisoner, torture him/her until you have all needed information and either 
	ransom them off or kill them. If you are called to debrief you must attend. 
	]], 25)

CreatePage("Formations", [[
	Left Face- 90 Degree turn to the left 
    Right Face- 90 Degree turn to the right 
    About Face- 180 Degree turn Clockwise
    Column- A vertical line facing the superior
    Double Column- Two vertical lines facing the superior with enough room in between them for the superior to walk through.  
	]], 25)

CreatePage("Overall Server Rules", [[
	Only Pilots may fly. 
    RDM is not allowed. 
    NLR is one minute. 
    Hostages are to remain imprisoned for no longer than 15 minutes after that they either must be killed or ransomed off. 
    Grenade spam is not allowed. (30 sec period for each grenade thrown).
    Grenade launcher spam is not allowed. (60 Sec Period between each launch).
    RPG Spam is not allowed (60 Sec Period between each launch).
    TK (Team Killing) is not allowed. 
    Glitching or finding bugs in the server and using them to your advantage is not allowed. 
    OOC Disrespect is not allowed.
    Excessive racism (Meaning saying a racial slur or remark more than 2-3 times every 30 minutes or  repeatedly saying them in quick succession) IC or OOC is not allowed. 
    Mic Spam is not allowed.
    Minging is not allowed. 
	]], 35)

Here’s the exacty errors I got:

[ERROR] addons/revival-tutorial-addon/lua/autorun/client/pages.lua:1: attempt to call global ‘CreatePage’ (a nil value)

  1. unknown - addons/revival-tutorial-addon/lua/autorun/client/pages.lua:1
  2. include - [C]:-1
    3. unknown - addons/revival-tutorial-addon/lua/autorun/client/cl_tutorial.lua:2

[ERROR] addons/revival-tutorial-addon/lua/autorun/client/cl_tutorial.lua:111: attempt to index a nil value

  1. func - addons/revival-tutorial-addon/lua/autorun/client/cl_tutorial.lua:111
  2. unknown - lua/includes/extensions/net.lua:32

I know that I posted a large snippet of code, and I am aware that there are rules against that. I’ve just used up my other options. I understand if it results in the thread being locked.

Thanks in advance :slight_smile:

The order of files loaded in autorun isn’t guaranteed. Either move your pages.lua to a folder where you can include the file yourself after CreatePage has been declared or put the code in a hook or timer.

Where precisely? Aslong as it’s in the lua folder? I’m not good when it comes to the structure of an addon folder.

You can create your own custom folders in the lua folder that you can include with autorun files.

Ah, thank you. I understand folder structure much better now :slight_smile:

[editline]21st July 2017[/editline]

It says it can’t find them.

I moved the file to a folder called ‘customize’ in the lua directory.

This is the code inside the ‘cl_tutorial.lua’ file:


I have added them with AddCSLuaFile in init.lua aswell. I initially tried just doing


You need to AddCSLuaFile serverside.

I have.






You don’t need to include nor AddCSLua files inside of autorun, plus that file of yours “lua/init.lua” will never run and it MAY cause conflicts by its simplistic name (Aka: lua/init.lua).

I don’t get any errors when it comes to include/AddCSLuaFile, but stuff still isn’t carried over to ‘cl_tutorial.lua’.

[editline]22nd July 2017[/editline]

It still says:

Couldn’t include file ‘customize\fonts.lua’ (File not found) (@addons/revival-tutorial-addon/lua/autorun/client/cl_tutorial.lua (line 55))

Couldn’t include file ‘customize\pages.lua’ (File not found) (@addons/revival-tutorial-addon/lua/autorun/client/cl_tutorial.lua (line 56))

But the dermapanel itself works perfectly fine.

[editline]22nd July 2017[/editline]

I guess. I thought it was just an appropriate place to do the AddCSLuaFile functions, since that’s how it works with gamemodes. Where should I put the AddCSLua functions then?