Hi,
I don't know anything about lua, but I wanna make it so the sandbox gamemode starts you with less weapons.
e.g. physgun, gravgun, toolgun
Is there a lua file I need to edit?
thanks
C:\Program Files\Steam\steamapps\bradmcco\garrysmod\garrysmod\gamemodes\sandbox\gamemode
then go to init.lua
and take the ones you dont want out
eg
[LUA]
/*---------------------------------------------------------
Sandbox Gamemode
This is GMod's default gamemode
---------------------------------------------------------*/
// These files get sent to the client
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_spawnmenu.lua" )
AddCSLuaFile( "cl_notice.lua" )
AddCSLuaFile( "cl_hints.lua" )
AddCSLuaFile( "cl_worldtips.lua" )
AddCSLuaFile( "player_extension.lua" )
AddCSLuaFile( "cl_scoreboard.lua" )
AddCSLuaFile( "cl_quicktool.lua" )
AddCSLuaFile( "scoreboard/admin_buttons.lua" )
AddCSLuaFile( "scoreboard/player_frame.lua" )
AddCSLuaFile( "scoreboard/player_infocard.lua" )
AddCSLuaFile( "scoreboard/player_row.lua" )
AddCSLuaFile( "scoreboard/scoreboard.lua" )
AddCSLuaFile( "scoreboard/vote_button.lua" )
include( 'shared.lua' )
include( 'commands.lua' )
include( 'player.lua' )
include( 'rating.lua' )
/*---------------------------------------------------------
Name: gamemode:PlayerSpawn( )
Desc: Called when a player spawns
---------------------------------------------------------*/
function GM:PlayerSpawn( pl )
self.BaseClass.PlayerSpawn( self, pl )
// Set the player's speed
GAMEMODE:SetPlayerSpeed( pl, 250, 500 )
end
/*---------------------------------------------------------
Name: PlayerDataUpdate
---------------------------------------------------------*/
function PlayerDataUpdate( pl )
if ( !pl ) then return end
if ( !pl:IsValid() ) then return end
pl:SetNetworkedString( "Website", pl:GetInfo( "cl_website" ) )
pl:SetNetworkedString( "Location", pl:GetInfo( "cl_location" ) )
pl:SetNetworkedString( "Email", pl:GetInfo( "cl_email" ) )
pl:SetNetworkedString( "MSN", pl:GetInfo( "cl_msn" ) )
pl:SetNetworkedString( "AIM", pl:GetInfo( "cl_aim" ) )
pl:SetNetworkedString( "GTalk", pl:GetInfo( "cl_gtalk" ) )
pl:SetNetworkedString( "XFire", pl:GetInfo( "cl_xfire" ) )
timer.Simple( 1, PlayerDataUpdate, pl )
end
/*---------------------------------------------------------
Name: gamemode:PlayerLoadout()
---------------------------------------------------------*/
function GM:PlayerLoadout( pl )
// Remove any old ammo
pl:RemoveAllAmmo()
if ( server_settings.Bool( "sbox_weapons", true ) ) then
end
pl:Give( "gmod_tool" )
pl:Give( "gmod_camera" )
pl:Give( "weapon_physgun" )
local cl_defaultweapon = pl:GetInfo( "cl_defaultweapon" )
if ( pl:HasWeapon( cl_defaultweapon ) ) then
pl:SelectWeapon( cl_defaultweapon )
end
end
/*---------------------------------------------------------
Name: gamemode:OnPhysgunFreeze( weapon, phys, ent, player )
Desc: The physgun wants to freeze a prop
---------------------------------------------------------*/
function GM:OnPhysgunFreeze( weapon, phys, ent, ply )
self.BaseClass:OnPhysgunFreeze( weapon, phys, ent, ply )
ply:SendHint( "PhysgunUnfreeze", 0.3 )
ply:SuppressHint( "PhysgunFreeze" )
end
/*---------------------------------------------------------
Name: gamemode:OnPhysgunReload( weapon, player )
Desc: The physgun wants to freeze a prop
---------------------------------------------------------*/
function GM:OnPhysgunReload( weapon, ply )
local num = ply:PhysgunUnfreeze()
if ( num > 0 ) then
ply:SendLua( "GAMEMODE:UnfrozeObjects("..num..")" )
end
ply:SuppressHint( "PhysgunReload" )
end
/*---------------------------------------------------------
Name: gamemode:PlayerShouldTakeDamage
Return true if this player should take damage from this attacker
Note: This is a shared function - the client will think they can
damage the players even though they can't. This just means the
prediction will show blood.
---------------------------------------------------------*/
function GM:PlayerShouldTakeDamage( ply, attacker )
// The player should always take damage in single player..
if ( SinglePlayer() ) then return true end
// Global godmode, players can't be damaged in any way
if ( server_settings.Bool( "sbox_godmode", false ) ) then return false end
// No player vs player damage
if ( attacker:IsValid() && attacker:IsPlayer() ) then
return !server_settings.Bool( "sbox_plpldamage", false )
end
// Default, let the player be hurt
return true
end
/*---------------------------------------------------------
Show the school window when F1 is pressed..
---------------------------------------------------------*/
function GM:ShowHelp( ply )
ply:ConCommand( "SchoolMe" )
end
/*---------------------------------------------------------
Called once on the player's first spawn
---------------------------------------------------------*/
function GM:PlayerInitialSpawn( ply )
self.BaseClass:PlayerInitialSpawn( ply )
PlayerDataUpdate( ply )
end
/*---------------------------------------------------------
Desc: A ragdoll of an entity has been created
---------------------------------------------------------*/
function GM:CreateEntityRagdoll( entity, ragdoll )
// Replace the entity with the ragdoll in cleanups etc
undo.ReplaceEntity( entity, ragdoll )
cleanup.ReplaceEntity( entity, ragdoll )
end
/*---------------------------------------------------------
Name: gamemode:PlayerUnfrozeObject( )
---------------------------------------------------------*/
function GM:PlayerUnfrozeObject( ply, entity, physobject )
local effectdata = EffectData()
effectdata:SetOrigin( physobject:GetPos() )
util.Effect( "phys_unfreeze", effectdata, true, true )
end
/*---------------------------------------------------------
Name: gamemode:PlayerFrozeObject( )
---------------------------------------------------------*/
function GM:PlayerFrozeObject( ply, entity, physobject )
local effectdata = EffectData()
effectdata:SetOrigin( physobject:GetPos() )
util.Effect( "phys_freeze", effectdata, true, true )
end
[/LUA]
Back up your old one its untested it should work try it
Thanks!
Would this work for other players in multiplayer?
For instance, if I edited that file, and then started a listen server with it, and someone joined, would it work?
thanks
Yes it would work, any file changed on the server affects the users that join said server.
Yes, when you create a listen server you use the rules defined on your computer.
No it wouldnt! The GMod GCF file overwrites it! You can only copy sandbox change the name and THEN change it!
[QUOTE=commander204;17026634]No it wouldnt! The GMod GCF file overwrites it! You can only copy sandbox change the name and THEN change it![/QUOTE]
I'm pretty sure that for any given file, the source engine will first look in the game's folder and if nothing is found default back to the .gcf. That's how you can mod HL2 (or any source game) to use different models/materials.
[QUOTE=Crazy Quebec;17026760]I'm pretty sure that for any given file, the source engine will first look in the game's folder and if nothing is found default back to the .gcf. That's how you can mod HL2 (or any source game) to use different models/materials.[/QUOTE]
Nope. Each time a changelevel is performed the Gmod gets fresh copies of the files from the GCF. He would technically need to make a gamemode that derrives sandbox, and make the appropriate changes.
You're all wrong. Use hooks.
[lua]local function LoadOut(ply) --Make our own loadout function.
// Remove any old ammo
pl:RemoveAllAmmo()
pl:Give( "gmod_tool" )
pl:Give( "gmod_camera" )
pl:Give( "weapon_physgun" )
local cl_defaultweapon = pl:GetInfo( "cl_defaultweapon" )
if ( pl:HasWeapon( cl_defaultweapon ) ) then
pl:SelectWeapon( cl_defaultweapon )
end
return true --Overrides existing one.
end
hook.Add("PlayerLoadout", "LimitWeps", LoadOut) --Hook it. [/lua]
Seriously. Ignore brad. Listen to Skyhawk.
Sorry, you need to Log In to post a reply to this thread.