Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: now you can add infinite amount of items and quantities #1

Merged
merged 1 commit into from Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions config.lua
Expand Up @@ -12,11 +12,20 @@ Config.Cooldown = 10000 -- in milliseconds

Config.Chance = 5 -- 1-10, 10 being 100% chance of cops being called

Config.Reward1 = "water_bottle" -- Change this to whatever item you want to give out (item name)

Config.Reward2 = "sandwich" -- Change this to whatever item you want to give out (item name)

Config.Reward3 = "ligther" -- Change this to whatever item you want to give out (item name)
Config.Rewards = {
{
item = 'water_bottle',
amount = 1
},
{
item = 'sandwich',
amount = 1
},
{
item = 'ligther',
amount = 1
}
}

Config.CooldownText = "Empty : (" -- Change this to whatever you want the notification to say when the player attempts to steal another mailbox before the cooldown is up

Expand Down
14 changes: 3 additions & 11 deletions server.lua
Expand Up @@ -3,15 +3,7 @@ RegisterServerEvent("jz-mail:giveitem")
AddEventHandler("jz-mail:giveitem", function()
local src = source
local player = QBCore.Functions.GetPlayer(src)
local rand3 = math.random(1,3)
if rand3 == 1 then
player.Functions.AddItem(Config.Reward1, 1)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[Config.Reward1], 'add')
elseif rand3 == 2 then
player.Functions.AddItem(Config.Reward2, 1)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[Config.Reward2], 'add')
else
player.Functions.AddItem(Config.Reward3, 1)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[Config.Reward3], 'add')
end
local index = math.random(1, #Config.Rewards)
player.Functions.AddItem(Config.Rewards[index].item, Config.Rewards[index].amount)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[Config.Rewards[index].item], 'add')
end)