Creating Vendors
Creating new vendors is straight forward. Follow the steps below and you will have as many vendors as you want setup in no time at all.
Step 1. Setting Up Locations
The order of the steps does not really matter but for tutorial sake we will start here.
Open the data
folder followed by the locations.lua
file.
Here you can define new locations within the module:
return {
some_general_store = {
type = "general",
label = "Some General Store",
coords = vector4(-306.99, -971.24, 31.08, 159.15),
payment_types = { "balance", "item" },
can_access = function()
return true
end,
}
}
Options
key - A unique key ID to represent the store.
type - A type for the store, this is important, it connects with your items.
label - A readable label for UI display.
coords - Coordinates to spawn the store ped and display blip if enabled, this is also used for server side validation.
payment_type - The types of payment the vendor will accept.
balance - Any balance type for frameworks; "cash", "crypto", "bank", etc.
item - Any item registered in your server, trade bread for pistols if you really want.
can_access - Function used for adding custom restrictions to open the vendor.
Restricting Vendor Access
You can restrict access to a vendor by utilising the can_access
function.
Here is a quick example of restricting a vendor so players cannot access it from within a vehicle.
can_access = function()
return not IsPedInAnyVehicle(PlayerPedId())
end
Step 2. Setting Up Peds
Once you have setup a location and decided what type
you are using for your vendors, open the peds.lua
file and create an entry for your new vendor type:
return {
general = {
model = "mp_m_shopkeep_01",
scenario = "WORLD_HUMAN_AA_COFFEE",
networked = false
}
}
Options
key - The connects to your vendor type created in Step 1.
model - The ped model to spawn.
scenario - The world scenario to run on the ped.
networked - Network flag for ped spawning
Step 3. Setting Up Blips
The next step is setting up your blip for the vendor:
return {
general = {
label = "General Store",
sprite = 52,
colour = 0,
scale = 0.6,
enabled = true
}
}
Options
key - The connects to your vendor type created in Step 1.
label - A readable label for UI display.
sprite - ID of sprite to use.
colour - Colour for sprite.
scale - The scale of blip on the map.
enabled - If false blip will not be added to locations.
Step 4. Setting Up Items
Now the main sauce of the script. You can set any items you want, define whatever prices you want, using any money type or other item you want.
You can build up your items list like so:
return {
test_item = {
label = "Test Item",
image = "test_item.png",
description = "This is just an example test item.",
locations = { "general", "medical" },
categories = { "test", "food" },
stock = 500,
prices = {
cash = { type = "balance", value = 5 },
bank = { type = "balance", value = 10 },
crypto = { type = "balance", value = 2 },
bread = { type = "item", value = 5 },
water = { type = "item", value = 5 }
}
}
}
Options
key - Unique identifier for the item.
label - A readable label for UI display.
description - A readable description for the item.
locations - The vendor types the item can be shown in, e.g. this item could be purchased from "general" or "medical" vendors.
categories - Categories to place the item in, any unique categories will generate the UI page tabs.
stock - The amount of stock the item has this is refreshed every 5 minutes by 25% on default settings.
prices - The prices the item can be purchased for
key - Unique item or balance for your server
type - The money type players can purchase for
balance - Any framework balance type; "cash", "crypto", "bank" etc.
item - Any registered item in your server.
value - The price of the item
Thats it now your good to go!
Summary
Create a new location in
locations.lua
Setup blips and peds for the vendor type in
blips.lua
andpeds.lua
Define your items within
items.lua
Restart and go.
Last updated