• How to SetTeams in Gamemode
    0 replies, posted
Alright, well I have another thread out there, and because no one wants to reply to it, I thought maybe I should just create a more ontopic name for the topic. Simple as it gets, my team.SetUp is all right and everything, however if you look at the code I will provide below, can you tell me one reason why my guy DOESN'T STAY ON THE ASSIGNED TEAM, and WHY HE DOESN'T GET THE WEAPONS, HEALTH, ETC. I have set for him?? ----init.lua---- //Starting the Server and Client Download Files AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") //Spawning and Determining Team function GM:PlayerInitialSpawn( ply ) ply:ConCommand( "team_menu" ) end //Giving specif team members their respective weapons function GM:PlayerSpawn(ply) if ply:Team() == 1 then ply:SetModel( "models/player/combine_soldier.mdl" ) ply:SetMaxHealth(150,true) elseif ply:Team() == 3 then ply:SetModel( "models/player/gman_high.mdl" ) ply:SetMaxHealth(500,true) elseif ply:Team() == 2 then ply:SetModel( "models/player/group01/male_05.mdl" ) ply:SetMaxHealth(200,true) else ply:SetMaxHealth(100,true) end end function GM:PlayerLoadout(ply) if ply:Team() == 1 then ply:Give("weapon_smg1") ply:GiveAmmo(1275, "smg1") elseif ply:Team() == 3 then ply:Give("weapon_crowbar") ply:Give("weapon_pistol") ply:GiveAmmo(255, "pistol") elseif ply:Team() == 2 then ply:Give("weapon_smg1") ply:Give("weapon_pistol") ply:GiveAmmo(55, "pistol") ply:GiveAmmo(1275, "smg1") else ply:Give("weapon_crowbar") end end //Change Teams by ConCommand function team_1( ply ) if team.NumPlayers( 1 ) < 8 then ply:SetTeam( 1 ) ply:Spawn() end end function team_2( ply ) if team.NumPlayers( 2 ) < 6 then ply:SetTeam( 2 ) ply:Spawn() end end function team_3( ply ) if team.NumPlayers( 3 ) < 1 then ply:SetTeam( 3 ) ply:Spawn() end end concommand.Add( "team_1", team_1 ) concommand.Add( "team_2", team_2 ) concommand.Add( "team_3", team_3 ) ----cl_init.lua---- //Client should load Shared as well include("shared.lua") //Miss. Variables and Commands function GM:Initialize( ) surface.CreateFont("Tahoma", 16, 1000, true, false, "HUDFontAA") end //Elaborate, but more enthusiastic way of giving players a team... function set_team() local frame = vgui.Create( "DFrame" ) frame:SetPos( ScrH() / 2, ScrW() / 2 ) frame:SetSize( 115, 100 ) frame:SetTitle( "Change Team" ) frame:SetVisible( true ) frame:SetDraggable( true ) frame:ShowCloseButton( true ) frame:MakePopup() team_1 = vgui.Create( "DButton", frame ) team_1:SetPos( 10, 25 ) team_1:SetSize( 100, 20 ) team_1:SetText( "Terrorists" ) team_1.DoClick = function() RunConsoleCommand( "team_1" ) end team_2 = vgui.Create( "DButton", frame ) team_2:SetPos( 10, 45 ) team_2:SetSize( 100, 20 ) team_2:SetText( "Secret Service" ) team_2.DoClick = function() RunConsoleCommand( "team_2" ) end team_3 = vgui.Create( "DButton", frame ) team_3:SetPos( 10, 65 ) team_3:SetSize( 100, 20 ) team_3:SetText( "President" ) team_3.DoClick = function() RunConsoleCommand( "team_3" ) end end concommand.Add( "team_menu", set_team ) function showhelp() local help = vgui.Create( "DFrame" ) help:SetPos( ScrH() / 2, ScrW() / 2 ) help:SetSize( 400, 410 ) help:SetTitle( "Help" ) help:SetVisible( true ) help:SetDraggable( true ) help:ShowCloseButton( true ) help:MakePopup() text = vgui.Create( "DLabel", help ) text:SetPos(10, 25) text:SetSize(380, 360) text:SetText([[MyTextishere]]) end concommand.Add("gm_help", showhelp) //Draw Current Team Data function GM:HUDPaintBackground() end function GM:HUDPaint() h = ScrH() w = ScrW() surface.SetDrawColor(255, 255, 255, 180) //Team Score Count local terrorist = 0 local secret = 0 local president = 0 terrorist = team.GetScore( 1 ) secret = team.GetScore( 2 ) president = team.GetScore( 3 ) draw.RoundedBox(16, 0, 0, w*0.25, h*0.11, color_black_alpha90) local w05 = w * 0.05 local h05 = h * 0.05 surface.SetDrawColor(235, 235, 235, 255) surface.DrawRect(0, 0, w05, h05) surface.DrawRect(0, h05, w05, h05) draw.DrawText(terrorist, "HUDFontAA", w05, 0, COLOR_RED, TEXT_ALIGN_LEFT) draw.DrawText(secret, "HUDFontAA", w05, h05, COLOR_GREEN, TEXT_ALIGN_LEFT) draw.DrawText(president, "HUDFontAA", w05, h05, COLOR_BLUE, TEXT_ALIGN_LEFT) end ----shared.lua---- //Setting the Gamemode Info up GM.Name = "Blah" GM.Author = "blah" GM.Email = "blah" GM.Website = "N/A" GM.TakeFragOnSuicide = false GM.PlayerCanNoClip = false GM.AllowAutoTeam = false GM.NoPlayerSuicide = false GM.NoPlayerDamage = false GM.NoPlayerSelfDamage = true GM.NoPlayerTeamDamage = true GM.NoPlayerPlayerDamage = false GM.NoNonPlayerPlayerDamage = false GM.NoPlayerFootsteps = false GM.AutomaticTeamBalance = false GM.AddFragsToTeamScore = true //Setting up Teams team.SetUp( 1, "Taliban", Color(255, 0, 0)) team.SetUp( 2, "Secret Service", Color(0, 255, 0)) team.SetUp( 3, "President", Color(0, 0, 255)) team.SetUp( 4, "Waiting", Color(0, 100, 100)) Also note that I have fixed the GUI, and fixed the SetHealth and Ammo tips, so do not mention remove the comma, blah blah blah or change the ammo amount... I also changed it so it used a PlayerSetup command through the PlayerSpawn, however that didn't work, it also didn't work when I added them both together, or separated them into the PlayerSpawn and LoadOut. Please help! This is huge, if I can get this working, everything else will work 100% (The stuff I didn't add in this post)
Sorry, you need to Log In to post a reply to this thread.