diff --git a/code/datums/supplypacks.dm b/code/datums/supplypacks.dm index a70a81bb285..d22179ad4d9 100644 --- a/code/datums/supplypacks.dm +++ b/code/datums/supplypacks.dm @@ -55,6 +55,10 @@ GLOBAL_LIST_INIT(all_supply_groups, list(SUPPLY_EMERGENCY,SUPPLY_SECURITY,SUPPLY var/list/announce_beacons = list() // Particular beacons that we'll notify the relevant department when we reach var/special = FALSE //Event/Station Goals/Admin enabled packs var/special_enabled = FALSE + /// The number of times one can order a cargo crate, before it becomes restricted. -1 for infinite + var/order_limit = -1 + /// Number of times a crate has been ordered in a shift + var/times_ordered = 0 /// List of names for being done in TGUI var/list/ui_manifest = list() @@ -200,6 +204,7 @@ GLOBAL_LIST_INIT(all_supply_groups, list(SUPPLY_EMERGENCY,SUPPLY_SECURITY,SUPPLY containertype = /obj/structure/closet/crate containername = "crate" hidden = 1 + order_limit = 5 ////////////////////////////////////////////////////////////////////////////// //////////////////////////// Security //////////////////////////////////////// diff --git a/code/modules/shuttle/supply.dm b/code/modules/shuttle/supply.dm index 8a6c5b159a4..bf87fcb685a 100644 --- a/code/modules/shuttle/supply.dm +++ b/code/modules/shuttle/supply.dm @@ -521,6 +521,14 @@ visible_message("[src]'s monitor flashes, \"[world.time - reqtime] seconds remaining until another requisition form may be printed.\"") return + var/datum/supply_packs/P = locateUID(params["crate"]) + if(!istype(P)) + return + + if(P.times_ordered >= P.order_limit && P.order_limit != -1) //If the crate has reached the limit, do not allow it to be ordered. + to_chat(usr, "[P.name] is out of stock, and can no longer be ordered.") + return + var/amount = 1 if(params["multiple"] == "1") // 1 is a string here. DO NOT MAKE THIS A BOOLEAN YOU DORK var/num_input = input(usr, "Amount", "How many crates? (20 Max)") as null|num @@ -528,11 +536,6 @@ return amount = clamp(round(num_input), 1, 20) - - var/datum/supply_packs/P = locateUID(params["crate"]) - if(!istype(P)) - return - var/timeout = world.time + 600 // If you dont type the reason within a minute, theres bigger problems here var/reason = input(usr, "Reason", "Why do you require this item?","") as null|text if(world.time > timeout || !reason || (!is_public && !is_authorized(usr)) || ..()) @@ -573,10 +576,13 @@ if(SO.ordernum == ordernum) O = SO P = O.object - if(SSshuttle.points >= P.cost) + if(P.times_ordered >= P.order_limit && P.order_limit != -1) //If this order would put it over the limit, deny it + to_chat(usr, "[P.name] is out of stock, and can no longer be ordered.") + else if(SSshuttle.points >= P.cost) SSshuttle.requestlist.Cut(i,i+1) SSshuttle.points -= P.cost SSshuttle.shoppinglist += O + P.times_ordered += 1 investigate_log("[key_name(usr)] has authorized an order for [P.name]. Remaining points: [SSshuttle.points].", "cargo") else to_chat(usr, "There are insufficient supply points for this request.")