DarkRP:CustomShipmentFields
Jump to navigation
Jump to search
Custom shipment fields[edit]
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[edit]
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
-- The following fields are OPTIONAL. If you do not need them, or do not need to change them from their defaults, REMOVE them.
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, if you want it different than the name above
category = "Other", -- The name of the category it is in. Note: the category must be created!
sortOrder = 100, -- The position of this thing in its category. Lower number means higher up.
-- 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
spawn = function(shipment_ent, shipment_data) print("Spawn custom entity and place it") end, -- Function to override how the shipment spawns the weapon when used.
})
Notes[edit]
If you set shipmentClass to something other than the default, make sure the shipment entity has implemented the function SetContents(ShipmentID, Count).
The specified category must have its categorises field set to "shipments". If its categorises field is set to "weapons", you will get an error looking like The category of "TMP" ("SMGs") does not exist!