1. Post #1
    101% Asian
    Banhfunbags's Avatar
    April 2007
    2,025 Posts
    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'
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 1 (list)

  2. Post #2
    devinpro's Avatar
    May 2008
    96 Posts
    Okay, here is probably what you would do.
    function GM:PlayerLoadout( ply )
     if(ply:Team()==1){
    ply:Give("weapon")
    }
    end
    
    You should get the point.
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 7Friendly Friendly x 1 (list)

  3. Post #3
    melindagreen's Avatar
    November 2009
    1,563 Posts
    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

    Code:
    function GM:PlayerLoadout( ply )
    	ply:StripWeapons()
     	ply:Give( "weapon_physcannon" )
            ply:Give( "weapon_physgun" )
            ply:Give( "gmod_tool" ) 
    end
    for team loadout:

    Code:
    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)

    Code:
    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
    Reply With Quote Edit / Delete Reply United States Show Events Friendly Friendly x 4Informative Informative x 1 (list)

  4. Post #4

    November 2009
    474 Posts
    sbox_weapons 0

    If thats what you need D:
    Reply With Quote Edit / Delete Reply United States Show Events Friendly Friendly x 2Dumb Dumb x 2Agree Agree x 1 (list)

  5. Post #5
    101% Asian
    Banhfunbags's Avatar
    April 2007
    2,025 Posts
    function GM:PlayerLoadout( ply ) ply:StripWeapons()
    end I just did this and got it. Thanks

  6. Post #6
    open.gl
    Overv's Avatar
    February 2007
    7,431 Posts
    Okay, here is probably what you would do.
    function GM:PlayerLoadout( ply )
     if(ply:Team()==1){
    ply:Give("weapon")
    }
    end
    
    You should get the point.
    Get out.
    Reply With Quote Edit / Delete Reply Netherlands Show Events Agree Agree x 5Dumb Dumb x 2 (list)

  7. Post #7
    metromod.net
    _Chewgum's Avatar
    April 2010
    2,216 Posts
    function GM:PlayerLoadout(player)
    end;
    

  8. Post #8
    101% Asian
    Banhfunbags's Avatar
    April 2007
    2,025 Posts
    ^ That works too.
    But I have another problem, when I spawn without weapons, my HUD disappears. I didn't realize that before.

  9. Post #9
    H0rsey's Avatar
    March 2010
    227 Posts
    Okay, here is probably what you would do.
    function GM:PlayerLoadout( ply )
     if(ply:Team()==1){
    ply:Give("weapon")
    }
    end
    
    You should get the point.
    You don't know lua, nor did he ask for that. What are you doing? Get the fuck out.
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Agree Agree x 3Dumb Dumb x 1 (list)

  10. Post #10
    Gold Member
    alexanderk's Avatar
    May 2007
    1,355 Posts
    oh god i laughed at devinpro
    Reply With Quote Edit / Delete Reply Norway Show Events Agree Agree x 1 (list)

  11. Post #11
    101% Asian
    Banhfunbags's Avatar
    April 2007
    2,025 Posts
    is it possible for you make it so that some teams have weapons and some teams don't?

  12. Post #12
    Gold Member
    Killer_Steel's Avatar
    October 2007
    1,362 Posts
    Code:
    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.

  13. Post #13
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,831 Posts
    On another note, for getting teams by name (not the best way really, but I use it for little scripts on servers)

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

  14. Post #14
    |FlapJack|'s Avatar
    July 2009
    6,138 Posts
    hook.Add("PlayerLoadout" , 0 , function() return false end )

  15. Post #15

    October 2011
    12 Posts
    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

  16. Post #16
    Casual Bananas
    E X C L's Avatar
    February 2011
    1,716 Posts
    Add a reference to GM.

  17. Post #17
    We Are No Idiots
    Aide's Avatar
    March 2010
    4,776 Posts
    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)

  18. Post #18

    October 2011
    12 Posts
    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 :)

  19. Post #19
    We Are No Idiots
    Aide's Avatar
    March 2010
    4,776 Posts
    Then ply:StripWeapons()


    wiki.garrysmod.com

  20. Post #20
    zzaacckk's Avatar
    June 2009
    2,146 Posts
    Use GAMEMODE instead of GM.

  21. Post #21

    November 2009
    474 Posts
    Why the hell was this thread bumped from LAST YEAR?

  22. Post #22

    October 2011
    12 Posts
    @zack - thankyou very much, switched GM for GAMEMODE and for the first time have been able to play without that damn physgun however i need to run the script and kill myself first, i assume there is a more elegant way of spawning without weapons upon compiling and running the map?

    @aide - thanks for the posts i really appreciate the help, the reference to the wiki was a little condescending though, i do do my reading before asking for peoples time its just this was a very specific issue that id been working at for a while, perhaps you just thought i might not have seen it yet.

    @mikeym - im sorry to have upset you, but that's not particularly constructive in any direction is it? i found this thread on the net and i thought tagging onto the bottom of it would avoid a lot of 'try this, already have, try this, already have' type scenarios. like i said im new here im not trying to mess with anything.

    thanks again everyone!