• Making 'Q' Menu SWEPS un-spawnable
    8 replies, posted
Where can I find the SWEPS' .lua files in gmod 13 on a dedicated server? I want to set all the weapons to SWEP.Spawnable = false, but i can't find the .lua files for them.
Instead of that painful process you can remove the ability to spawn the weapons with this: [b][url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5e83.html]Gamemode.PlayerSpawnSWEP [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[QUOTE=Ice Tea;40372167]Instead of that painful process you can remove the ability to spawn the weapons with this: [b][url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5e83.html]Gamemode.PlayerSpawnSWEP [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b][/QUOTE] Thank you!! Where should I put this, and how do I make it run on start up? Sorry, I'm a bit of a .lua tard :(
You would need to find it in your gamemode. If it doesn't exist, just create a new function with that name and return false in the init.lua in your gamemode's "gamemode" folder An example of the code is provided in the link Ice Tea sent you.
[QUOTE=SeveredSkull;40374393]You would need to find it in your gamemode. If it doesn't exist, just create a new function with that name and return false in the init.lua in your gamemode's "gamemode" folder An example of the code is provided in the link Ice Tea sent you.[/QUOTE] Thanks! I couldn't find it in my gamemode's shared.lua, so I just pasted it in at the bottom, and it doesn't work. It doesn't throw any errors, I can just still spawn SWEPS. Do I need to put something in place of the ( ply, class, wep )?
[b]PlayerSpawnSWEP[/b] is a serverside function, which would belong in [b]init.lua[/b] in your case. This would be the function to only allow admins to spawn weapons: [lua]function GM:PlayerSpawnSWEP( ply, class, weapon ) return ply:IsAdmin() || ply:IsUserGroup( "superadmin" ); end[/lua]
[QUOTE=Walrus Viking;40378296][b]PlayerSpawnSWEP[/b] is a serverside function, which would belong in [b]init.lua[/b] in your case. This would be the function to only allow admins to spawn weapons: [lua]function GM:PlayerSpawnSWEP( ply, class, weapon ) return ply:IsAdmin() || ply:IsUserGroup( "superadmin" ); end[/lua][/QUOTE] Have tried this, and also this [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7b0a.html"]PlayerGiveSWEP[/URL] but it still doesn't have any effect in game, whether I am admin or not. I hit 'Q' in game, go to the weapons tab, and I am still able to give myself a weapon. Just to clarify, I've done it like this, in \SRCDS\orangebox\garrysmod\gamemodes\sandbox\gamemode\shared.lua [IMG]http://i37.tinypic.com/16m4yll.jpg[/IMG]
Make sure there are no other PlayerGiveSWEP and PlayerSpawnSWEP hooks in any of files.
[QUOTE=Robotboy655;40380361]Make sure there are no other PlayerGiveSWEP and PlayerSpawnSWEP hooks in any of files.[/QUOTE] Thank you!!! The SWEPS were in player.lua!! I just added [lua] ply:IsAdmin() || ply:IsUserGroup( "superadmin" );[/lua] after the return, and it works perfectly!! Admins & Superadmins can spawn SWEPS, players cannot! I will be trying the same for NPCs which are also in the player.lua file! Thanks to all for your input!
Sorry, you need to Log In to post a reply to this thread.