A long time ago in 2009, I made many different playermodels for a game called Garry's Mod. I made this tutorial a long time ago, but I decided to make a copy of it here before it eventually gets purged from it's original post. Many of the things listed below may be outdated, the steps for preparing the model are mostly the same. Jan 17, 2012.
Lua: Your First Scripted Weapon |
Description: | A step-by-step guide to developing your first Garry's Mod Scripted Weapon. |
Original Author: | Badger |
Created: | 14th March 2011 |
|
Better known as a SWep (or SWEP in some cases) a scripted weapon is a weapon that has an underlying script controlling its operation. Popular choices for SWeps include launching objects, such as watermelons or chairs, and 'better' versions of existing weapons, like a crossbow that can shoot several bolts per second. In this tutorial, we will be making a SWep with the RPG Launcher model to fire chairs.
First of all, it is suggested you download a good code editor such as Notepad++, with a GMod Lua syntax highlighter like this one. This will make your life a lot easier. See Getting Started With Lua for help.
Go to the directory (folder): <Steam Folder>/steamapps/<Steam Username>/garrysmod/garrysmod/lua. The default location of the steam folder is C:Program FilesSteam, or C:Program Files (x86)Steam for 64-bit operating systems.
Destinator 7 pda greek maps free. Now, create a new directory with a simple name (without spaces) for your SWep. e.g. chair_thrower
Tip:In a SWep, there are normally 3 script files:
init.lua is run Serverside. Doom 2 movie full. This environment will contain functions that will affect the server, such as killing players or throwing things.
cl_init.lua is run Clientside. This is for functions that will affect clients individually. It is used for things like rendering shoot effects/explosions.
shared.lua is run in both environments (server/clientside). Normally this is used only for weapon information.
There is however, an alternative way of laying out SWeps. It is possible to to include both the server-only and client-only code in the shared.lua file. Simply put the serverside/clientside code inside an if statement like so: Myriad 4 2 1 – audio batch processor.
Tip:An example of this is shown below:
Complete anatomy 2018 3 2 – anatomy learning platform plans. Note: We will be using the single file (shared.lua) layout for this tutorial.
At the top of the shared.lua file, you can enter all of the information that will define a SWep's name, category, and certain behaviours, amongst other things. Your SWep will work without most of this information, but it's ideal to include details.
The next piece of information is important. It tells Garry's Mod what player groups can see the SWep in the Spawn (Q) Menu.
This information is also important. It defines the SWep's models. Copied 1 1 4 – clipboard manager with icloud sync.
The following code sets up the SWeps primary/secondary fire and ammo.Primary:
The same applies to the secondary system:
It is always good practice to precache sounds, so there is no delay when using the gun. It can be done as below:
This is where we define what the SWep will do.
Both Reload() and Think() are not needed by this SWep so we will provide empty functions for them.
This function we are defining will spawn and throw the chair. It accepts one argument, the filename of the model to be used. That means it can be used to throw almost anything, from barrels to ragdolls.
Now we've defined the function to spawn and throw props, we need to define the ones that will actually be triggered when we fire:
Once the above is combined, you will have a fully functional chair throwing RPG Launcher. When creating your own SWeps, it's ideal to check and re-check your code. Even the world's best developers make mistakes.
Below is a combination of the code snippets above, Don't just copy the code, make sure you understand it beforehand.
https://coolxload644.weebly.com/cookie-5-8-4-protect-your-online-privacy-issues.html. Call of chernobyl scope fix.