Giter Site home page Giter Site logo

es-nitrous's Introduction

Nitrous Script for FiveM

Nitrous Script Preview

YouTube Subscribe Discord Tebex Store

Integrate this nitrous script into your FiveM server to enhance your vehicle customization experience. This script uses qb-target and interacts with the nitrous item to allow players to install nitrous on their vehicles dynamically.

Script Overview

This script allows players to approach a vehicle, target the nitrous item, and initiate a progress bar. Once the progress is complete, the vehicle will have nitrous installed, providing an enhanced driving experience.

Code Implementation

Here's the implementation of the nitrous script for your FiveM server:

-- qb-target setup
exports['qb-target']:AddTargetModel('car', {
    options = {
        {
            event = "nitrous:install",
            icon = "fas fa-wrench",
            label = "Install Nitrous",
            item = "nitrous",
        },
    },
    distance = 2.5,
})

-- Register the event for nitrous installation
RegisterNetEvent('nitrous:install')
AddEventHandler('nitrous:install', function(data)
    local playerPed = PlayerPedId()
    local vehicle = GetVehiclePedIsIn(playerPed, false)
    if vehicle and data.item == "nitrous" then
        -- Open the vehicle's hood
        SetVehicleDoorOpen(vehicle, 4, false, false)
        
        -- Focus camera on the engine
        local coords = GetEntityCoords(vehicle)
        local cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", coords.x, coords.y, coords.z + 0.5, 0, 0, 0, 45.0, false, 0)
        PointCamAtEntity(cam, vehicle, 0, 0, 0, true)
        RenderScriptCams(true, false, 0, true, true)

        -- Show progress bar
        exports['progressbar']:Progress({
            name = "installing_nitrous",
            duration = 10000,
            label = "Installing Nitrous...",
            useWhileDead = false,
            canCancel = false,
            controlDisables = {
                disableMovement = true,
                disableCarMovement = true,
                disableMouse = false,
                disableCombat = true,
            },
            animation = {
                animDict = "mini@repair",
                anim = "fixing_a_player",
                flags = 49,
            },
        }, function(status)
            if not status then
                -- Close the hood and reset camera
                SetVehicleDoorShut(vehicle, 4, false)
                RenderScriptCams(false, false, 0, true, true)
                DestroyCam(cam, false)

                -- Install nitrous
                TriggerServerEvent('nitrous:installOnServer', GetVehicleNumberPlateText(vehicle))
                TriggerEvent('chat:addMessage', {
                    color = {255, 0, 0},
                    multiline = true,
                    args = {"System", "Nitrous installed successfully!"}
                })
            end
        end)
    end
end)

-- Server-side event to handle nitrous installation
RegisterNetEvent('nitrous:installOnServer')
AddEventHandler('nitrous:installOnServer', function(plate)
    local src = source
    local xPlayer = QBCore.Functions.GetPlayer(src)
    local vehicle = GetVehicleByPlate(plate)
    
    -- Ensure the vehicle exists and the player has nitrous item
    if vehicle and xPlayer.Functions.GetItemByName('nitrous') then
        -- Add nitrous to the vehicle's metadata
        MySQL.Async.execute('UPDATE owned_vehicles SET nitrous = 1 WHERE plate = @plate', {
            ['@plate'] = plate
        })
        
        -- Remove nitrous item from player inventory
        xPlayer.Functions.RemoveItem('nitrous', 1)
        TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items['nitrous'], "remove")
    end
end)

es-nitrous's People

Contributors

raiderss avatar

Stargazers

 avatar  avatar

Watchers

 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.