Item Use Effect API
The dream_vending
script uses a centralized system (DreamCore.Items
) to define how items affect the player when used. This API enables you to easily assign effects to items such as healing, animations, or visual effects like drunkenness.
๐ง Usageโ
To make an item usable with effects, define it in the DreamCore.Items
table with a use
function:
DreamCore.Items = {
['mocha'] = { -- This is the item name as defined in your items system (e.g., mocha, water, burger)
use = function(playerId)
TriggerClientEvent('dream_vending:client:ApplyItemEffects', playerId, {
-- Effects are passed as a list (array) of tables.
{ type = 'addArmor', amount = 2 }, -- Player will first get 2 armor
{ type = 'drinkAnim', prop = 'ng_proc_coffee_01a' } -- After the armor he drink
})
end
},
-- Add more items ;)
}
๐ก Note: If another script manages the item, simply donโt include it in
DreamCore.Items
.
โ๏ธ Supported Effect Typesโ
Below is a list of supported type
values for the dream_vending:client:ApplyItemEffects
event:
๐ฉบ addHealโ
Increases the player's health.
{ type = 'addHeal', amount = 10 }
๐ removeHealโ
Reduces the player's health.
{ type = 'removeHeal', amount = 10 }
๐ก๏ธ addArmorโ
Increases the player's armor.
{ type = 'addArmor', amount = 10 }
๐ฅ removeArmorโ
Reduces the player's armor.
{ type = 'removeArmor', amount = 10 }
๐ eatAnimโ
Plays an eating animation. Optionally set a prop.
{ type = 'eatAnim', prop = 'prop_cs_burger_01' }
๐ฅค drinkAnimโ
Plays a drinking animation. Optionally set a prop.
{ type = 'drinkAnim', prop = 'prop_ecola_can' }
๐ป drunkโ
Applies a drunk visual and movement effect.
Optional parameters:
intensity
(float): Camera shake strengthveryDrunk
(boolean): Changes walking style
{ type = 'drunk', intensity = 1.0, veryDrunk = true }
โฑ๏ธ Delayed Effectsโ
You can delay an effect with the timeout
parameter (in milliseconds):
{ type = 'addHeal', amount = 10, timeout = 3000 }
๐ก Tipsโ
- You can stack multiple effects in a single item.
- Try to stay realistic: a whiskey contains more alcohol than just a piรฑa colada.
- Use props that exist in GTA V (e.g.,
prop_ecola_can
,ng_proc_coffee_01a
, etc.). - Want custom effects? Add new
effectType
handling to theApplyItemEffects
event (You need to buy the source version).