Really bad behavior on GM functions

Hello, i’m trying to create my own gamemode and its…Horrible…I followed the tutorial on wiki.garrysmod.com
But seriously…GM functions calls randomly (I don’t trust on the random word, but this is happening)

Simple examples:

cl_init.lua

[lua]
include( “shared.lua” )
include(“util.lua”)
include(“cl_hud.lua”) //Loads…
include( “mainhud.lua” ) //Main hud, works really great without any issues

DEFINE_BASECLASS( “gamemode_base” )

function GM:Initialize()
self.BaseClass:Initialize()
end
[/lua]

cl_hud.lua
GM:HUDDrawTargetID It’s not overrided until i resave the file (And seriously, i don’t want to put a timer outside this for fix it…

[lua]

function GM:HUDPaint()
MsgN(“PLEASE! WORK!”) //Totally ignored on cl_init and cl_hud
end

hook.Add(“HUDPaint”,“GamemodePaint”,function()
TargetID()
end)

function GM:HUDDrawTargetID() //Used for remove the old drawTargetID, doesn’t work
end

function TargetID()
//replication of HUDDrawTargetID with few tweaks, it’s not called
end

function GM:HUDShouldDraw( name )
//remove the old hud
end

[/lua]

init.lua

[lua]
AddCSLuaFile( “shared.lua” )
AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “cl_hud.lua” )
include( “shared.lua” )
include( “player_class/player_soldier.lua” )

DEFINE_BASECLASS( “gamemode_base” )

function GM:PlayerSpawn( pl )
player_manager.SetPlayerClass( pl, “player_soldier” )
BaseClass.PlayerSpawn( self, pl )
pl:SetTeam(team.BestAutoJoinTeam())
end
[/lua]

shared.lua

[lua]

GM.Name = “Capture The Flag”
GM.Author = “N/A”
GM.Email = “N/A”
GM.Website = “N/A”

TEAM_RED = 1
TEAM_BLU = 2
TEAM_SPE = 3

function GM:CreateTeams()
team.SetUp(TEAM_RED, “Red”, Color(231, 76, 60), true)
team.SetUp(TEAM_BLU, “Blue”, Color(52, 152, 219,255), true)
team.SetUp(TEAM_SPE, “Spectators”, Color(46, 204, 113,255), false)

team.SetSpawnPoint(TEAM_RED, “info_player_terrorist”)
team.SetSpawnPoint(TEAM_BLU, “info_player_conterterrorist”)
team.SetSpawnPoint(TEAM_SPE, “info_player_conterterrorist”)
end

GAMEMODE:CreateTeams() //Without this, doesn’t work, tried on init.lua too, same result…

[/lua]

I really would like to know why the GM functions doesn’t want to load

Just call GAMEMODE:CreateTeams() in GM:Initialize(). CreateTeams isn’t a hook, and won’t be called automatically.

Solved client hooks adding on cl_init.lua

[lua]DEFINE_BASECLASS( “gamemode_base” )[/lua]

I think that i can close the trhead (I always found the solution after create the trhead, not 2 or 3 hours before when i’m mad)