Code Monkey home page Code Monkey logo

qb-explosivevest's Introduction

Explosive vests with huge blast radius and a deadman switch made for the QBCore framework

there alot of checks within the script to ensure that the vests can not be exploited/abused.
all the sounds of the vest are played within distance of the player so anyone nearby will be able
to hear the vest beeping and activating

Requirements

qb-core

qb-smallresources/consumables

interact-sounds

Keys to activate the vest

G activates the vest

= toggles the deadmanswitch

add to qb-smallresources/client/consumables around line 500

RegisterNetEvent('consumables:client:RemoveVest', function()
    local ped = PlayerPedId()
    if Vest == true then
        loadAnimDict("clothingtie")
        TaskPlayAnim(ped, 'clothingtie', 'try_tie_negative_a' , 3.0, 3.0, -1, 0, 32, false, false, false)
        QBCore.Functions.Progressbar("remove_armor", "Removing the explosive vest", 8500, false, true, {
            disableMovement = true,
            disableCarMovement = false,
            disableMouse = false,
            disableCombat = true,
        }, {}, {}, {}, function() -- Done
            SetPedComponentVariation(ped, 9, 0, 0, 2)
            TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items["explosivevest"], "add")
            TriggerServerEvent("QBCore:Server:AddItem", "explosivevest", 1)
            TriggerEvent('qb-explosivevest:client:remove')
            TriggerEvent('consumables:client:detonated')
            QBCore.Functions.Notify("You Have Removed You're explosive Vest","success")
        end)
    else
        QBCore.Functions.Notify("You're not wearing a vest", "error")
    end
end)
RegisterNetEvent('consumables:client:UseExplosiveVest', function()
    if Vest == true then QBCore.Functions.Notify('You already have an explosive vest on', 'error') return end
    local ped = PlayerPedId()
    local PlayerData = QBCore.Functions.GetPlayerData()
    loadAnimDict("clothingtie")
    TaskPlayAnim(ped, 'clothingtie', 'try_tie_negative_a' , 3.0, 3.0, -1, 0, 32, false, false, false)
    QBCore.Functions.Progressbar("use_heavyarmor", "Putting on an explosive vest", 8500, false, true, {
        disableMovement = true,
        disableCarMovement = false,
		disableMouse = false,
		disableCombat = true,
    }, {}, {}, {}, function() -- Done
        if PlayerData.charinfo.gender == 0 then
            currentVest = GetPedDrawableVariation(ped, 9)
            currentVestTexture = GetPedTextureVariation(ped, 9)
            SetPedComponentVariation(ped, 9, 14, 0, 1)
        else
            currentVest = GetPedDrawableVariation(ped, 30)
            currentVestTexture = GetPedTextureVariation(ped, 30)
            SetPedComponentVariation(ped, 9, 16, 0, 1)
        end
        TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items["explosivevest"], "remove")
        TriggerServerEvent("QBCore:Server:RemoveItem", "explosivevest", 1)
        TriggerEvent('qb-explosivevest:client:equip')
        TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3, "beep-sound-1", 0.50)
        Vest = true
        QBCore.Functions.Notify("You Have Equiped An Explosive Vest","success")
    end)
end)
RegisterNetEvent('consumables:client:detonated', function()
    Vest = false
end)

add to qb-smallresources/server/consumables around line 130

QBCore.Functions.CreateUseableItem("explosivevest", function(source, item)
    local src = source
    TriggerClientEvent("consumables:client:UseExplosiveVest", src)
end)

QBCore.Commands.Add("removevest", "Removes Vest", {}, false, function(source, args)
    local src = source
	TriggerClientEvent('consumables:client:RemoveVest', src)
end)

Add to qb-core/shared/items

['explosivevest'] 		 		 = {['name'] = 'explosivevest', 					['label'] = 'Explosive Vest', 			['weight'] = 5000, 	    ['type'] = 'item', 		['image'] = 'vest.png', 				['unique'] = true, 		['useable'] = true, 	['shouldClose'] = true,	   ['combinable'] = nil,   ['description'] = 'Definitely just a normal vest'}

Replace in qb-core/shared/items

['heavyarmor'] 		 			 = {['name'] = 'heavyarmor', 					['label'] = 'Heavy Armor', 				['weight'] = 5000, 	    ['type'] = 'item', 		['image'] = 'armor.png', 				['unique'] = false, 	['useable'] = true, 	['shouldClose'] = true,	   ['combinable'] = {accept = {'weapon_stickybomb'}, reward = 'explosivevest', anim = {['dict'] = 'anim@amb@business@weed@weed_inspecting_high_dry@', ['lib'] = 'weed_inspecting_high_base_inspector', ['text'] = 'Crafting Explosive Vest', ['timeOut'] = 7500,}}, ['description'] = 'Some protection won\'t hurt... right?'},

Add the vest.png to inventory photos

Add the sounds to interact-sounds/client/Html

Preview

Preview

qb-explosivevest's People

Contributors

omega248 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.