fivemeconomydrugscriminalroleplay
Building a Drug Economy in FiveM — Processing, Selling and Turf War
March 22, 2026
2 min read
149 views
Drug Economy ใน FiveM
Drug economy เป็นหนึ่งใน systems ที่สร้าง engagement สูงใน criminal RP เพราะมีทั้ง risk, reward และ social conflict
Economy Chain
Harvest Seeds → Process Raw → Sell to NPC/Player
(Weed Plants) (Weed Lab) (Dealer NPCs)
Config
Config.Drugs = {
weed = {
seed = 'weed_seed',
raw = 'weed_raw',
processed = 'weed',
growTime = 3600, -- 1 ชั่วโมงจริง
harvestAmount = { min = 3, max = 8 },
processTime = 10000,
processAmount = 1, -- raw 2 -> processed 1
processNeeds = 2,
basePrice = 500,
priceVariance = 0.3, -- ±30%
},
meth = {
seed = nil,
raw = 'chemicals',
processed = 'meth',
processTime = 30000,
processAmount = 2,
processNeeds = 5,
basePrice = 2000,
priceVariance = 0.4,
}
}
Config.GrowSpots = {
{ coords = vector3(-1268.0, -1594.0, 4.0), drug = 'weed', label = 'แปลงสวน 1' },
{ coords = vector3(-1279.0, -1610.0, 3.0), drug = 'weed', label = 'แปลงสวน 2' },
}
Config.Labs = {
{ coords = vector3(-1089.7, -1600.2, 4.4), drug = 'meth', label = 'Lab เหนือ' },
{ coords = vector3(1150.0, -1600.0, 35.0), drug = 'weed', label = 'Lab ใต้' },
}
Config.Dealers = {
{ coords = vector3(165.0, -1718.0, 29.0), drug = 'weed', multiplier = 1.0 },
{ coords = vector3(-1589.0, -1078.0, 13.0), drug = 'meth', multiplier = 1.2 },
}
Dynamic Pricing
-- server.lua
local drugPrices = {}
-- คำนวณราคาตาม supply/demand
local salesHistory = {} -- {[drug] = count ใน 1 ชั่วโมงล่าสุด}
local function GetDrugPrice(drug)
local base = Config.Drugs[drug].basePrice
local variance = Config.Drugs[drug].priceVariance
local sales = salesHistory[drug] or 0
-- ยิ่งขายมาก ราคายิ่งตก (supply สูง)
local demandMultiplier = 1.0 - (math.min(sales, 50) / 50 * variance)
-- random noise เล็กน้อย
local noise = (math.random() - 0.5) * 0.1
return math.floor(base * (demandMultiplier + noise))
end
-- Reset sales history ทุก 1 ชั่วโมง
Citizen.CreateThread(function()
while true do
Citizen.Wait(3600000)
salesHistory = {}
-- broadcast ราคาใหม่
TriggerClientEvent('drug:priceUpdate', -1, GetAllPrices())
end
end)
-- Sell
RegisterNetEvent('drug:sell')
AddEventHandler('drug:sell', function(drug, amount)
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
-- ตรวจสอบ item
local item = xPlayer.getInventoryItem(drug)
if item.count < amount then
TriggerClientEvent('M2.Notify:Notify', src, 'error', 'ยาไม่พอ', 3000)
return
end
local price = GetDrugPrice(drug) * amount
xPlayer.removeInventoryItem(drug, amount)
xPlayer.addMoney(price)
-- อัพเดท sales history
salesHistory[drug] = (salesHistory[drug] or 0) + amount
TriggerClientEvent('M2.Notify:Notify', src, 'success',
string.format('ขาย %d %s ได้ $%d', amount, drug, price), 5000)
end)
Growing System
-- server.lua — บันทึก plants ใน DB
local activePlants = {}
RegisterNetEvent('drug:plant')
AddEventHandler('drug:plant', function(spotId)
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
local drug = GetSpotDrug(spotId)
-- ตรวจสอบ seed
local seedItem = Config.Drugs[drug].seed
if not xPlayer.getInventoryItem(seedItem) then return end
xPlayer.removeInventoryItem(seedItem, 1)
local harvestTime = GetGameTimer() + (Config.Drugs[drug].growTime * 1000)
activePlants[spotId] = {
owner = xPlayer.identifier,
drug = drug,
harvestTime = harvestTime
}
-- บันทึก DB
MySQL.insert.await(
'INSERT INTO drug_plants (spot_id, owner, drug, harvest_time) VALUES (?, ?, ?, ?)',
{ spotId, xPlayer.identifier, drug, harvestTime }
)
end)
สรุป
Drug economy ที่ดีต้องมีความสมดุลระหว่าง risk (โดนตำรวจ, turf war) และ reward (กำไร) dynamic pricing ช่วยให้ตลาดไม่ saturate และผู้เล่น diversify พฤติกรรมได้เอง
Related Articles
Breaking: GTA Online อัพเดท "Money Fronts" — FiveM Server Owners ต้องทำอะไร?
Rockstar ปล่อย GTA Online อัพเดท Money Fronts มีผลกระทบต่อ FiveM servers บางส่วน นี่คือสิ่งที่ต้องทำทันทีหลังอัพเดท
Community Spotlight: Script และ Projects ที่น่าสนใจจาก FiveM Community
รวม scripts, tools และ projects ที่โดดเด่นจาก FiveM community ในช่วงที่ผ่านมา ตั้งแต่ free resources ถึง open-source projects
txAdmin อัพเดทใหม่ — Dashboard, Diagnostics และ Ban System ที่ดีขึ้น
txAdmin ซึ่งตอนนี้เป็นส่วนหนึ่งของ Cfx.re อย่างเป็นทางการ ได้รับการอัพเดทครั้งใหญ่ มี features ใหม่ที่ทำให้ Server Management ง่ายขึ้นมาก