A simple prescription resource for QBCore, created using React

Prescription Medication Script for FiveM QBCore

Description

A simple prescription resource for QBCore, created using React. It allows players to fill out prescriptions, and give them to other players. With the prescription, players can go to the pharmacy and interact with the spawned in ped to retrieve their medications.

Prescription UIPed Interaction


Key Features

  • Prescription form with drop down menu of available medications found in the config
  • Prescriptions expire based on time set in config
  • Pharmacy will only give medications if the name on prescription matches player name
  • Ability to prescribe specific dosages of medication
  • Each use of a medication will reduce items metadata by one dose and remove item when no doses remain
  • Using a the prescription will display a read only version of the UI

Installation

  • Download latest release at https://github.com/christikat/glow_prescription/releases
  • Open the ZIP and move glow_prescription into your resource folder and ensure glow_prescription in server.cfg
  • Add prescriptionpadprescription, and all medications in your config to qbcore/shared/items.lua
    ['prescriptionpad'] 			 = {['name'] = 'prescriptionpad', 				['label'] = 'Prescription Pad', 		['weight'] = 1000, 		['type'] = 'item', 		['image'] = 'prescriptionpad.png', 		['unique'] = false, 	['useable'] = true, 	['shouldClose'] = true,	   ['combinable'] = nil,   ['description'] = 'Used to prescribe drugs'},
	['prescription'] 				 = {['name'] = 'prescription', 					['label'] = 'Prescription', 			['weight'] = 500, 		['type'] = 'item', 		['image'] = 'prescription.png', 		['unique'] = true, 		['useable'] = true, 	['shouldClose'] = true,	   ['combinable'] = nil,   ['description'] = 'A prescription for legal drugs'},
	['amoxicillin'] 				 = {['name'] = 'amoxicillin', 					['label'] = 'Amoxicillin', 				['weight'] = 500, 		['type'] = 'item', 		['image'] = 'amoxicillin.png', 			['unique'] = true, 		['useable'] = true, 	['shouldClose'] = true,	   ['combinable'] = nil,   ['description'] = 'A prescribed antibiotic'},
  • Items passed in Config.medList will be usable by default with code below, found in server.lua. This can be edited to add custom effects for specific medications
for i=1, #Config.medList do
    QBCore.Functions.CreateUseableItem(Config.medList[i].item, function(source, item)
        local Player = QBCore.Functions.GetPlayer(source)
        if not Player.Functions.GetItemBySlot(item.slot) or not item.info.dosage then return end
        local playerInventory = QBCore.Functions.GetPlayer(source).PlayerData.items

        if item.info.dosage <= 1 then
            Player.Functions.RemoveItem(Config.medList[i].item, 1, item.slot)
            TriggerClientEvent("QBCore:Notify", source, "You take the last dose of your medication", "success")
        else
            local newDosage = item.info.dosage - 1
            playerInventory[item.slot].info.dosage = newDosage 
            Player.Functions.SetInventory(playerInventory)
            TriggerClientEvent("QBCore:Notify", source, "You take your medication and have " .. newDosage .. " dose(s) left", "success")
        end

        -- Edit here to add custom med effect
        -- if Config.medList[i].item == "specialMed" then
        --     TriggerClientEvent("customEventName", source)
        -- end
    end)
end

GitHub

View Github

Related Posts

Recent Posts

ഇടുക്കിയിലെ മലയോര മേഖലകളിൽ രാത്രിയാത്ര നിരോധിച്ചു. രാത്രി ഏഴു മുതൽ രാവിലെ ആറു വരെയാണ് നിരോധനം

ഏന്തയാർ ഈസ്റ്റിൽ പ്രളയത്തിൽ തകർന്ന പാലത്തിന് പകരം പുതിയ പാലം നിർമ്മിക്കുവാൻ താത്ക്കാലിക പാലം പൊളിച്ച് നീക്കി

Explore the Investment Opportunities: A Comprehensive Guide to Different Types of Mutual Funds

Title: Understanding Mutual Funds: A Beginner's Guide to Investing

തീവ്രമഴ മുന്നറിയിപ്പിന്റെ പശ്ചാതലത്തിൽ സംസ്ഥാനം ജാഗ്രതയിൽ

250,000 അപേക്ഷകൾ വർദ്ധിച്ചതിനാൽ ട്രാൻസ്‌പോർട്ട് കമ്മീഷണർ പരിശോധന പുനരാരംഭിക്കും

ഏലക്കയിൽ കീടനാശിനി സാന്നിധ്യം; ആറര ലക്ഷത്തിലധികം ടിൻ അരവണ നശിപ്പിക്കാൻ ടെൻഡർ ക്ഷണിച്ച് ദേവസ്വം ബോർഡ്‌

ഭീമൻ പാറക്കഷണങ്ങൾ അടർന്ന് ദേശീയ പാതയിലേക്ക് വീഴുന്നത് പതിവാകുന്നു. കുട്ടിക്കാനത്തിനും മുണ്ടക്കയത്തിനുമിടയിൽ നിലനിൽക്കുന്നത് വൻ അപകട ഭീഷണി

ചക്രവാതച്ചുഴി:അതിശക്തമായ മഴ വരുന്നു

പ്ലസ് വൺ പ്രവേശനം. അക്ഷയയിൽ തിക്കി തിരക്കേണ്ട, നെറ്റിവിറ്റി/ജാതി തെളിയിക്കാൻ പത്താംതരം സർട്ടിഫിക്കറ്റ് മതി