• No Player hover over data, and no hands, and no team colors.
    4 replies, posted
Hello there, I'm creating a small Saxton Hale-esk gamemode and I've ran into the problem that bots now don't show their data on hover, and I also have no hands on my models, I'll supply the code for both client side hud as I think this is what is messing it up, I also don't have chat colors either, which is not really important but surely the team color should be my chat color? Anyway I'll show you these two files. [B]sv_player.lua[/B] [CODE] /** TEMP - TODO: Change this! **/ local ply = FindMetaTable("Player") /** ================================================ PLAYER MODELS: Randomise the models! ================================================ **/ local playermodels = { Model("models/player/odessa.mdl"), Model("models/player/kleiner.mdl"), Model("models/player/monk.mdl"), Model("models/player/breen.mdl"), Model("models/player/mossman.mdl"), Model("models/player/police.mdl"), Model("models/player/alyx.mdl"), Model("models/player/barney.mdl"), Model("models/player/group02/male_02.mdl"), Model("models/player/group02/male_04.mdl"), Model("models/player/group02/male_08.mdl"), Model("models/player/group01/male_07.mdl") } /** ================================================ SPAWN: Handle Spawn ================================================ **/ function GM:PlayerSpawn( ply ) ply:SetSurvivor() print("I"..ply:Nick().." are on team "..ply:Team()) ply:SetHealth( PLAYER_HEALTH ) ply:SetModel( table.Random(playermodels)) ply:SetWalkSpeed( PLAYER_SPEED ) ply:SetCanZoom( false ) ply:AllowFlashlight(true) // Can be over ridden with mp_flashlight ply:SetNoCollideWithTeammates( true ) end [/CODE] I was using a Hands function, but i removed it because it was not working. And here's my cl_hud.lua. [B]cl_hud.lua[/B] [CODE] /** ================================================ PLAYER HUD: The players heads up display. ================================================ **/ surface.CreateFont("Biggish_HUD", {font = "Trebuchet MS", size = 40, weight = 1000}) surface.CreateFont("Big_HUD", {font = "Trebuchet MS", size = 20, weight = 1000}) surface.CreateFont("Small_HUD", {font = "Trebuchet MS", size = 18, weight = 1000}) function DrawHud() draw.RoundedBox( 4, 10 , ScrH() - 60, 210, 50, Color( 0, 0, 0, 200 ) ) draw.RoundedBox( 4, 15 , ScrH() - 55, 200, 40, Color( 0, 0, 0, 150 ) ) end function DrawHealth() if PLAYER_HEALTH < 99 then draw.SimpleTextOutlined("0", "Biggish_HUD", 58 , ScrH() - 10 - 45, Color(255,255,255,20), 0, 0, 1, Color( 0, 0, 0, 20 )) end if PLAYER_HEALTH < 10 then draw.SimpleTextOutlined("0", "Biggish_HUD", 39, ScrH() - 10 - 45, Color(255,255,255,20), 0, 0, 1, Color( 0, 0, 0, 20 )) end if PLAYER_HEALTH < 1 then draw.SimpleTextOutlined("0", "Biggish_HUD", 20, ScrH() - 10 - 45, Color(255,255,255,20), 0, 0, 1, Color( 0, 0, 0, 20 )) end if PLAYER_HEALTH > 0 then draw.SimpleTextOutlined(PLAYER_HEALTH, "Biggish_HUD", 20 , ScrH() - 10 - 45, Color(255,255,255,255), 0, 0, 1, Color( 0, 0, 0, 255 )) end if PLAYER_HEALTH < 1000 then draw.SimpleTextOutlined("0", "Biggish_HUD", 77 , ScrH() - 10 - 45, Color(255,255,255,20), 0, 0, 1, Color( 0, 0, 0, 20 )) end if PLAYER_HEALTH < 10000 then draw.SimpleTextOutlined("0", "Biggish_HUD", 95 , ScrH() - 10 - 45, Color(255,255,255,20), 0, 0, 1, Color( 0, 0, 0, 20 )) end end function DrawInformation() end function GM:HUDPaint() if DISABLE_DEFAULT_HUD == 1 then return false end PLAYER = LocalPlayer() PLAYER_HEALTH = math.max(0, PLAYER:Health()) PLAYER_ARMOR = math.max(0, PLAYER:Armor()) DrawHud() DrawHealth() if (ROUND_STATE == 1) then draw.SimpleTextOutlined("Prepare", "Big_HUD", 120 , ScrH() - 10 - 40, Color(255,255,255,255), 0, 0, 1, Color( 0, 0, 0, 255 )) elseif (ROUND_STATE == 2) then draw.SimpleTextOutlined("Fight!", "Big_HUD", 120 , ScrH() - 10 - 40, Color(255,255,255,255), 0, 0, 1, Color( 0, 0, 0, 255 )) elseif (ROUND_STATE == 3) then draw.SimpleTextOutlined("Round Over!", "Big_HUD", 120 , ScrH() - 10 - 40, Color(255,255,255,255), 0, 0, 1, Color( 0, 0, 0, 255 )) elseif (ROUND_STATE == 0) then draw.SimpleTextOutlined("Wait..", "Big_HUD", 120 , ScrH() - 10 - 40, Color(255,255,255,255), 0, 0, 1, Color( 0, 0, 0, 255 )) end if ROUND_TIME > 10 then draw.SimpleTextOutlined(ROUND_TIME, "Biggish_HUD", 10 , 10 , Color(255,255,255,255), 0, 0, 1, Color( 0, 0, 0, 255 )) else draw.SimpleTextOutlined(ROUND_TIME, "Biggish_HUD", 10 , 10 , Color(255,0,0,255), 0, 0, 1, Color( 0, 0, 0, 255 )) end if ROUND_TIME < 100 then draw.SimpleTextOutlined("0", "Biggish_HUD", 49 , 10 , Color(255,255,255,20), 0, 0, 1, Color( 0, 0, 0, 20 )) end if ROUND_TIME < 10 then draw.SimpleTextOutlined("0", "Biggish_HUD", 30 , 10 , Color(255,255,255,20), 0, 0, 1, Color( 0, 0, 0, 20 )) end draw.SimpleTextOutlined("Seconds left..", "Small_HUD", 70 , 28 , Color(255,255,255,255), 0, 0, 1, Color( 0, 0, 0, 255 )) end /** ================================================ HIDE HUD: Hide the default HUD! ================================================ **/ function hidehud(name) for k, v in pairs{"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"} do if name == v then return false end end end hook.Add("HUDShouldDraw", "hidehud", hidehud) [/CODE] These are the user messages this script receives. [B]cl_init.lua[/B] [CODE] include("client/cl_hud.lua") /** HOOKS **/ usermessage.Hook( "ROUNDSTATE", function( um ) ROUND_STATE = um:ReadLong() end) usermessage.Hook( "TIMESTATE", function( um ) ROUND_TIME = um:ReadLong() end) usermessage.Hook( "GARRYHEALTH", function( um ) GARRY_HEALTH = um:ReadLong() end) [/CODE] and where they are broadcasted from [b]sh_broadcast.lua[/b] [CODE] /** ================================================ BROADCAST TIMER STATUS TO CLIENT: For the hud and stuffs! ================================================ **/ function SendRoundstate() umsg.Start( "ROUNDSTATE" ) umsg.Long( ROUND_STATE ) umsg.End() end function SendTimeState( Timer ) umsg.Start( "TIMESTATE" ) umsg.Long( Timer ) umsg.End() end [/CODE] and also here's the team core because I'm confused. [b]sh_teams[/b] [CODE] local ply = FindMetaTable("Player") /** ================================================ TEAM CORE CLIENT: Used when settings and seeing is player is a team ================================================ **/ function ply:SetSurvivor() return self:SetTeam( Fight_Team ) end function ply:SetGarry() return self:SetTeam( Garry_Team ) end function ply:IsGarry() if self:Team() == Garry_Team then return true end end function ply:IsSurvivor() if self:Team() == Fight_Team then return true end end [/CODE] Help me! (I put so much code it broke the page) [b]shared.lua[/b] [CODE] /** ================================================ GLOBAL VARRIABLES: Used in everything! ================================================ **/ ROUND_STATE = 0 /** ================================================ TEAMS: Used in everything! ================================================ **/ GM.Name = "Garry Attack!" GM.Author = "Haskell" GM.Email = "nsahotline@gmail.com" GM.Website = "n/a" Fight_Team = 1 Spectator_Team = 2 Garry_Team = 3 /** Shared between the client and the stuff **/ ROUND_STATE = 0 team.SetUp (Fight_Team, "Player", Color(0,0,205,255)) team.SetUp (Spectator_Team, "Spectator", Color(204,204,0,255)) team.SetUp (Garry_Team, "Garry", Color(204,204,0,255)) /** ================================================ LOAD DIRECTORY II: For the shared side! ================================================ **/ function SharedLoadDirectory(dir) print("==[LOADING "..dir.."]===========================================")
This is because you've overridden GM:HudPaint without including code from base gamemode. Either copy the hook from base gamemode and add in your own code [editline]24th February 2014[/editline] Or put [code] self.BaseClass.HUDPaint( self) [/code] into your existing hook. [editline]24th February 2014[/editline] As for the hands, wiki has an article on that.
[QUOTE=Robotboy655;44028418]This is because you've overridden GM:HudPaint without including code from base gamemode. Either copy the hook from base gamemode and add in your own code [editline]24th February 2014[/editline] Or put [code] self.BaseClass.HUDPaint( self) [/code] into your existing hook. [editline]24th February 2014[/editline] As for the hands, wiki has an article on that.[/QUOTE] Cheers, Worked like a charm! How about these chat colors? [img]http://gyazo.com/0b78cc8d7d034d3cdc65f5a53fc8206c.png[/img] Even though the team clearly states [CODE] team.SetUp (Fight_Team, "Player", Color(0,0,205,255)) team.SetUp (Spectator_Team, "Spectator", Color(204,204,0,255)) team.SetUp (Garry_Team, "Garry", Color(204,204,0,255)) [/CODE] Its not really important but I'd be nice.
Are you actually setting the team? [editline]24th February 2014[/editline] [url]http://wiki.garrysmod.com/page/GM/CreateTeams[/url]
[QUOTE=Robotboy655;44028863]Are you actually setting the team? [editline]24th February 2014[/editline] [url]http://wiki.garrysmod.com/page/GM/CreateTeams[/url][/QUOTE] Yeah, still no luck. [CODE] Fight_Team = 1 Spectator_Team = 2 Garry_Team = 3 /** Shared between the client and the stuff **/ ROUND_STATE = 0 function GM:CreateTeams() team.SetUp(1, "Player", Color( 255, 0, 0 ) ) team.SetUp(2, "Spectator", Color(204,204,0) ) team.SetUp(3, "Garry", Color(204,204,0) ) end [/CODE] and then this [CODE] function ply:SetSurvivor() return self:SetTeam( Fight_Team ) end function ply:SetGarry() return self:SetTeam( Garry_Team ) end function ply:IsGarry() if self:Team() == Garry_Team then return true end end function ply:IsSurvivor() if self:Team() == Fight_Team then return true end end [/CODE] gives this still [img]http://gyazo.com/1fc170df8775a2ae52214ddbae186769.png[/img]
Sorry, you need to Log In to post a reply to this thread.