• [FRETTA] ''Change Class'' button doesn't work
    1 replies, posted
after a lot of trying i managed to get a "Change Class" button, but it isn't working. When i press the button i just hear a click and nothing happens, i do spawn as class A but i can't switch to class b. this is my code: THE BUTTON [code] if ( IsValid( LocalPlayer() ) ) then local TeamID = LocalPlayer():Team() local Classes = team.GetClass( TeamID ) if ( Classes && #Classes > 1 ) then local btn = Help:AddSelectButton( "Change Class", function() GAMEMODE:ShowClassChooser( LocalPlayer():Team() ) end ) btn.m_colBackground = Color( 120, 255, 100 ) end end[/code] My first 2 classes [code]if ( !GAMEMODE.TeamBased ) then return end team.SetUp( TEAM_1, "Team 1", Color( 50, 255, 50 ), true ) team.SetSpawnPoint( TEAM_1, { "info_player_counterterrorist" } ) team.SetClass( TEAM_1, { "Class A", "Class B" } ) // "Human" is the class we want players to use[/code] class_a.lua [code] local CLASS = {} CLASS.DisplayName = "Class A" CLASS.WalkSpeed = 400 CLASS.CrouchedWalkSpeed = 0.2 CLASS.RunSpeed = 600 CLASS.DuckSpeed = 0.2 CLASS.JumpPower = 200 CLASS.PlayerModel = "models/player/ct_gsg9" CLASS.DrawTeamRing = true CLASS.DrawViewModel = true CLASS.CanUseFlashlight = true CLASS.MaxHealth = 100 CLASS.StartHealth = 100 CLASS.StartArmor = 0 CLASS.RespawnTime = 0 // 0 means use the default spawn time chosen by gamemode CLASS.DropWeaponOnDie = false CLASS.TeammateNoCollide = false CLASS.AvoidPlayers = false // Automatically avoid players that we're no colliding CLASS.Selectable = true // When false, this disables all the team checking CLASS.FullRotation = false // Allow the player's model to rotate upwards, etc etc function CLASS:Loadout( pl ) end function CLASS:OnSpawn( pl ) end function CLASS:OnDeath( pl, attacker, dmginfo ) end function CLASS:Think( pl ) end function CLASS:Move( pl, mv ) end function CLASS:OnKeyPress( pl, key ) end function CLASS:OnKeyRelease( pl, key ) end function CLASS:ShouldDrawLocalPlayer( pl ) return false end function CLASS:CalcView( ply, origin, angles, fov ) end player_class.Register( "Class A", CLASS )[/code] class_b.lua [code] local CLASS = {} CLASS.DisplayName = "Class B" CLASS.WalkSpeed = 400 CLASS.CrouchedWalkSpeed = 0.2 CLASS.RunSpeed = 600 CLASS.DuckSpeed = 0.2 CLASS.JumpPower = 200 CLASS.PlayerModel = "models/player/ct_gsg9" CLASS.DrawTeamRing = true CLASS.DrawViewModel = true CLASS.CanUseFlashlight = true CLASS.MaxHealth = 100 CLASS.StartHealth = 100 CLASS.StartArmor = 0 CLASS.RespawnTime = 0 // 0 means use the default spawn time chosen by gamemode CLASS.DropWeaponOnDie = false CLASS.TeammateNoCollide = false CLASS.AvoidPlayers = false // Automatically avoid players that we're no colliding CLASS.Selectable = true // When false, this disables all the team checking CLASS.FullRotation = false // Allow the player's model to rotate upwards, etc etc function CLASS:Loadout( pl ) end function CLASS:OnSpawn( pl ) end function CLASS:OnDeath( pl, attacker, dmginfo ) end function CLASS:Think( pl ) end function CLASS:Move( pl, mv ) end function CLASS:OnKeyPress( pl, key ) end function CLASS:OnKeyRelease( pl, key ) end function CLASS:ShouldDrawLocalPlayer( pl ) return false end function CLASS:CalcView( ply, origin, angles, fov ) end player_class.Register( "Class B", CLASS )[/code] Can anyone help me?
I am having the exact same problem.
Sorry, you need to Log In to post a reply to this thread.