• Just need someone to help with a code error...
    2 replies, posted
Hello everyone! I am new to the forums and have tried to post in the right place :zoid: I am not asking people how to make a game mode, but finding an error i have. Basically, it is a game mode in which you can choose out of five classes with a menu, which has been having issues. When clicked, it claims that the command is unknown, so, yeah. I have the folder structure like this: garrysmod/garrysmod/gamemodes/zmod under zmod i have zmod/gamemode/ which contains all the inits and the shared.lua under the other folders like content and entities which are empty. I have however, been making the menu give the player CSS content, which i have, like if the player chooses class one, they get a five seven and X ammo. I am trying to give you as much clarity, i am sorry it is like a horrific wall of text :( [I]Shared.lua:[/I] GM.Name = "Zmod" //Set the gamemode name GM.Author = "Dark_matter99" //Set the author name GM.Email = "bluebanshee@ymail.com" //Set the author email GM.Website = "www.youtube.com/bluebansh3e" //Set the author website team.SetUp( 1, "Runner", Color( 125, 125, 125, 255 ) ) team.SetUp( 2, "Assault", Color( 225, 225, 0 , 225 ) ) team.SetUp( 3, "CQC", Color( 100, 100, 100, 255 ) ) team.SetUp( 4, "Bandit", Color( 0, 255, 255, 255 ) ) team.SetUp( 5, "Admin", Color( 0, 255, 0, 0 ) ) [I]init.lua:[/I] AddCSLuaFile( "cl_init.lua" ) //Tell the server that the client need to download cl_init.lua AddCSLuaFile( "shared.lua" ) //Tell the server that the client need to download shared.lua include( 'shared.lua' ) //Tell the server to load shared.lua function GM:PlayerInitialSpawn( ply ) //"When the player first joins the server and spawns" function ply:ConCommand( "team_menu" ) //Run the console command when the player first spawns end //End the "when player first joins server and spawn" function function GM:PlayerLoadout(ply) --"The weapons/items that the player spawns with" function ply:StripWeapons() -- This command strips all weapons from the player. if ply:Team() == 1 then --If the player is on team "Guest"... ply:Give("glock") -- ...then give them the Glock. end -- This ends the if/elseif. end -- This ends the function. function team_1( ply ) ply:SetTeam( 1 ) //Make the player join team 1 ply:Spawn() end function team_2( ply ) ply:SetTeam( 2 ) ply:Spawn() end function team_3( ply ) ply:SetTeam( 3 ) //Make the player join team 3 ply:Spawn() end function team_4( ply ) ply:SetTeam( 4 ) //Make the player join team 4 ply:Spawn() end function team_5( ply ) ply:SetTeam( 5 ) //Make the player join team 5 ply:Spawn() end --And after the two previous console commands add function GM:PlayerLoadout( ply ) if ply:Team() == 1 then ply:Give( "weapon_fiveseven" ) --Give the player the Gravity Gun ply:SetModel( "models/player/male7.mdl" ) --Set the players model ply:GiveAmmo( 25 "pistol" ) --Give them 5 battries elseif ply:Team() == 2 then ply:Give( "weapon_m4a1" ) ply:GiveAmmo( 180, "ar2" ) ply:SetModel( "models/player/riot.mdl" ) elseif ply:Team() == 3 then ply:Give( "weapon_m3" ) ply:GiveAmmo( 180, "buckshot" ) --Give the player 180 pistol rounds ply:SetModel( "models/player/police.mdl" ) elseif ply:Team() == 4 then ply:Give( "weapon_usp" ) ply:GiveAmmo( 32, "pistol" ) ply:SetModel( "models/player/phoenix.mdl" ) elseif ply:Team() == 5 then ply:Give( "weapon_fiveseven" ) ply:Give( "weapon_m3" ) ply:GiveAmmo( 32, "buckshot" ) ply:GiveAmmo( 32, "pistol" ) ply:SetModel( "models/player/swat.mdl" ) end end function GM:PlayerSelectSpawn( ply ) --Make a team select a spawn and randomize where they spawn local spawns = ents.FindByClass( "info_player_start" ) --Make so that we can use spawns instead of info_player_start (they will do the same things) local random = math.random(spawns) --Random spawn of the info_player_start if ply:Team() == 1 --If player is in team 1 then spawns[random] --Make them always spawn from a random point of this class end --End if condition end --End the function if ply:Team() == 2 --If player is in team 1 then spawns[random] --Make them always spawn from a random point of this class end --End if condition if ply:Team() == 3 --If player is in team 1 then spawns[random] --Make them always spawn from a random point of this class end --End if condition if ply:Team() == 4 --If player is in team 1 then spawns[random] --Make them always spawn from a random point of this class end --End if condition if ply:Team() == 5 --If player is in team 1 then spawns[random] --Make them always spawn from a random point of this class end --End if condition end --End the function concommand.Add( "team_1", team_1 ) concommand.Add( "team_2", team_2 ) concommand.Add( "team_3", team_3 ) //Add the command to set the players team to team 3 concommand.Add( "team_4", team_4 ) //Add the command to set the players team to team 4 concommand.Add( "team_5", team_5 ) [I]cl_init.lua:[/I] function set_team() local frame = vgui.Create( "DFrame" ) frame:SetPos( ScrW() / 2, ScrH() / 2 ) --Set the window in the middle of the players screen/game window frame:SetSize( 400, 400 ) --Set the size frame:SetTitle( "Change Team" ) --Set title frame:SetVisible( true ) frame:SetDraggable( false ) frame:ShowCloseButton( true ) frame:MakePopup() --Add the buttons team_1 = vgui.Create( "DButton", frame ) team_1:SetPos( frame:GetTall() / 100, 50 ) --Place it half way on the tall and 5 units in horizontal team_1:SetSize( 50, 50 ) team_1:SetText( "Team 1" ) team_1.DoClick = function() --Make the player join team 1 RunConsoleCommand( "team_1" ) end team_2 = vgui.Create( "DButton", frame ) team_2:SetPos( frame:GetTall() / 100, 100 ) --Place it next to our previous one team_2:SetSize( 50, 50 ) team_2:SetText( "Team 2" ) team_2.DoClick = function() --Make the player join team 2 RunConsoleCommand( "team_2" ) end team_3 = vgui.Create( "DButton", frame ) team_3:SetPos( 50, 50 ) //Place it next to our previous one team_3:SetSize( 50, 50 ) team_3:SetText( "Team 3" ) team_3.DoClick = function() //Make the player join team 3 RunConsoleCommand( "team_3" ) end team_4 = vgui.Create( "DButton", frame ) team_4:SetPos( 50, 100 ) //Place it next to our previous one team_4:SetSize( 50, 50 ) team_4:SetText( "Team 4" ) team_4.DoClick = function() //Make the player join team 4 RunConsoleCommand( "team_4" ) end team_5 = vgui.Create( "DButton", frame ) team_5:SetPos( 25, 50 ) //Place it next to our previous one team_5:SetSize( 50, 50 ) team_5:SetText( "Team 5" ) team_5.DoClick = function() //Make the player join team 4 RunConsoleCommand( "team_5" ) end end concommand.Add( "team_menu", set_team ) Thanks guys! Sorry for the inconvenience X-)
Are there any lua errors being printed?
You have two Player Loadout Hooks choose either or then delete the one you don't need.
Sorry, you need to Log In to post a reply to this thread.