How do I make a Job spawn with a SWEP?

I’m trying to make an assassins class with the “Climb SWEP 2” from the workshop and I can’t for the life of me figure it out. If someone could help me out that’d be awesome. Basically I want to know how to make a class spawn with a specific SWEP, is there a universal way to go about this?

Well, all you need to do is give that SWEP to them once they spawn using something like

Player:Give - you could do that by hooking into

GM/PlayerInitialSpawn

Someone will probably tell you the proper way to do this in DarkRP (if you’re doing it in that) though

Where would I put this? Like, disregard it being DarkRP for a moment, where would you personally put this?

Do you mean the code? Well, if it wasn’t DarkRP, I’d just put it in any old serverside Lua file, but if it was DarkRP, I’d just put it in the job file for whatever job you’re using (I think there’s a part in this file where you can set what happens when you spawn and what weapon you have)

I’m assuming this is for darkrp, and there is literately a config to what weapons they spawn with.

… Very helpful mate, would you mind informing me of where this is? I don’t see how this makes sense though because the SWEP I’d be adding isn’t default…

Looking at this, it seems that you can set it as the ‘weapons’ bit

Thank you, this is useful. I understand how to add in weapons onto, but how would I add in a custom weapon, you know? Would you mind looking at the addons code and specifying where i could find the weapon tag (worldmodel) ? workshop

I think you could find out it’s ‘weapon tag’ (which I think is just the weapon’s class) by running this with that weapon equipped:



print( LocalPlayer():GetActiveWeapon():GetClass() )


[editline]26th March 2016[/editline]

I’ll check what it prints for you, hang on

**climb_swep2 **is the class name. If you extract the addon with gmad the folder or file name in the weapons folder is the class name.

Goddamn it you beat me

I mean, if you didn’t look at the jobs already, it says with the rest of the functions…


weapons = {"weapon_p2282"},

Just change it to


weapons = {"climb_swep2"},

and that job will spawn with climb_swep2

I see what you mean now, I thought you were talking about a whole separate file for weapons lol

[editline]26th March 2016[/editline]

Where would I run this ? print( LocalPlayer():GetActiveWeapon():GetClass() )

[editline]26th March 2016[/editline]

This didn’t work? That’s why I’m stumped because I’ve tried to just put “climb_swep2” in the weapons and nothing happens, would i have to put the addon in my weapons folder? such as (C:\GMOD\garrysmod\addons\darkrpmodification-\lua\weapons)?

Don’t worry, you don’t need to now that someone else found the weapon’s class (but if you wanted to run it you could do


"lua_run_cl print( LocalPlayer():GetActiveWeapon():GetClass() )"

in the console if sv_allowcslua was enabled)

You could put it in lua/autorun/client and then when you are on single-player you would run it with lua_openscript_cl lua/autorun/client/filename.lua. For example if you called the file grabWeapon.lua you woud call lua_openscript_cl lua/autorun/client/grabWeapon.lua in your single-player console.

[editline]26th March 2016[/editline]

Or you could do that :smile:

I was asking for future reference, thanks m8!

Huh ?

This is one of my jobs from the jobs.lua file, it uses the climb swep.




TEAM_SPY = DarkRP.createJob("Spy", {
	color = Color(245, 203, 203, 255),
	model = {
		"models/player/mossman.mdl"
		 },
	description = [[As Spy you are hired by players to stalk/Eavesdrop on that player and find out information, you can charge money.]],
	weapons = {
	
	"bb_usp",
	"realistic_hook",
	"climb_swep2",
	"eoti_disg_hide"
		
	}, 
	command = "spy",
	max = 2,
	salary = 15,
	admin = 0,
	vote = false,
	hasLicense = false,
})



I feel like a dumbass lmaoo, I got it now that you shared that, I forgot quotes xD

[editline]26th March 2016[/editline]

Thank you MPan1 and Cheese, you guys were very helpful

Add me on steam cheese :slight_smile: