2026-03-05 00:00:34 -08:00
|
|
|
if not Config.Drugs['whippit'] then return end
|
2025-10-11 23:18:48 -07:00
|
|
|
|
|
|
|
|
RegisterServerEvent('md-drugs:server:buyWhippitItem', function(loc, item,amount)
|
|
|
|
|
local src = source
|
2026-01-23 03:41:19 -07:00
|
|
|
|
|
|
|
|
if timeOut(src, 'md-drugs:server:buyWhippitItem') then return end
|
|
|
|
|
|
2026-01-31 02:05:15 -07:00
|
|
|
if not checkDistance(src, Config.Whippit.Locations.Whippit[loc].loc, 3.0, 'md-drugs:server:buyWhippitItem') then
|
2026-01-23 03:41:19 -07:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2026-01-31 02:05:15 -07:00
|
|
|
if not Config.Whippit.Recipes.shop[item] then
|
2026-01-23 03:41:19 -07:00
|
|
|
Bridge.Prints.Warn(Bridge.Language.Locale('Whippit.invalidItemWarn', Bridge.Framework.GetPlayerIdentifier(src), item))
|
|
|
|
|
return
|
|
|
|
|
end
|
2026-01-31 02:05:15 -07:00
|
|
|
local price = Config.Whippit.Recipes.shop[item] * amount
|
2026-01-19 00:38:01 -07:00
|
|
|
if not Bridge.Framework.RemoveAccountBalance(src, 'cash', price, 'whippit-shop') then
|
2026-01-16 02:57:26 -07:00
|
|
|
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Whippit.notEnoughMoney', price), 'error')
|
2025-10-11 23:18:48 -07:00
|
|
|
end
|
2026-01-19 00:38:01 -07:00
|
|
|
Bridge.Inventory.AddItem(src, item, amount)
|
2025-10-11 23:18:48 -07:00
|
|
|
end)
|
2025-10-11 18:38:24 -06:00
|
|
|
|
2026-01-19 00:38:01 -07:00
|
|
|
Bridge.Framework.RegisterUsableItem('cracker', function(source)
|
2025-10-11 18:38:24 -06:00
|
|
|
local src = source
|
2026-01-19 00:38:01 -07:00
|
|
|
if not Bridge.Inventory.HasItem(src, 'cracker', 1) then return end
|
|
|
|
|
if not Bridge.Inventory.HasItem(src, 'whipped_cream_cannister', 1) then return end
|
2025-10-11 23:18:48 -07:00
|
|
|
local balloonItem, balloonColor = nil, nil
|
2026-01-31 02:05:15 -07:00
|
|
|
for _, balloon in pairs(Config.Whippit.Recipes.cracker) do
|
2026-01-19 00:38:01 -07:00
|
|
|
if Bridge.Inventory.HasItem(src, balloon.item, 1) then
|
2025-10-11 23:18:48 -07:00
|
|
|
balloonItem = balloon.item
|
|
|
|
|
balloonColor = 'ate_balloon_' .. balloon.color
|
2025-10-11 18:38:24 -06:00
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-10-11 23:18:48 -07:00
|
|
|
if not balloonItem then
|
2026-01-16 02:57:26 -07:00
|
|
|
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Whippit.needBalloon'), 'error')
|
2025-10-11 18:38:24 -06:00
|
|
|
end
|
|
|
|
|
|
2026-01-19 00:38:01 -07:00
|
|
|
if not Bridge.Inventory.RemoveItem(src, 'whipped_cream_cannister', 1) then
|
2026-01-16 02:57:26 -07:00
|
|
|
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Whippit.needCanister'), 'error')
|
2025-10-11 18:38:24 -06:00
|
|
|
end
|
2026-01-19 00:38:01 -07:00
|
|
|
if not Bridge.Inventory.RemoveItem(src, balloonItem, 1) then
|
2026-01-19 00:46:49 -07:00
|
|
|
return
|
2025-10-11 18:38:24 -06:00
|
|
|
end
|
2026-01-19 00:38:01 -07:00
|
|
|
Bridge.Callback.Trigger('md-drugs:client:useWhippit', src, balloonColor)
|
2025-10-11 18:38:24 -06:00
|
|
|
end)
|