Garry's Mod

Garry's Mod

PropHunt (Hide'n'Seek) - Original
iD4NG3R` 24 Jul, 2013 @ 2:50pm
How To: Fix cl_hints.lua and some other stuff
Getting that annoying message "cl_hints" could not be included? Here's how it goes:

When you connect to a server running PropHunt you are first opening the "init.lua" file in gamemodes/prop_hunt/gamemode in there it tells the client to download some files, however the client file cl_hints.lua is not defined there. Add the following to line 6 of init.lua:

AddCSLuaFile('cl_hints.lua')

Next up is cl_hints.lua itself its there to display hints on your screen. However because PropHunt is not derived from sandbox it doesnt recognice GAMEMODE:AddNotify on line 18. So we are replacing that with:

notification.AddLegacy

The final step is to replace include( 'cl_hints.lua' ) with include( "cl_hints.lua" ) inside cl_init.lua (Its on line 3).

Use a text editor like notepad++ to make it clear what lines you have to edit, or use ctrl+f to search for these lines in the files themselves.
Last edited by iD4NG3R`; 24 Jul, 2013 @ 2:57pm
< >
Showing 1-7 of 7 comments
iD4NG3R` 24 Jul, 2013 @ 2:51pm 
So what you get:

cl_init.lua:
// Include the needed files include( "sh_init.lua" ) include( "cl_hints.lua" ) // Decides where the player view should be (forces third person for props) function GM:CalcView(pl, origin, angles, fov) local view = {} if blind then view.origin = Vector(20000, 0, 0) view.angles = Angle(0, 0, 0) view.fov = fov return view end view.origin = origin view.angles = angles view.fov = fov // Give the active weapon a go at changing the viewmodel position if pl:Team() == TEAM_PROPS && pl:Alive() then view.origin = origin + Vector(0, 0, hullz - 60) + (angles:Forward() * -80) else local wep = pl:GetActiveWeapon() if wep && wep != NULL then local func = wep.GetViewModelPosition if func then view.vm_origin, view.vm_angles = func(wep, origin*1, angles*1) // Note: *1 to copy the object so the child function can't edit it. end local func = wep.CalcView if func then view.origin, view.angles, view.fov = func(wep, pl, origin*1, angles*1, fov) // Note: *1 to copy the object so the child function can't edit it. end end end return view end // Draw round timeleft and hunter release timeleft function HUDPaint() if GetGlobalBool("InRound", false) then local blindlock_time_left = (HUNTER_BLINDLOCK_TIME - (CurTime() - GetGlobalFloat("RoundStartTime", 0))) + 1 if blindlock_time_left < 1 && blindlock_time_left > -6 then blindlock_time_left_msg = "Hunters have been released!" elseif blindlock_time_left > 0 then blindlock_time_left_msg = "Hunters will be unblinded and released in "..string.ToMinutesSeconds(blindlock_time_left) else blindlock_time_left_msg = nil end if blindlock_time_left_msg then surface.SetFont("MyFont") local tw, th = surface.GetTextSize(blindlock_time_left_msg) draw.RoundedBox(8, 20, 20, tw + 20, 26, Color(0, 0, 0, 75)) draw.DrawText(blindlock_time_left_msg, "MyFont", 31, 26, Color(255, 255, 0, 255), TEXT_ALIGN_LEFT) end end end hook.Add("HUDPaint", "PH_HUDPaint", HUDPaint) // Called immediately after starting the gamemode function Initialize() hullz = 80 //surface.CreateFont("Arial", 14, 1200, true, false, "ph_arial") surface.CreateFont( "MyFont", { font = "Arial", size = 14, weight = 1200, antialias = true, underline = false }) end hook.Add("Initialize", "PH_Initialize", Initialize) // Resets the player hull function ResetHull(um) if LocalPlayer() && LocalPlayer():IsValid() then LocalPlayer():ResetHull() hullz = 80 end end usermessage.Hook("ResetHull", ResetHull) // Sets the local blind variable to be used in CalcView function SetBlind(um) blind = um:ReadBool() end usermessage.Hook("SetBlind", SetBlind) // Sets the player hull function SetHull(um) hullxy = um:ReadLong() hullz = um:ReadLong() new_health = um:ReadLong() LocalPlayer():SetHull(Vector(hullxy * -1, hullxy * -1, 0), Vector(hullxy, hullxy, hullz)) LocalPlayer():SetHullDuck(Vector(hullxy * -1, hullxy * -1, 0), Vector(hullxy, hullxy, hullz)) LocalPlayer():SetHealth(new_health) end usermessage.Hook("SetHull", SetHull)
cl_hints.lua:
CreateClientConVar( "cl_showhints", "1", true, false ) -- A list of hints we've already done so we don't repeat ourselves` local ProcessedHints = {} -- -- Throw's a Hint to the screen -- local function ThrowHint( name ) local show = GetConVarNumber( "cl_showhints" ) if ( show == 0 ) then return end if ( engine.IsPlayingDemo() ) then return end notification.AddLegacy( "#Hint_"..name, NOTIFY_HINT, 20 ) surface.PlaySound( "ambient/water/drip"..math.random(1, 4)..".wav" ) end -- -- Adds a hint to the queue -- function GM:AddHint( name, delay ) if (ProcessedHints[ name ]) then return end timer.Create( "HintSystem_"..name, delay, 1, function() ThrowHint( name ) end ) ProcessedHints[ name ] = true end -- -- Removes a hint from the queue -- function GM:SuppressHint( name ) timer.Destroy( "HintSystem_"..name ) end -- Show opening menu hint if they haven't opened the menu within 30 seconds GM:AddHint( "OpeningMenu", 30 ) -- Tell them how to turn the hints off after 1 minute GM:AddHint( "Annoy1", 5 ) GM:AddHint( "Annoy2", 7 )
init.lua:
// Send the required lua files to the client AddCSLuaFile('cl_init.lua') AddCSLuaFile('sh_config.lua') AddCSLuaFile('sh_init.lua') AddCSLuaFile('sh_player.lua') AddCSLuaFile('cl_hints.lua') // If there is a mapfile send it to the client (sometimes servers want to change settings for certain maps) if file.Exists("../gamemodes/prop_hunt/gamemode/maps/"..game.GetMap()..".lua", "LUA") then AddCSLuaFile("maps/"..game.GetMap()..".lua") end // Include the required lua files include("sh_init.lua") // Server only constants EXPLOITABLE_DOORS = { "func_door", "prop_door_rotating", "func_door_rotating" } USABLE_PROP_ENTITIES = { "prop_physics", "prop_physics_multiplayer" } // Send the required resources to the client for _, taunt in pairs(HUNTER_TAUNTS) do resource.AddFile("sound/"..taunt) end for _, taunt in pairs(PROP_TAUNTS) do resource.AddFile("sound/"..taunt) end // Called alot function GM:CheckPlayerDeathRoundEnd() if !GAMEMODE.RoundBased || !GAMEMODE:InRound() then return end local Teams = GAMEMODE:GetTeamAliveCounts() if table.Count(Teams) == 0 then GAMEMODE:RoundEndWithResult(1001, "Draw, everyone loses!") return end if table.Count(Teams) == 1 then local TeamID = table.GetFirstKey(Teams) GAMEMODE:RoundEndWithResult(TeamID, team.GetName(1).." win!") return end end // Called when an entity takes damage function EntityTakeDamage(ent, dmginfo) local att = dmginfo:GetAttacker() if GAMEMODE:InRound() && ent && ent:GetClass() != "ph_prop" && !ent:IsPlayer() && att && att:IsPlayer() && att:Team() == TEAM_HUNTERS && att:Alive() then att:SetHealth(att:Health() - HUNTER_FIRE_PENALTY) if att:Health() <= 0 then MsgAll(att:Name() .. " felt guilty for hurting so many innocent props and committed suicide\n") att:Kill() end end end hook.Add("EntityTakeDamage", "PH_EntityTakeDamage", EntityTakeDamage) // Called when player tries to pickup a weapon function GM:PlayerCanPickupWeapon(pl, ent) if pl:Team() != TEAM_HUNTERS then return false end return true end // Called when player needs a model function GM:PlayerSetModel(pl) local player_model = "models/Gibs/Antlion_gib_small_3.mdl" if pl:Team() == TEAM_HUNTERS then player_model = "models/player/combine_super_soldier.mdl" end util.PrecacheModel(player_model) pl:SetModel(player_model) end // Called when a player tries to use an object function GM:PlayerUse(pl, ent) if !pl:Alive() || pl:Team() == TEAM_SPECTATOR then return false end if pl:Team() == TEAM_PROPS && pl:IsOnGround() && !pl:Crouching() && table.HasValue(USABLE_PROP_ENTITIES, ent:GetClass()) && ent:GetModel() then if table.HasValue(BANNED_PROP_MODELS, ent:GetModel()) then pl:ChatPrint("That prop has been banned by the server.") elseif ent:GetPhysicsObject():IsValid() && pl.ph_prop:GetModel() != ent:GetModel() then local ent_health = math.Clamp(ent:GetPhysicsObject():GetVolume() / 250, 1, 200) local new_health = math.Clamp((pl.ph_prop.health / pl.ph_prop.max_health) * ent_health, 1, 200) local per = pl.ph_prop.health / pl.ph_prop.max_health pl.ph_prop.health = new_health pl.ph_prop.max_health = ent_health pl.ph_prop:SetModel(ent:GetModel()) pl.ph_prop:SetSkin(ent:GetSkin()) pl.ph_prop:SetSolid(SOLID_BSP) pl.ph_prop:SetPos(pl:GetPos() - Vector(0, 0, ent:OBBMins().z)) pl.ph_prop:SetAngles(pl:GetAngles()) local hullxymax = math.Round(math.Max(ent:OBBMaxs().x, ent:OBBMaxs().y)) local hullxymin = hullxymax * -1 local hullz = math.Round(ent:OBBMaxs().z) pl:SetHull(Vector(hullxymin, hullxymin, 0), Vector(hullxymax, hullxymax, hullz)) pl:SetHullDuck(Vector(hullxymin, hullxymin, 0), Vector(hullxymax, hullxymax, hullz)) pl:SetHealth(new_health) umsg.Start("SetHull", pl) umsg.Long(hullxymax) umsg.Long(hullz) umsg.Short(new_health) umsg.End() end end // Prevent the door exploit if table.HasValue(EXPLOITABLE_DOORS, ent:GetClass()) && pl.last_door_time && pl.last_door_time + 1 > CurTime() then return false end pl.last_door_time = CurTime() return true end // Called when player presses [F3]. Plays a taunt for their team function GM:ShowSpare1(pl) if GAMEMODE:InRound() && pl:Alive() && (pl:Team() == TEAM_HUNTERS || pl:Team() == TEAM_PROPS) && pl.last_taunt_time + TAUNT_DELAY <= CurTime() && #PROP_TAUNTS > 1 && #HUNTER_TAUNTS > 1 then repeat if pl:Team() == TEAM_HUNTERS then rand_taunt = table.Random(HUNTER_TAUNTS) else rand_taunt = table.Random(PROP_TAUNTS) end until rand_taunt != pl.last_taunt pl.last_taunt_time = CurTime() pl.last_taunt = rand_taunt pl:EmitSound(rand_taunt, 100) end end // Called when the gamemode is initialized function Initialize() game.ConsoleCommand("mp_flashlight 0\n") end hook.Add("Initialize", "PH_Initialize", Initialize) // Called when a player leaves function PlayerDisconnected(pl) pl:RemoveProp() end hook.Add("PlayerDisconnected", "PH_PlayerDisconnected", PlayerDisconnected) // Called when the players spawns function PlayerSpawn(pl) pl:Blind(false) pl:RemoveProp() pl:SetColor( Color(255, 255, 255, 255)) pl:SetRenderMode( RENDERMODE_TRANSALPHA ) pl:UnLock() pl:ResetHull() pl.last_taunt_time = 0 umsg.Start("ResetHull", pl) umsg.End() pl:SetCollisionGroup(COLLISION_GROUP_PASSABLE_DOOR) end hook.Add("PlayerSpawn", "PH_PlayerSpawn", PlayerSpawn) // Removes all weapons on a map function RemoveWeaponsAndItems() for _, wep in pairs(ents.FindByClass("weapon_*")) do wep:Remove() end for _, item in pairs(ents.FindByClass("item_*")) do item:Remove() end end hook.Add("InitPostEntity", "PH_RemoveWeaponsAndItems", RemoveWeaponsAndItems) // Called when round ends function RoundEnd() for _, pl in pairs(team.GetPlayers(TEAM_HUNTERS)) do pl:Blind(false) pl:UnLock() end end hook.Add("RoundEnd", "PH_RoundEnd", RoundEnd) // This is called when the round time ends (props win) function GM:RoundTimerEnd() if !GAMEMODE:InRound() then return end GAMEMODE:RoundEndWithResult(TEAM_PROPS, "Props win!") end // Called before start of round function GM:OnPreRoundStart(num) game.CleanUpMap() if GetGlobalInt("RoundNumber") != 1 && SWAP_TEAMS_EVERY_ROUND == 1 && ((team.GetScore(TEAM_PROPS) + team.GetScore(TEAM_HUNTERS)) > 0 || SWAP_TEAMS_POINTS_ZERO==1) then for _, pl in pairs(player.GetAll()) do if pl:Team() == TEAM_PROPS || pl:Team() == TEAM_HUNTERS then if pl:Team() == TEAM_PROPS then pl:SetTeam(TEAM_HUNTERS) else pl:SetTeam(TEAM_PROPS) end pl:ChatPrint("Teams have been swapped!") end end end UTIL_StripAllPlayers() UTIL_SpawnAllPlayers() UTIL_FreezeAllPlayers() end
Last edited by iD4NG3R`; 24 Jul, 2013 @ 2:52pm
Bagel 25 Jul, 2013 @ 10:15pm 
But I don't have the prop hunt folder in my gamemodes folder!!! All I have in that folder is 3 folders called base, sandbox, and terrortown and a txt document named gamemodes! The only "prophunt" related file I have in my garry's mod folder is the GMA file in my addons folder. Someone please Help!!!
nzkfc 26 Jul, 2013 @ 2:16am 
This works, thanks for your more detailed fix :)

@Bagel, are you trying to install this locally? as in your own gamemode when you connect to actual servers vs a LAN server?

When you connect to a gamemode server, your game should download the .gma (as you can see) when you create a server, you extract this content via Gmad program and place them into the gamemodes folder where you only have base, sandbox and terrortown.
Bagel 26 Jul, 2013 @ 11:28pm 
Originally posted by nzkfc:
This works, thanks for your more detailed fix :)

@Bagel, are you trying to install this locally? as in your own gamemode when you connect to actual servers vs a LAN server?

When you connect to a gamemode server, your game should download the .gma (as you can see) when you create a server, you extract this content via Gmad program and place them into the gamemodes folder where you only have base, sandbox and terrortown.

Thanks alot, I extracted the folder with Gmad and now I'm caught up with everyone else! :)
Nixcker 29 Jul, 2013 @ 2:27pm 
Still cant get it to work, extracted the gma file and put it in gamemodes directory but still cant get it to work.
whenever i start a game i get the lua error mentioned above and and only i able to connect to my server, others get the missing lua file error.
iD4NG3R` 29 Jul, 2013 @ 2:36pm 
If you follow it properly or copy-paste the code above to the proper files it should work.
Nixcker 29 Jul, 2013 @ 2:38pm 
nvm solved it, i should move prop_hunt to the gamemodes folder, thanks!
Last edited by Nixcker; 29 Jul, 2013 @ 2:39pm
< >
Showing 1-7 of 7 comments
Per page: 1530 50