banner



How To Make Gmod Run Better

A tutorial on how to take custom entities such as weapons prove upward in hammer.

At the terminate of this tutorial yous will know how to implement custom entities into your maps and the basics of making your ain FGD.

What to Do If You Run into Issues

If you run into a problem the fastest way is to ask a question on the Steam Source SDK Forums, Reddit, or the Source Engine Discord. But do be certain to search first, often someone else has already had the aforementioned problem and solved it!

You tin can email me directly only I answer the fastest to posts on the Source SDK forums since Steam puts the alert in my face.

Video Version of This Tutorial

Don't feel like reading or need a visual aid? Check out the video!

Things You Will Need to Download

  • Garry's Mod

  • Notepad++, Visual Studio Code, or any other editor for working with text files that is NOT notepad or Word

Discover the Classname of the Entity

In club to spawn the entity you need to know it's classname, the easiest manner to do this is to extract the contents of the workshop file and find the entities master file/folder as that volition be the classname for it.

  1. Get to the workshop and subscribe to the weapon/entity yous want to implmenet into your map, for me I am going to use this Silenced Ak47 and TTT Famas

  2. Navigate to your GarrysMod install directory in steamapps/mutual image-center

  3. Open the bin directory in a new window, y'all tin can practice this by right cicking on it and choosing "Open in a new window"

  4. Keep the bin directory open in the other window and in the original window navigate to garrysmod/addons image-center

  5. Find your addon adding in .gma and drag information technology on top of gmad.exe and it will begin to unpack it into your addons directory

  6. Explore the newely unpack addon for the entities lua file, this volition be the classname for the entity.

For the Silenced AK47 this was in \addons\silenced_ak47_1857391969\lua\weapons and was called weapon_triage_ak47_s.lua

image-center

For the TTT Famas this was in \addons\ttt_famas_337050692\gamemodes\terrortown\entities\weapons and was called weapon_ttt_famas.lua

image-center

Notation: The location can vary depending on what gamemode and how the creator implmented it. Gamemode specific entities tend to exist inside of the gamemodes folder.

Placing the Entity in Hammer

  1. Start Garry's Mod's hammer within the bin binder.

  2. In your map create a point entity image-center

  3. Select the entity and open up the entities properties window (alt+enter)

  4. Select the class name in the drib downwards list and write in your new entities name that you found in the previous section without the lua extension . E.chiliad. weapon_triage_ak47_s and weapon_ttt_famas image-center

  5. Press Apply, you volition at present see that y'all take the "Obsolete" icon. This is normal.

  6. Compile the map but practise not run the map from hammer. Sometimes when launching through hammer addons don't get mounted before the map actually loads in causing custom entities to not work. Run Garry's Mod from Steam and load the map.

  7. You should at present run into your weapon sitting on the ground.

image-center

NOTE: If it doesn't spawn in check the console for an error message related to trying to create an unkown entity

Annotation: Some entities it appears are imposible to utilise through this method. As an instance virtually NPC's volition not work considering they are not truly new entities they are a base npc such as a insubordinate or combine that has it's model switched out, so they still have the same classname. If you are working with Nextbots this shouldn't be an issue however.

Creating a Custom FGD

Manually typing in the classname every time is time consuming and if you lot have a typo and so it will non work. And then let'southward create our own FGD then that Hammer knows what the entities are.

Before nosotros begin you should sympathise what an FGD actually is. The elementary caption is that an FGD is like an English to Spanish translation book. It tells Hammer what it should look like in the edtior along with what keyvalues, inputs/outputs, and flags it has that are user friendly while also having what the Source Engine is expecting one time it is compiled. Proceed in mind that an FGD DOES NOT create entities, only because y'all ascertain something in information technology does non make it existent the code must too be.

Let's brainstorm creating our own FGD.

  1. Navigate to the to Garry'south Mod's bin folder, y'all will see it already has several FGD files in information technology

  2. Right click inside the folder and choose New -> Text Certificate and name it MyFGD.fgd

  3. Open your newly created file in any text editor you prefer, I'm using Visual Studio Code

  4. I'grand going to create an entity for the Silenced AK47, my lawmaking will look like this

            @PointClass base(Weapon) studio("models/weapons/w_triage_ak47_s.mdl") = weapon_triage_ak47_s : "Silenced AK47" []                      

Let me explicate what each function of this is at present but if you desire a more in depth explanation read the FGD documentation:

  • @PointClass : This is the course blazon of the entity, things similar weapons, logic entities, etc are all Point Entities. If we were making a custom castor entity it would have the form of SolidClass

  • base of operations(weapon) : This is the base entity definition, rather then rewrite every unmarried time we can pull from a parent that has the bones setup we need

Here is what the definition for weapon looks like from the halflife2.fgd

            @BaseClass color(0 0 200) base(Targetname, Angles, GMODSandbox) sphere(fademindist) sphere(fademaxdist) = Weapon [ 	spawnflags(Flags) = 	[ 		ane : "Start constrained" : 0 		two : "Deny role player pickup (reserve for NPC)" : 0 		4 : "Not puntable by Gravity Gun" : 0 	]  	output OnPlayerUse(void) : "Fires when the player +uses this weapon" 	output OnPlayerPickup(void) : "Fires when the player picks up this weapon" 	output OnNPCPickup(void) : "Fires when an NPC picks upwards this weapon" 	output OnCacheInteraction(void) : "Fires when the player 'proves' they've institute this weapon. Fires on: Player Touch, +USE pickup, Physcannon pickup, Physcannon punt."  	fademindist(float) : "Get-go Fade Dist/Pixels" : -ane : "Distance at which the prop starts to fade (<0 = use fademaxdist). If 'Screen Infinite Fade' is selected, this represents the number of pixels wide covered past the prop when it starts to fade." 	fademaxdist(float) : "End Fade Dist/Pixels" : 0 : "Maximum distance at which the prop is visible (0 = don't fade out). If 'Screen Space Fade' is selected, this represents the *minimum* number of pixels wide covered by the prop when it fades." 	fadescale(float) : "Fade Scale" : 1 : "If yous specify a fade in the worldspawn, or if the engine is running nether dx7, and so the engine will forcibly fade out props even if fademindist/fademaxdist isn't specified." + 												 " This calibration factor gives you lot some control over the fade. Using 0 here turns off the forcible fades." + ]                      

Again, just beceause it is in the FGD does not mean it is going to work. Even so considering we know the Silent AK47 is using the proper base of operations weapon script it is highly probable these volition all work.

  • studio("models/weapons/w_triage_ak47_s.mdl") : This tells hammer what model to employ for dispalying in the editor window. If you want an icon you can utilise iconsprite

  • weapon_triage_ak47_s : This is the entities classname

  • : "Silenced AK47" : This is the assistance text that go'south displayed if you press the help button in Hammer

  • [] : Additional entity properties would go betwixt these square brackets simply considering this is a basic weapon we don't need any

At present then save the FGD and open Hammer.

  • Click Tools -> Options...

image-center

  • Click Add and select your new FGD

  • You can now place your entities in Hammer!

image-center

If you are wanting to make game logic entities and demand a refrence check out TTT'southward official FGD file

Remember when you upload your map to the workshop that you add together the weapons/entities workshop pages as requirements, practise not pack other peoples work into yours without permission!!!

If yous have feedback experience free to shoot me an email and if you want to purchase me a coffee on Ko-fi information technology would exist really appreciated!

Source: https://jesseculver.com/tutorials/gmodcustomentityhammer/

Posted by: hobbsluldenced.blogspot.com

0 Response to "How To Make Gmod Run Better"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel