Contents

Custom shipment fields

You can create custom shipments in DarkRP. However, there are many things to fiddle with. This page explains every single "field".

Example with all fields

Here's an example with all available fields filled in:

DarkRP.createShipment("Example shipment", {
model = "models/weapons/w_pist_fiveseven.mdl", -- The model of the item that hovers above the shipment
entity = "weapon_fiveseven2", -- the entity that comes out of the shipment
price = 100, -- the price of one shipment
amount = 10, -- how many of the item go in one purchased shipment
separate = true, -- whether the item is sold separately (usually used for guns)
pricesep = 100, -- the price of a separately sold item
noship = false, -- whether this item has a shipment
allowed = {TEAM_GUN, TEAM_MEDIC}, -- OPTIONAL, which teams are allowed to buy this shipment/separate gun
shipmodel = "models/items/item_item_crate.mdl", -- OPTIONAL, the model of the shipment (this crate is the default)
customCheck = function(ply) return ply:Frags() < 10 end, -- OPTIONAL, extra conditions before people can purchase the shipment or separate item
CustomCheckFailMsg = function(ply, shipment) return ply:Frags() >= 10 and "You killed too many people" end, -- Can be a simple string as well
weight = 15, -- OPTIONAL, the weight of the shipment. The default is the weight of the shipment
spareammo = 10, -- OPTIONAL, Add ammo to the default amount of ammo for every weapon
clip1 = 10, -- OPTIONAL, The amount of bullets in the primary clip by default
clip2 = 10, -- OPTIONAL, The amount of bullets in the secondary clip by default
buttonColor = Color(255, 255, 255, 255), -- Optional: The color of the button in the F4 menu,
label = "Super pistol", -- Optional: the text on the button in the F4 menu
-- Advanced, optional
shipmentClass = "spawned_shipment", -- The classname of the shipment entity. Use this if you have made a different shipment entity
onBought = function(ply, shipment, ent) end, -- function that is called when the shipment is bought
getPrice = function(ply, price) return ply:GetNWString("usergroup") == "donator" and price * 0.9 or price end, -- function to decide what the price is based on the player
})

Notes

If you set shipmentClass to something other than the default, make sure the shipment entity has implemented the function SetContents(ShipmentID, Count).