How do I make players spawn without weapons?

oh hai im new to glua

How do I make players spawn without weapons?
I’ve tried doing StripWeapons and not giving them weapons at all.
What else can I do?

I don’t know if this would help but I see this in console.

Registering gamemode ‘lol_test’ derived from ‘base’

Okay, here is probably what you would do.
[lua]
function GM:PlayerLoadout( ply )
if(ply:Team()==1){
ply:Give(“weapon”)
}
end
[/lua]
You should get the point.

this is the basic no war build only server gmod loadout.
put in your root gmod lua/autorun as a file names something like - loadout.lua



function GM:PlayerLoadout( ply )
	ply:StripWeapons()
 	ply:Give( "weapon_physcannon" )
        ply:Give( "weapon_physgun" )
        ply:Give( "gmod_tool" ) 
end 


for team loadout:



function GM:PlayerLoadout( ply )
	ply:StripWeapons() 
	if ply:Team() == 1 then
		ply:Give( "weapon_physcannon" )
		ply:Give( "weapon_physgun" )
		ply:Give( "gmod_tool" )
		--[[
                ply:Give( "weapon_crowbar" )
		ply:Give( "weapon_pistol" )
		ply:Give( "weapon_smg" )
		ply:Give( "weapon_shotgun" )
		ply:Give( "weapon_ar2" )
		ply:Give( "weapon_rpg" )
		ply:Give( "weapon_crossbow" )
		ply:Give( "weapon_frag" )--]]
 
	elseif ply:Team() == 2 then 
		ply:Give( "weapon_physcannon" )
		ply:Give( "weapon_physgun" )
		ply:Give( "gmod_tool" )
		--[[
                ply:Give( "weapon_crowbar" )
		ply:Give( "weapon_pistol" )
		ply:Give( "weapon_smg" )
		ply:Give( "weapon_shotgun" )
		ply:Give( "weapon_ar2" )
		ply:Give( "weapon_rpg" )
		ply:Give( "weapon_crossbow" )
		ply:Give( "weapon_frag" )--]]
 
	end 
end



Team loadout if you look at it you will see the weapons you can add to a player loadout. i included them but omitted them in the --[[ ]] brackets

You can also give ammo and other things in a similar fashion to the above examples.

sbox_weapons 0 will remove all weapons but the build tools also

Complete weapons list: (sort of)



Gmod tools:

gmod_tool
weapon_physgun
weapon_physcannon

HL2 weapons:

weapon_crowbar
weapon_pistol
weapon_357
weapon_smg
weapon_shotgun
weapon_ar2
weapon_rpg
weapon_crossbow
weapon_frag
weapon_stunstick
weapon_alyxgun
weapon_annabelle
weapon_bugbait
weapon_cubemap

CSS weapons:

weapon_ak47
weapon_deagle
weapon_fiveseven
weapon_glock
weapon_m4
weapon_mp5
weapon_para
weapon_pumpshotgun
weapon_tmp
weapon_mac10

Team Fortress 2 (by class):

SCOUT:
"tf_weapon_scattergun"
"tf_weapon_pistol_scout"
"tf_weapon_bat"

SNIPER:
"tf_weapon_sniperrifle"
"tf_weapon_smg"
"tf_weapon_club"

SOLDIER:
"tf_weapon_rocketlauncher"
"tf_weapon_shotgun_soldier"
"tf_weapon_shovel"

DEMOMAN:
"tf_weapon_pipebomblauncher"
"tf_weapon_grenadelauncher"
"tf_weapon_bottle"

MEDIC:
"tf_weapon_syringegun_medic"
"tf_weapon_medigun"
"tf_weapon_bonesaw"

HEAVY:
"tf_weapon_minigun"
"tf_weapon_shotgun_hwg"
"tf_weapon_fists"

PYRO:
"tf_weapon_flamethrower"
"tf_weapon_shotgun_pyro"
"tf_weapon_fireaxe"

SPY:
"tf_weapon_revolver"
"tf_weapon_builder"
"tf_weapon_knife"
"tf_weapon_pda_spy" 

ENGINEER:
"tf_weapon_shotgun_primary"
"tf_weapon_pistol"
"tf_weapon_wrench"
"tf_weapon_pda_engineer_build" 
"tf_weapon_pda_engineer_destroy"


Nuke pack 4 Weapons:

weapon_clusternuke
weapon_machnuke
weapon_nukestrike
weapon_nukepack
weapon_redeemer

Stargate Weapons:

weapon_handdevice
weapon_ringcaller
weapon_dexgun
sodan_cloak
weapon_staff
weapon_zat

WTib Weapons:

wtib_swep_sonicpulse

SBEP:
so-dronegun
sbepwepbase

Wiremod:

laserpointer
remotecontroller

Misc Gmod:

manhack_welder



sbox_weapons 0

If thats what you need D:

function GM:PlayerLoadout( ply ) ply:StripWeapons()
end I just did this and got it. Thanks

Get out.

[lua]
function GM:PlayerLoadout(player)
end;
[/lua]

^ That works too.
But I have another problem, when I spawn without weapons, my HUD disappears. I didn’t realize that before.

You don’t know lua, nor did he ask for that. What are you doing? Get the fuck out.

oh god i laughed at devinpro

is it possible for you make it so that some teams have weapons and some teams don’t?



function GM:PlayerLoadout( ply )
if (ply:Team() == 1) then
ply:Give("weapon_physgun")
ply:Give("weapon_pistol")

elseif (ply:Team() == 2) then
ply:Give("weapon_physcannon")
ply:Give("weapon_ar2")
end
end

/me prepares for the flamefest.

On another note, for getting teams by name (not the best way really, but I use it for little scripts on servers)



if team.GetName(ply:Team()) == "Cops" then
     ply:Give("weapon_pistol")
end


hook.Add(“PlayerLoadout” , 0 , function() return false end )

Hello all, been tackling this same issue for a while now so i thought it might be time to ask for a hand. I’ve tried spawning as player_weaponstrip and game_player_equip to avoid weapons which works but I end up stuck in a wall. I’ve tried saving the lua files function GM:PlayerLoadout(player) end and some variations on that, but when i go to activate them from within the in game, the console returns the message:

[lua\loadout.lua:1] attempt to index global ‘GM’ (a nil value)

and i still have my physgun tool and camera, i need to be rid of the blasted things. any ideas where i might be going wrong? thanks a lot

Add a reference to GM.

[lua]hook.Add(“PlayerLoadout”, “GiveWeapons”, function( ply )
if (ply:Team() == 1) then
ply:Give(“weapon_physgun”)
ply:Give(“weapon_pistol”)

elseif (ply:Team() == 2) then
ply:Give(“weapon_physcannon”)
ply:Give(“weapon_ar2”)
end
end)[/lua]

hey aide, am i wrong in thinking that executing that will give my player weapons? ideally I’d like to spawn with nothing at all.

@_NewBee that sounds like the sort of thing that might work, but I’m afraid you’ll have to elaborate a bit it’s my first day here. How would I go about adding a reference to GM?

Thankyou both for the responses :slight_smile:

Then ply:StripWeapons()

Use GAMEMODE instead of GM.