• Gamemode CL_Init wont run automatically
    8 replies, posted
Greetings everyone, I am developing a gamemode, everything works fine except cl_init, there is absolutely no console errors and it seems to behave really strangely. When i boot up my game cl_init wont do anything, however, if i edit my code to print a lua error in the console, then fix it cl_init will run perfectly until i close garry's mod. After that, the issue repeats. I was trying for 3 days yet i still couldnt find solutions, this is getting really annoying and obnoxious. Thank you in advance.
AddCSLuaFile( "shared.lua" ) AddCSLuaFile( "cl_init.lua" ) Yes i do
include( "shared.lua" ) AddCSLuaFile(" init.lua ") language.Add("cycler_actor","Hostage") function HUDPrepare() hook.Add("HUDPaint","security_splash",securitysplash) hook.Add("HUDPaint","intruder_splash",intrudersplash) print("prepre ze finale") end  function set_team()     frame = vgui.Create( "DFrame" )   frame:SetPos( 100, ScrH() / 2 ) //Set the window in the middle of the players screen/game window   frame:SetSize( 200, 210 ) //Set the size   frame:SetTitle( "Insurgent" ) //Set title   frame:SetVisible( true )   frame:SetDraggable( false )   frame:MakePopup()     team_1 = vgui.Create( "DButton", frame )   team_1:SetPos( 30, 30 )  team_1:SetSize( 100, 50 )   team_1:SetText( "Insurgent" )   team_1.DoClick = function() //Make the player join team 1         RunConsoleCommand( "team_insurgentman" ) RunConsoleCommand("kill")    end     team_2 = vgui.Create( "DButton", frame )   team_2:SetPos( 30, 85 ) //Place it next to our previous one   team_2:SetSize( 100, 50 )   team_2:SetText( "SWAT" )   team_2.DoClick = function() //Make the player join team 2         RunConsoleCommand( "team_securityman" ) RunConsoleCommand( "kill" )  end  end     concommand.Add( "test_menu", intrudersplash )  concommand.Add( "team_menu", set_team )  concommand.Add("HUDTest", HUDPrepare)    function GM:PostDrawViewModel( vm, ply, weapon ) if ( weapon.UseHands || !weapon:IsScripted() ) then local hands = LocalPlayer():GetHands() if ( IsValid( hands ) ) then hands:DrawModel() end end end function GM:KeyPress(ply) if CLIENT then if ( Entity( 1 ):KeyPressed( IN_USE ) ) and !(LocalPlayer()) then swrp_draw_mask() end end end  //function swrp_draw_mask()local mask = "models/props_c17/fisheyelens" //DrawMaterialOverlay(mask, -0.06) //end //hook.Add("RenderScreenspaceEffects", "swrp_draw_mask", swrp_draw_mask)  function GM:PlayerSpawn ( ply ) print("hah2_spawn"); end function GM:PlayerInitialSpawn(ply) set_team() print("hah2_initial"); end local tex = surface.GetTextureID("hud/intruder_select") // Gets the texture id for the brick texture local checktest = 0 function intrudersplash()  surface.SetTexture(tex) surface.SetDrawColor(255,255,255,255) // Makes sure the image draws with all colors surface.DrawTexturedRect(150,75,320,425,128) if checktest == 1 then   frame = vgui.Create( "DFrame" )  frame:SetPos( 480,500)    frame:SetSize(260,150 ) frame:MakePopup() frame:SetTitle("Choose Your Team.") DermaButton2 = vgui.Create ("DButton", frame) DermaButton2:SetText( "Security" ) DermaButton2:SetSize( 250, 30 ) DermaButton2:SetPos(10, 80 ) DermaButton2.DoClick = function() // A custom function run when clicked ( note the . instead of : ) // Run the console command "say hi" when you click it ( command, args )      RunConsoleCommand( "team_securityman" ) RunConsoleCommand("kill") hook.Remove("HUDPaint","intruder_splash",intrudersplash) hook.Remove("HUDPaint","security_splash",securitysplash) frame:SetVisible(false)   checktest = 0   end DermaButton = vgui.Create( "DButton", frame )// Create the button and parent it to the frame DermaButton:SetText( "Insurgent" ) // Set the text on the button DermaButton:SetPos(10, 50 ) // Set the position on the frame DermaButton:SetSize( 250, 30 ) // Set the size DermaButton.DoClick = function() // A custom function run when clicked ( note the . instead of : ) // Run the console command "say hi" when you click it ( command, args )      RunConsoleCommand( "team_insurgentman" ) RunConsoleCommand("kill") hook.Remove("HUDPaint","intruder_splash",intrudersplash) hook.Remove("HUDPaint","security_splash",securitysplash) frame:SetVisible(false) end  end    checktest = 0   end    local tex2 = surface.GetTextureID("hud/security_select")  function securitysplash() surface.SetTexture(tex2) surface.SetDrawColor(255,255,255,255) // Makes sure the image draws with all colors surface.DrawTexturedRect(750,75,320,425,128) end checktest = 1
Apparently it fails to initialize cl_init
I can't remember if this matters in lua, but you're using functions before they're defined.
Fixed it, thank you so much...
Sorry, you need to Log In to post a reply to this thread.