Garry's Mod

Garry's Mod

[simfphys] Randy's Extra Functions
 This topic has been pinned, so it's probably important
Randy  [developer] Nov 21, 2022 @ 8:26am
FOR MOD CREATORS:
If you wish to utilize these features on your vehicles, here's a guide on how to do that!

Enabling features is as simple as it can be. Simply go into your simfphys vehicle's LUA file, and where you configure stuff like the seat position and engine torque and stuff, just add in the fields you want to activate, as if they were default simfphys features.

Example of enabling features[i.imgur.com]

Best of all, you do not have to mark this as a required addon at all. If these features are specified in your vehicle's config but the addon isn't installed, the vehicle will simply work normally as if nothing's changed.

The random colors feature has the following config options:
  • AllowRandomColors = true/false | This will let your vehicle generate with random colors.
  • RandomColorMin = 0/255 | Optional | The minimum RGB value for random colors.
  • RandomColorMax = 0/255 | Optional | The maximum RGB value for random colors.
  • RandomColorPresets = TABLE | Optional | You can specify preset colors the vehicle can spawn with. Format: { Color(255,0,0), Color(0,255,0) }
  • ProxyColorPresets = TABLE | Optional | With this you can specify Proxy Color presets for the vehicle. These will only be used if Proxy Color tool is installed, and will overwrite the normal colors.
If RandomColorMin and RandomColorMax are not specified, the value will go from 0 to 255.

The random skins feature has the following config options:
  • AllowRandomSkins = true/false | This will allow random skins on your vehicle.
  • RandomSkinRange = {MinValue,MaxValue} | Optional | This will specify a range the skins can be picked from.

The random bodygroups feature has the following config options:
  • RandomBodygroups = TABLE | This will let your vehicle generate with random bodygroups. For every item in the table you can specify:
    number - the number of the slot you want to change
    min | Optional - the minimum value the slot should get.
    max | Optional - the maximum value the slot should get.
WARNING - If "min" is specified without "max" also being specified, the minimum value WILL NOT WORK. You must specify either BOTH or NEITHER. This is unintentional, I just don't know how to fix it atm
If min and max are not specified, the value will go from 0 to the number of bodygroups that are in that slot.

The presets feature has the following config options:
  • Presets = TABLE | This will enable presets. For every item in the table you can specify:
    bodygroups = Table of strings | The bodygroup strings that this preset can spawn with.
    colors = Table of colors | The colors that this preset can spawn with.
    proxyColors = Table of colors, with 2 colors per item | The proxy colors that this preset can spawn with.
    skins = Table of integers | The skins that this preset can spawn with.
An example for using presets[i.imgur.com]

There are also a bunch of disconnected features you can enable. These are all optional and none of them depend on each other. They are:
  • NoAlarm = true/false | This will disable the possible alarm for your vehicle.
  • ForceAlarm = true/false | This will force your vehicle to have an alarm.
  • SimpleIgnition = true/false | This will force your vehicle to use the simple default simfphys ignition. Useful for electric vehicles that don't have starters.
  • HasAirbrakes = true/false | This will make your vehicle use air brake sounds when braking.
  • IsTrailer = true/false | This will tell the script that your vehicle is a trailer. It will automatically lock itself on spawn and will not play braking sounds.
  • NoBrakes = true/false | This will disable braking sounds on the vehicle.
  • HasBullhorn = true/false | This will give your vehicle a bullhorn.
  • MinIgnitionTime = Float | The minimum time the ignition should take, in seconds. Def 0.3
  • MaxIgnitionTime = Float | The maximum time the ignition should take, in seconds. Def 0.7

Trailer legs have received new options as well. They are:
  • TrailerLegsPosition = Vector | This is the command that will enable trailer legs. Please specify the bottom of your trailer's legs here.
  • TrailerLegsPoseParameter = String | Optional | With this, you can change the legs script pose parameter. The default value for this is "trailer_legs".
  • TrailerLegsHeight = Float | Optional | With this you can change how far up the trailer leg will go when it is retracted.
  • SingleTrailerLeg = true/false | Optional | By default, the trailer legs use a long cube model, set this to true if you want it to be a small cube instead.
In addition to this, using trailer legs requires your model to have a pose parameter for your trailer's legs. on 0, the legs should be down, and on 1 they should be up.

There are also a bunch of New Sounds you can specify for your vehicle. These are all optional.
  • snd_starter = String | This sound is the START of the ignition.
  • snd_starter_good = String | This sound is the successful ignition.
  • snd_starter_bad = String | This sound is the UNsuccessful ignition. If you do not specify this, but specify the _good sound, that sound will be used for this as well.
  • snd_stop = String | This sound is when your vehicle shuts off.
  • snd_reverse_beep = String | Specifying a sound here will enable the reverse beeping on your vehicle. There is a generic sound included with the addon, the path to it is "vehicles/gen_reverse.wav"
  • snd_bullhorn = String | This is the bullhorn sound. This will only be used if your vehicle has a "HasBullhorn" field on it. Here you can specify a different sound from the default one.
  • snd_simpleIgnition = String | This sound will be played if "Advanced Ignition" is turned off, or if "SimpleIgnition" is set to true on the vehicle.

There are a few types of starters you can specify for your vehicle. These are:
vehicles/starter_generic.wav - this is the default sound
vehicles/starter_old.wav
vehicles/starter_oldtruck.wav
vehicles/starter_smalltruck.wav
vehicles/starter_truck.wav

The EMS Radio can be enabled with:
  • PolRadioSound = String | The EMS Radio will play this sound.
  • PolRadioMinTime = Integer | Optional | The minimum amount of time between EMS Radio sounds. Def 10
  • PolRadioMaxTime = Integer | Optional | The maximum amount of time between EMS Radio sounds. Def 35
There is, of course, a default sound included with the addon. "Simf_PolRadio"
Thanks to the way source is made, everytime the sound is played, it picks a random wav file. The default sound is a seperate lua file in the addon that you can copy to make your own.

Custom License Plates
There is a standard generic license plate model that works with this script that is included with this addon. In a nutshell, it's a model of a plate where each character is a bodygroup that contains all possible characters. The script simply picks a random slot for each bodygroup, thus randomizing the plate.

If you simply want to use the generic plate provided with this addon, you need to specify:
  • LPGroup = Plates_Generic | This will pick the standard generic plate for your vehicle. To then add the plate you need to specify:
  • LPMountFront = Vector | A mounting point for either the front plate,
  • LPMountRear = Vector | or the rear plate. You can also specify both.
  • LPRotateFront = Angle | Optional | Lets you rotate the plate if it needs to be tilted.
  • LPRotateRear = Angle | Optional | Lets you rotate the plate if it needs to be tilted. Note that the rear plate is automatically rotated 180 degrees.
  • LPType = TABLE | Optional | With this, you can specify additional sub-types of plates. The standard generic group does NOT have any types, thus if you are using that, you can leave this field out.

If you want to use a custom license plate model, please decompile the standard plate and study how it is made so you can make your own model.
Then once that is done, you will need to copy the "_simfphys_plates_generic.lua" file into your own lua folder and rename it. Inside that file you will find further instructions.

The license plates may be greatly reworked in the future, keep an eye out
Last edited by Randy; Mar 2, 2023 @ 8:06am