Skip to content

Commit

Permalink
Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
FBFezz authored Jun 22, 2021
0 parents commit 15cab2e
Show file tree
Hide file tree
Showing 16 changed files with 602 additions and 0 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (C) 2021 Sub-Zero Interactive

All rights reserved.

Permission is hereby granted, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software with 'All rights reserved'. Even if 'All rights reserved' is very clear :

You shall not sell and/or resell this software
The rights to use, copy, modify and merge
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# szi_vendingrobbery
This is a script that allows you to buy Soda's & rob vending machines using fivem-target.

## Requirements
- [es_extended](https://github.com/esx-framework/es_extended/tree/legacy)
- [mhacking](https://github.com/GHMatti/FiveM-Scripts/tree/master/mhacking)
- [fivem-target](https://github.com/meta-hub/fivem-target) OR [bt-target](https://github.com/brentN5/bt-target)
- [mythic_progbar](https://github.com/HalCroves/mythic_progbar)
- [mythic_notify](https://github.com/JayMontana36/mythic_notify)

## Download & Installation

### Using Git
```
cd resources
git clone https://github.com/Sub-Zero-Interactive/szi_vendingrobbery [szi]/szi_vendingrobbery
```

### Manually
- Download https://github.com/Sub-Zero-Interactive/szi_vendingrobbery
- Put it in the `[szi]` directory


## Installation
- Import `szi_vendingrobbery.sql` in your database
- Add this in your server.cfg :

```
ensure szi_vendingrobbery
```

# Legal
### License
szi_vendingrobbery - This is a script that allows you to rob vending machines using fivem-target.

Copyright (C) 2021 Sub-Zero Interactive

All rights reserved.

Permission is hereby granted, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software with 'All rights reserved'. Even if 'All rights reserved' is very clear :

You shall not sell and/or resell this software
The rights to use, copy, modify and merge
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
216 changes: 216 additions & 0 deletions client/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
local hasStarted, startedRobbing, cancontinue = false, false, false
local CurrentCoords, started = nil, nil
local taken = 0

Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(100)
end
end)

AddEventHandler('onClientResourceStart', function (resourceName)
if (GetCurrentResourceName() ~= resourceName) then return end
for k,v in pairs(Config.VendingMachineModels) do
if Config.FivemTarget then
exports['fivem-target']:AddTargetModel({
name = 'robbery',
label = 'Vending Machine',
icon = 'fas fa-mug-hot',
model = GetHashKey(v.prop),
interactDist = 2.0,
onInteract = StartRobbing,
options = {
{
name = 'rob',
label = 'Rob Vending Machine'
},
{
name = 'buy',
label = 'Buy Soda'
}
},
vars = {}
})
else
local machines = {}
for k,v in pairs(Config.VendingMachineModels) do
table.insert(machines,GetHashKey(v.prop))
end
Wait(5)
exports['bt-target']:AddTargetModel(machines, {
options = {
{
event = 'szi_vendingmachine:startRobbing',
icon = 'fas fa-mug-hot',
label = 'Rob Vending Machine',
},
{
event = 'szi_vendingmachine:buy',
icon = 'fas fa-mug-hot',
label = 'Buy Soda',
}
},
job = {'all'},
distance = 1.5
})
end
end
end)

function OpenVendingMenu()
ESX.UI.Menu.CloseAll()

local elements = {}
for k, v in pairs(Config.Rewards) do
table.insert(elements, {label = ('%s - <span style="color:green;">%s</span>'):format(v.name, ESX.Math.GroupDigits(v.price)), item = v.name, price = v.price, type = 'slider', value = 1, min = 1, max = 100})
end

ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vending', {
title = 'Vending Machine',
align = 'bottom-right',
elements = elements
}, function(data, menu)
TriggerServerEvent('szi_vendingmachine:buyItem', data.current.item, data.current.price, data.current.value)
TaskPlayAnim(PlayerPedId(),Config.VendingDict,Config.VendingAnim,1.0,1.0,-1,1,0,false,false,false)
Wait(5000)
ClearPedTasks(PlayerPedId())
end, function(data, menu)
menu.close()
end)
end

function FinishRobbings(success)
TriggerServerEvent('szi_vendingmachine:robSuccess', success)
FinishRobbing(success)
Cooldown(true)
end

function FinishRobbing(success)
TriggerEvent('mhacking:hide')
if success and taken < Config.MaxTake then
ClearPedTasks(PlayerPedId())
RequestAnimDict(Config.VendingDict)
while not HasAnimDictLoaded(Config.VendingDict) do
Wait(10)
end
TaskPlayAnim(PlayerPedId(),Config.VendingDict,Config.VendingAnim,1.0,1.0,-1,1,0,false,false,false)
cancontinue = true
ESX.ShowHelpNotification(_U('press_stop'))
exports['mythic_progbar']:Progress({
name = 'using',
duration = Config.RobTime * 1000,
label = 'Robbing Vending Machine',
useWhileDead = false,
canCancel = true,
controlDisables = {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}
}, function(cancelled)
if not cancelled then
TriggerServerEvent('szi_vendingmachine:success')
taken = taken + 1
FinishRobbing(true)
else
ClearPedTasks(PlayerPedId())
cancontinue = false
taken = 0
Cooldown(true)
end
end)
else
if not (taken < Config.MaxTake) then
ESX.ShowHelpNotification(_U('max_amount'))
end
ClearPedTasks(PlayerPedId())
cancontinue = false
taken = 0
Cooldown(true)
end
end

function StartRobbing(targetName, optionName, vars, entityHit)
if optionName and optionName == 'rob' then
if not startedRobbing then
startedRobbing = true
ESX.TriggerServerCallback('szi_vendingmachine:canRob', function(CanRob)
if CanRob then
local chance = math.random(Config.MinChance, Config.MaxChance)
local pos = GetEntityCoords(PlayerPedId(), true)
local s1, s2 = GetStreetNameAtCoord( pos.x, pos.y, pos.z, Citizen.PointerValueInt(), Citizen.PointerValueInt() )
local street1 = GetStreetNameFromHashKey(s1)
local street2 = GetStreetNameFromHashKey(s2)
ClearPedTasks(PlayerPedId())
RequestAnimDict(Config.RobbingDict)
while not HasAnimDictLoaded(Config.RobbingDict) do
Wait(1)
end
TaskPlayAnim(PlayerPedId(),Config.RobbingDict,Config.RobbingAnim ,8.0,8.0,-1,1,0,false,false,false)
TriggerEvent('mhacking:show')
TriggerEvent('mhacking:start',5,30,FinishRobbings)
if chance <= Config.Chance then
TriggerServerEvent('szi_vendingmachine:notifyPolice', street1, street2, pos)
end
else
ESX.ShowHelpNotification(_U('cant_rob'), false, true, 2000)
Wait(2000)
hasStarted = false
startedRobbing = false
end
end)
end
else
OpenVendingMenu()
end
end

RegisterNetEvent('szi_vendingmachine:startRobbing')
AddEventHandler('szi_vendingmachine:startRobbing', function()
StartRobbing(nil, 'rob')
end)

RegisterNetEvent('szi_vendingmachine:buy')
AddEventHandler('szi_vendingmachine:buy', function()
OpenVendingMenu()
end)

RegisterNetEvent('szi_vendingmachine:notifyPolice')
AddEventHandler('szi_vendingmachine:notifyPolice', function(msg)
exports['mythic_notify']:DoHudText('error', msg)
end)

RegisterNetEvent('szi_vendingmachine:blip')
AddEventHandler('szi_vendingmachine:blip', function(x,y,z)
Blip = AddBlipForCoord(x,y,z)
SetBlipSprite(Blip, 587)
SetBlipColour(Blip, 1)
SetBlipAlpha(Blip, 250)
SetBlipDisplay(Blip, 4)
SetBlipScale(Blip, 1.2)
SetBlipFlashes(Blip, true)
SetBlipAsShortRange(Blip, true)
BeginTextCommandSetBlipName('STRING')
AddTextComponentString('Robbery In Progress | Vending Machine')
EndTextCommandSetBlipName(Blip)
Wait(Config.BlipTimer * 1000)
RemoveBlip(Blip)
end)

function Cooldown(hasStarted)
local timer = Config.CooldownTime
while hasStarted == true do
Citizen.Wait(1000)
if timer > 0 then
timer = timer -1
end

if timer == 1 then
hasStarted = false
startedRobbing = false
break
end
end
end
81 changes: 81 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Config = {}

Config.Locale = 'en'

Config.RequiredItems = {
{
name = 'lockpick', -- Item required to rob the vending machines
quantity = 1
}
}


Config.RemoveItems = {
-- {
-- name = 'lockpick' -- Uncomment these 3 lines to remove the item after robbing the vending machine
-- }--,
}

Config.Rewards = {
{
name = 'soda', -- Choices are money, bank, black_money or an item name
amount = math.random(1, 10), -- The random amount you take per cycle (MaxTake is how many times it cycles max)
price = 5,
}
}

Config.VendingMachineModels = {
{
prop = 'prop_vend_coffe_01'
},
{
prop = 'prop_vend_condom_01'
},
{
prop = 'prop_vend_fags_01'
},
{
prop = 'prop_vend_fridge01'
},
{
prop = 'prop_vend_snak_01'
},
{
prop = 'prop_vend_soda_02'
},
{
prop = 'prop_vend_water_01'
},
{
prop = 'prop_vend_snak_01_tu'
},
{
prop = 'v_68_broeknvend'
},
{
prop = 'prop_vend_soda_01'
},
{
prop = 'ch_chint10_vending_smallroom_01'
}
}

Config.FivemTarget = true -- set to 'true' if you are using fivem-target or 'false' for bt-target

Config.PoliceRequired = 1 -- Amount of Police required to rob a vending machine
Config.CooldownTime = 300 -- Cooldown in Seconds before someone can rob a vending machine

Config.MaxChance = 100 -- Max number the chance can go up to (default 100)
Config.Chance = 15 -- The % Chance of notifying police when a robbery is started (25 = 25%)
Config.MinChance = 1 -- Minimum number the chance can be (Keep at 1 unless you know what you are doing)

Config.BlipTimer = 45 -- Blip timer until removed in seconds

Config.MaxTake = 3 -- The amount of times the "Cycle" can happen (links with reward ammount)
Config.RobTime = 10 -- How long it takes to rob the vending machine per cycle in seconds

Config.RobbingDict = 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@'
Config.RobbingAnim = 'machinic_loop_mechandplayer'

Config.VendingDict = 'amb@medic@standing@kneel@base'
Config.VendingAnim = 'base'
Loading

0 comments on commit 15cab2e

Please sign in to comment.