Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
Ok, so I reached the conclusion that SWEP was never declared as an item, so its nil as the error says.
I don't even know if SWEP is sometype of fuction.
Forgetting what I said before, when creating the swep, make it a Weapon() class
MySwep = Weapon()
I use the wiki[wiki.garrysmod.com] for help with coding, and discovered this class, which is what you want to set it to when you redo your code.
https://wiki.garrysmod.com/page/Chair_Throwing_Gun
This is a SWEP tutorial on the Garry's Mod wiki, but it fires physics props instead of bullets, but you can modify the fire function to fire bullets instead. If you need help with that, I could paste code for a primary fire function that fires bullets.
So basically I need to go back through and change every SWEP. into Weapon() such as:
SWEP.Spawnable= true > Weapon(Spawnable= true)
Hmm, that link doesn't work.
Looking at other mods I don't see any requirements for it, so your're right.
I haven't done sweps in a long time, so I have to relearn them again
Looking at the wiki tutorial gave me a huge understanding why alot of stuff was wrong.
If you want, try renaming your shared.lua myweaponname.lua and placing it in addon/lua/weapons/
This will most likely make a difference, but still might have some errors, since its made for Gmod 10.
GarrysMod > garrysmod > gamemodes > base > entities > weapons > weapon_base > shared.lua
You can see the base SWEP and see how that works. Keep in mind you don't need to copy and paste it in its entirety for your SWEP, because when you define the weapon base in your SWEP and setting it to "base", you're referring to this file, and setting a SWEP base basically just makes your SWEP inherit traits from the base that aren't defined in your SWEP.
For example you could make a SWEP base which has some realistic recoil mechanics, then in your SWEP refer to that base so that your SWEPs inherit that recoil system without having to rewrite it every time, and if you wanted to make a change to the recoil system you could just modify the base which applies to all your weapons that use this base rather than having to rewrite the recoil system individually in each SWEP.
Anyway, copy and pasting everything from the base for your SWEP isn't a good idea unless you're actually going to change those aspects for your own SWEP, so you probably want to just use the parts that will actually differ from the base swep such as variables like damage, spread, and all that.
GarrysMod > garrysmod > addons > myaddonnamehere > lua > weapons > weaponnamehere > shared.lua
Of course replacing myaddonnamehere and weaponnamehere with your own names, and make sure there's a .json file in myaddonnamehere, which defines certain things for the workshop such as name, tags, etc.