• Need a Function for a Menu!
    2 replies, posted
Sup Guys! I need a function that opens a menu where you can select weapons , and then press spawn and you spawn . Note im using fretta as base gamemode . One of the two player_classes : [CODE]// Create new class local CLASS = {} // Some settings for the class CLASS.DisplayName = "England" CLASS.WalkSpeed = 100 CLASS.CrouchedWalkSpeed = 0.2 CLASS.RunSpeed = 250 CLASS.DuckSpeed = 0.2 CLASS.DrawTeamRing = false // Called by spawn and sets loadout function CLASS:Loadout(pl) if game.GetMap() == "wz_sniperfight" then pl:Give( "weapon_m24sd" ) end if game.GetMap() == "wz_crossfire_v2" then pl:Give("knife") pl:Give("gdcw_deaglez") pl:Give("gdcw_scarh") pl:Give("gdcw_mp5") pl:Give("weapon_grenade") end if game.GetMap() == "wz_deagle" then pl:Give("knife") pl:Give("gdcw_deaglez") end if game.GetMap() == "wz_schrottplatz" then pl:Give("knife") pl:Give("gdcw_deaglez") pl:Give("gdcw_scarh") pl:Give("gdcw_mp5") pl:Give("weapon_grenade") end end // Called when player spawns with this class function CLASS:OnSpawn(pl) pl:SetColor( Color(255, 255, 255, 0)) end // Called when a player dies with this class function CLASS:OnDeath(pl, attacker, dmginfo) end // Register player_class.Register("England", CLASS)[/CODE] If you need more code information write me in steam : steamcommunity.com/id/clbanderthegamer/ Thanks for all help :) [editline]24th July 2013[/editline] Thats the Init.lua [CODE]/* init.lua - Server Component ----------------------------------------------------- The entire server side bit of Fretta starts here. */ AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) AddCSLuaFile( 'skin.lua' ) AddCSLuaFile( 'player_class.lua' ) AddCSLuaFile( 'class_default.lua' ) AddCSLuaFile( 'cl_splashscreen.lua' ) AddCSLuaFile( 'cl_selectscreen.lua' ) AddCSLuaFile( 'cl_gmchanger.lua' ) AddCSLuaFile( 'cl_help.lua' ) AddCSLuaFile( 'player_extension.lua' ) AddCSLuaFile( 'vgui/vgui_hudlayout.lua' ) AddCSLuaFile( 'vgui/vgui_hudelement.lua' ) AddCSLuaFile( 'vgui/vgui_hudbase.lua' ) AddCSLuaFile( 'vgui/vgui_hudcommon.lua' ) AddCSLuaFile( 'vgui/vgui_gamenotice.lua' ) AddCSLuaFile( 'vgui/vgui_scoreboard.lua' ) AddCSLuaFile( 'vgui/vgui_scoreboard_team.lua' ) AddCSLuaFile( 'vgui/vgui_scoreboard_small.lua' ) AddCSLuaFile( 'vgui/vgui_vote.lua' ) AddCSLuaFile( 'cl_hud.lua' ) AddCSLuaFile( 'cl_deathnotice.lua' ) AddCSLuaFile( 'cl_scores.lua' ) AddCSLuaFile( 'cl_notify.lua' ) AddCSLuaFile( 'player_colours.lua' ) include( "shared.lua" ) include( "sv_gmchanger.lua" ) include( "sv_spectator.lua" ) include( "round_controller.lua" ) include( "utility.lua" ) GM.ReconnectedPlayers = {} function GM:Initialize() util.AddNetworkString("PlayableGamemodes") /* // Disabled - causes games to end in the middle of a round - we don't want that to happen! // ::Think takes care of this anyway. if ( GAMEMODE.GameLength > 0 ) then timer.Simple( GAMEMODE.GameLength * 600000, function() GAMEMODE:EndOfGame( true ) end ) SetGlobalFloat( "GameEndTime", CurTime() + GAMEMODE.GameLength * 600000 ) SetGlobalFloat( "GameEndTime", CurTime() + GAMEMODE.GameLength * 600000 ) end */ // If we're round based, wait 3 seconds before the first round starts if ( GAMEMODE.RoundBased ) then timer.Simple( 3, function() GAMEMODE:StartRoundBasedGame() end ) end if ( GAMEMODE.AutomaticTeamBalance ) then timer.Create( "CheckTeamBalance", 30000, 0, function() GAMEMODE:CheckTeamBalance() end ) end end function GM:Think() self.BaseClass:Think() for k,v in pairs( player.GetAll() ) do local Class = v:GetPlayerClass() if ( !Class ) then return end v:CallClassFunction( "Think" ) end // Game time related if( !GAMEMODE.IsEndOfGame && ( !GAMEMODE.RoundBased || ( GAMEMODE.RoundBased && GAMEMODE:CanEndRoundBasedGame() ) ) && CurTime() >= GAMEMODE.GetTimeLimit() ) then GAMEMODE:EndOfGame( true ) end end /*--------------------------------------------------------- Name: gamemode:CanPlayerSuicide( Player ply ) Desc: Is the player allowed to commit suicide? ---------------------------------------------------------*/ function GM:CanPlayerSuicide( ply ) if( ply:Team() == TEAM_UNASSIGNED || ply:Team() == TEAM_SPECTATOR ) then return false // no suicide in spectator mode end return !GAMEMODE.NoPlayerSuicide end /*--------------------------------------------------------- Name: gamemode:PlayerSwitchFlashlight( Player ply, Bool on ) Desc: Can we turn our flashlight on or off? ---------------------------------------------------------*/ function GM:PlayerSwitchFlashlight( ply, on ) if ( ply:Team() == TEAM_SPECTATOR || ply:Team() == TEAM_UNASSIGNED || ply:Team() == TEAM_CONNECTING ) then return not on end return ply:CanUseFlashlight() end /*--------------------------------------------------------- Name: gamemode:PlayerInitialSpawn( Player ply ) Desc: Our very first spawn in the game. ---------------------------------------------------------*/ function GM:PlayerInitialSpawn( pl ) surface.PlaySound( "tdm.mp3" ) pl:SetTeam( TEAM_UNASSIGNED ) pl:SetPlayerClass( "Spectator" ) pl.m_bFirstSpawn = true pl:UpdateNameColor() GAMEMODE:CheckPlayerReconnected( pl ) end function GM:CheckPlayerReconnected( pl ) if table.HasValue( GAMEMODE.ReconnectedPlayers, pl:UniqueID() ) then GAMEMODE:PlayerReconnected( pl ) end end /*--------------------------------------------------------- Name: gamemode:PlayerReconnected( Player ply ) Desc: Called if the player has appeared to have reconnected. ---------------------------------------------------------*/ function GM:PlayerReconnected( pl ) // Use this hook to do stuff when a player rejoins and has been in the server previously end function GM:PlayerDisconnected( pl ) table.insert( GAMEMODE.ReconnectedPlayers, pl:UniqueID() ) self.BaseClass:PlayerDisconnected( pl ) end function GM:ShowHelp( pl ) pl:SendLua( "GAMEMODE:ShowHelp()" ) end function GM:PlayerSpawn( pl ) pl:UpdateNameColor() // The player never spawns straight into the game in Fretta // They spawn as a spectator first (during the splash screen and team picking screens) if ( pl.m_bFirstSpawn ) then pl.m_bFirstSpawn = nil if ( pl:IsBot() ) then GAMEMODE:AutoTeam( pl ) // The bot doesn't send back the 'seen splash' command, so fake it. if ( !GAMEMODE.TeamBased && !GAMEMODE.NoAutomaticSpawning ) then pl:Spawn() end else pl:StripWeapons() GAMEMODE:PlayerSpawnAsSpectator( pl ) // Follow a random player until we join a team if ( #player.GetAll() > 1 ) then pl:Spectate( OBS_MODE_CHASE ) pl:SpectateEntity( table.Random( player.GetAll() ) ) end end return end pl:CheckPlayerClassOnSpawn() if ( GAMEMODE.TeamBased && ( pl:Team() == TEAM_SPECTATOR || pl:Team() == TEAM_UNASSIGNED ) ) then GAMEMODE:PlayerSpawnAsSpectator( pl ) return end // Stop observer mode pl:UnSpectate() // Call item loadout function hook.Call( "PlayerLoadout", GAMEMODE, pl ) // Set player model hook.Call( "PlayerSetModel", GAMEMODE, pl ) // Call class function pl:OnSpawn() end function GM:PlayerLoadout( pl ) pl:CheckPlayerClassOnSpawn() pl:OnLoadout() // Switch to prefered weapon if they have it local cl_defaultweapon = pl:GetInfo( "cl_defaultweapon" ) if ( pl:HasWeapon( cl_defaultweapon ) ) then pl:SelectWeapon( cl_defaultweapon ) end end function GM:PlayerSetModel( pl ) pl:OnPlayerModel() end function GM:AutoTeam( pl ) if ( !GAMEMODE.AllowAutoTeam ) then return end if ( !GAMEMODE.TeamBased ) then return end GAMEMODE:PlayerRequestTeam( pl, team.BestAutoJoinTeam() ) end concommand.Add( "autoteam", function( pl, cmd, args ) hook.Call( "AutoTeam", GAMEMODE, pl ) end ) function GM:PlayerRequestClass( ply, class, disa
Make a vgui menu with a drop down box with different selections for weapons and add a button to spawn and make it so that the selected weapons are the ones you spawn with. (Here's a link to the tutorial on VGUI) [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe102.html[/url]
nice thanks :)
Sorry, you need to Log In to post a reply to this thread.