Garry's Mod

Garry's Mod

87 ratings
VendR - Customizable Vending Machines
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Tool
Addon Tags: Build, Roleplay
File Size
Posted
Updated
7.069 KB
27 Sep, 2016 @ 2:09pm
6 Oct, 2016 @ 12:07am
2 Change Notes ( view )

Subscribe to download
VendR - Customizable Vending Machines

Description
VendR is a easy to set up vending machine entity that you can set up throughout your server to sell items without the need for dealers


GitHub[github.com]

=OCT 6th UPDATE=
  • added concommand vendr_respawn
  • added col variable in item editor, allows changing the item color to be different from inherited category color
Everything should just be backwards compatible, let me know if there are any issues!

supports DarkRP out of the box, can be modified using the CLua entry to work with other forms of payment
========

if your problem is the result of a configuration
issue, please locate the data folder for the map you are experiencing errors on in the data/vend_data/ folder. Deleting
these folders will remove all vending machines on the map and reset the addon.

These vending machine entities allow you to place several vending machines acrossed the map, with different items for sale
as well as persiting machines on a per map basis

-=SETTING UP THE VENDING MACHINES=-

to set up vending machines, you MUST be an owner/superadmin rank
Locate the entity in the entities tab, under VendR, spawn it and you will see a red '-configure-' button on the display

The window you should see pop up should be called 'Vending Machine Configuration Editor' with 3 buttons, and a list box

To change the name of this vending machine, and set its persistance, click 'Settings'
Click 'name: default', this will display a text box, change the name of the vending machine and hit enter.
ALL vending machines must have a unique name, as this is how they are identified in the database.
you can also change the text that appears at the top of the screen, as well as change the colors.

When you are happy with these settings, hit the 'Persist on Reboot' button. This will write your settings to the vending
machine and save it to the server. it will respawn where you originally had it on server reboot until it is disabled.

Hit the settings button again to refresh the menu, you will see 'Persist on Reboot' has changed to 'Disable Persistance'
as well as a new button labeled 'Sync Changes To Server'. This button must be clicked when you wish to update the server
with your changes, and distribute the changes to all other clients

Now we will go over creating categories for items. To create a new category, click the 'new' button in the configuration
editor, this will display a text box where you can enter a name for the category. Hit enter when you are finished

you will see a new entry in the list box below, with the category name, and the number of items. Click on the category
and you will see a new menu displayed on the right. you can change the name by clicking on CatName, change the color
of the category, clear the category of items (this will remove everything in that category) and finally, Create new items.

Click on the 'Create New Item' button, you will see a new entry appear below with several fields. you can click on these
to edit the properies (such as price). the buttons on the upper left can be used to delete the entry, and move it up and
down the list to re-organize entries.

For this example we will create a basic pistol entry.
Click on the name and type 'Pistol', then hit your enter key
ClassID is the class name of the entity we will be spawning, for the pistol we will change ClassID to weapon_pistol
The description is a string of text that appears under the item in the menu, change it to 'Pew Pew'
Price should be pretty obvious, change this to the price you want the item to be (numbers only)

CLua is a feature intended for developers only, to create advanced functionality, allowing you to write lua scripts in game
that will be called when someone buys the item.

once you are happy with your changes, simply return to the settings menu and sync your changes!

USING CUSTOM LUA FUNCTIONS
the CLua entry is used to add scripting to your items in the form of callback functions when a player attempts to purchase an item.

If you are experienced with lua, this will be very easy to graps.

VSHARE is a temporary table created when a player attempts to buy an item. The values assigned to VSHARE are as follows:
ply : this is the player that has triggered the buy function
self : this is the vending machine entity
time : this is the time at which the function was executed
ent : this is the item that will be spawned (will be a nil value if spawning the item is not possible)
item : this is the item table used to spawn the item, includes price, name, etc.
nosound : you have the option to set this in your callback function, setting it to true will disable the vending machine from playing a sound

access VSHARE as if it were a global table, using VSHARE.<var>

VSHARE is cleared after the function is called.

returning false from your callback will disable the default behavior (such as spawning an entity)
and allows you to write your own conditions.

An example of what this can be used for is for example, giving players the ability to purchase perks, interact with other
addons, buy ranks with in-game money, disallow players from buying items if they are not a certain rank, etc.


My server is officially back up! join the group here
Popular Discussions View All (1)
0
7 May, 2023 @ 6:15am
Picking things up with gravity gun
Subnok
55 Comments
salter 29 Aug, 2021 @ 10:15am 
when i press buy, nothing happens, and i get this error

buying item 1 in category 1

[VendR - Customizable Vending Machines] lua/entities/ser_vender/init.lua:154: attempt to index a nil value
1. CreateWeapon - lua/entities/ser_vender/init.lua:154
2. func - lua/entities/ser_vender/init.lua:120
3. unknown - lua/includes/extensions/net.lua:32
Xirtlem 27 May, 2021 @ 10:03am 
anyone know how to change it to work with things like say, zombie survival money? im not at all a coder but would love to know what i do if possible.
Dave_Sherk 25 Jan, 2021 @ 12:35pm 
How to configure what type of value it takes? I'm using Sandbox Money mod type
Bob 25 Aug, 2019 @ 3:00pm 
when i press buy it takes my money
urethrat 23 Aug, 2019 @ 8:25am 
can you make this for a none dedicated (think thats the right word)
officereso 24 Jun, 2019 @ 4:34pm 
how do i make the entities produces by the machine able to be picked up by the gravity gun.
hyperjll 30 Mar, 2019 @ 7:30pm 
Please make a version for sandbox, this looks really fun. :(
Puw 27 Dec, 2018 @ 7:09am 
*played Borderlands 2 for more than 800 Hours* Hmm, Seems Familiar
Nihil 3 Sep, 2018 @ 10:00am 
Does This Addon Work's For The Sandbox Gamemode?
Sadist 29 May, 2018 @ 10:31am 
Please, make support PointShop (for use on SandBox) :)))