• How do I make a Job spawn with a SWEP?
    17 replies, posted
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 [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Give]Player:Give[/url] - you could do that by hooking into [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerInitialSpawn]GM/PlayerInitialSpawn[/url] Someone will probably tell you the proper way to do this in DarkRP (if you're doing it in that) though
[QUOTE=MPan1;50007352]Well, all you need to do is give that SWEP to them once they spawn using something like [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Give]Player:Give[/url] - you could do that by hooking into [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerInitialSpawn]GM/PlayerInitialSpawn[/url] Someone will probably tell you the proper way to do this in DarkRP (if you're doing it in that) though[/QUOTE] 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.
[QUOTE=Matt555;50007442]I'm assuming this is for darkrp, and there is literately a config to what weapons they spawn with.[/QUOTE] ... 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 [URL="http://wiki.darkrp.com/index.php/DarkRP:CustomJobFields"]this[/URL], it seems that you can set it as the 'weapons' bit
[QUOTE=MPan1;50007482]Looking at [URL="http://wiki.darkrp.com/index.php/DarkRP:CustomJobFields"]this[/URL], it seems that you can set it as the 'weapons' bit[/QUOTE] 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) ? [URL=http://steamcommunity.com/sharedfiles/filedetails/?id=113495466&searchtext=climb+swep+2]workshop[/URL]
[QUOTE=auctrix;50007617]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) ? [URL=http://steamcommunity.com/sharedfiles/filedetails/?id=113495466&searchtext=climb+swep+2]workshop[/URL][/QUOTE] 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: [CODE] print( LocalPlayer():GetActiveWeapon():GetClass() ) [/CODE] [editline]26th March 2016[/editline] I'll check what it prints for you, hang on
[B]climb_swep2 [/B]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
[QUOTE=auctrix;50007470]... 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....[/QUOTE] I mean, if you didn't look at the jobs already, it says with the rest of the functions... [CODE]weapons = {"weapon_p2282"},[/CODE] Just change it to [CODE]weapons = {"climb_swep2"},[/CODE] and that job will spawn with climb_swep2
[QUOTE=Matt555;50007719]I mean, if you didn't look at the jobs already, it says with the rest of the functions... [CODE]weapons = {"weapon_p2282"},[/CODE] Just change it to [CODE]weapons = {"climb_swep2"},[/CODE] and that job will spawn with climb_swep2[/QUOTE] I see what you mean now, I thought you were talking about a whole separate file for weapons lol [editline]26th March 2016[/editline] [QUOTE=MPan1;50007632]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: [CODE] print( LocalPlayer():GetActiveWeapon():GetClass() ) [/CODE] [editline]26th March 2016[/editline] I'll check what it prints for you, hang on[/QUOTE] Where would I run this ? print( LocalPlayer():GetActiveWeapon():GetClass() ) [editline]26th March 2016[/editline] [QUOTE=Cheese_3;50007662][B]climb_swep2 [/B]is the class name. If you extract the addon with gmad the folder or file name in the weapons folder is the class name.[/QUOTE] 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)?
[QUOTE=auctrix;50007780]Where would I run this ? print( LocalPlayer():GetActiveWeapon():GetClass() )[/QUOTE] 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 [CODE]"lua_run_cl print( LocalPlayer():GetActiveWeapon():GetClass() )"[/CODE] in the console if sv_allowcslua was enabled)
[QUOTE=auctrix;50007780] Where would I run this ? print( LocalPlayer():GetActiveWeapon():GetClass() )[/QUOTE] You could put it in [B]lua/autorun/client[/B] and then when you are on single-player you would run it with [B]lua_openscript_cl lua/autorun/client/filename.lua[/B]. For example if you called the file [B]grabWeapon.lua[/B] you woud call [B]lua_openscript_cl lua/autorun/client/grabWeapon.lua[/B] in your single-player console. [editline]26th March 2016[/editline] [QUOTE=MPan1;50007802] [CODE]"lua_run_cl print( LocalPlayer():GetActiveWeapon():GetClass() )"[/CODE] in the console if sv_allowcslua was enabled)[/QUOTE] Or you could do that :smile:
[QUOTE=MPan1;50007802]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 [CODE]"lua_run_cl print( LocalPlayer():GetActiveWeapon():GetClass() )"[/CODE] in the console if sv_allowcslua was enabled)[/QUOTE] I was asking for future reference, thanks m8!
[QUOTE=auctrix;50007780] 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)?[/QUOTE] Huh ? This is one of my jobs from the jobs.lua file, it uses the climb swep. [CODE] 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, }) [/CODE]
[QUOTE=Cheese_3;50007819]Huh ? This is one of my jobs from the jobs.lua file, it uses the climb swep. [CODE] 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, }) [/CODE][/QUOTE] 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 :)
Sorry, you need to Log In to post a reply to this thread.