Garry's Mod

Garry's Mod

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

Subscribe to download
VendR - Customizable Vending Machines

Subscribed
Unsubscribe
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
< >
53 Comments
Erode Aug 25 @ 3:00pm 
when i press buy it takes my money
can you make this for a none dedicated (think thats the right word)
officereso Jun 24 @ 4:34pm 
how do i make the entities produces by the machine able to be picked up by the gravity gun.
hyperjll Mar 30 @ 7:30pm 
Please make a version for sandbox, this looks really fun. :(
Puw Dec 27, 2018 @ 7:09am 
*played Borderlands 2 for more than 800 Hours* Hmm, Seems Familiar
Ace Sep 3, 2018 @ 10:00am 
Does This Addon Work's For The Sandbox Gamemode?
Sadist May 29, 2018 @ 10:31am 
Please, make support PointShop (for use on SandBox) :)))
|KB| >KEKSQUAD Mar 23, 2018 @ 8:27pm 
[ERROR] lua/entities/ser_vender/shared.lua:366: attempt to index local 'v' (a nil value)
1. CreateValueEditor - lua/entities/ser_vender/shared.lua:366
2. LoadItems - lua/entities/ser_vender/shared.lua:235
3. OnRowSelected - lua/entities/ser_vender/shared.lua:488
4. OnClickLine - lua/vgui/dlistview.lua:422
5. unknown - lua/vgui/dlistview_line.lua:81

Happens whenever I make a new category.
|KB| >KEKSQUAD Mar 23, 2018 @ 7:55pm 
Hey, how would we go about using it with Vrondakis' levelling system? We only want certain items accessible to certain levels and ULX ranks.
misterfantastic609 Jan 25, 2018 @ 7:24am 
How to remove vending machine from the server?