[Release] VehicleBomb


VehicleBomb
VehicleBomb is a simple bomb script similar to GTA Online’s car bombs, where you can place a bomb on a car and blow it up whenever you want.

  • To place a vehicle bomb, go to any customs shop such as Los Santos Customs, Benny’s, or Beeker’s Garage and do /placecarbomb.

  • To remove a vehicle bomb, go to any customs shop and do /removecarbomb.

  • To detonate a vehicle bomb, do /detonatecarbomb while within a certain radius of the vehicle. The radius can be changed by editing detonateRadius on line 2.

Resmon: 0.01ms

Feel free to provide feedback on the script, this is one of my first scripts and I am still learning LUA so any feedback is appreciated.

Update 1.1: Instead of using GetDistanceBetweenCoords it now subtracts vectors, huge thank you to @JayWoosh for the idea.

Requires
pNotify
Download
GitHub
Video
Video

6 Likes

Great Script. For one of your first scripts, it looks great! Good job.

1 Like

Fun to ruin someone’s day!

1 Like

Great work. Is there a way to make it explode randomly (for example activating the bomb but it doesn’t explode due to malfunction)?

1 Like

It’s definitely possible to make it malfunction, i’ll try doing this tomorrow morning since it’s pretty late for me right now.

1 Like

That’s ESX, this script I believe is Standalone. That script also has a few server sided events, while this is all client sided except the Version checker written in JS.
Looks like another great script though :slight_smile:

2 Likes

Just some feedback, instead of a large elseif tree, you could store the coordinates of the LSCustoms as a table (example:

local LSCustoms = {
    vector3(0,0,0),
    vector3(0,0,0),
}

Then instead of using GetDistanceBetweenCoords, subtract vectors, it’s faster and cleaner.

local nearLSCustoms = false
local plyPos = GetEntityCoords(PlayerPedId())

for k, v in pairs(LSCustoms) do
    if #(plyPos - v) < 15.0 then
        nearLSCustoms = true
    end
end

if nearLSCustoms then
    -- Plant bomb?
else
    -- Not near an LS customs
end

Other than that, some nice usage of a native I wasn’t even aware of, good job for your first script! :slight_smile:

1 Like

Is it possible to edit the requirements from a location to an item, thus allowing it anywhere provided you have the needed item?

1 Like

Thank you! I just updated it to use this and it looks way better.

Here is a version that should have a 10% chance of malfunctioning, if you want to change the chance that it successfully blows up edit chanceOfBlowingUp on line 3.
client.lua (4.3 KB)

1 Like

It’s possible to make it require you to be near an entity, I’ll make a version that has something like this.

1 Like

I think I see what you mean, if you want it to support a framework item just add a local for if the player has the item (example name: doesPlayerHaveItem) and replace inLSC or inBeekers or inBennys with doesPlayerHaveItem.

1 Like

Awesome!!! I will play around with this and see if I can get it to work lol.

1 Like

Hey man, just checked out your latest clean up, looks great however you don’t need to specify three different tables, you can use 1 with different data;

local bombSpots = {
    {pos = vector3(-335.5, -134.08, 39.51), reqDis = 21.0},
    {pos = vector3(-1154.54, -2009.08, 13.18), reqDis = 21.0},
    {pos = vector3(1179.18, 2639.21, 39.35), reqDis = 12.0},
    {pos = vector3(106.11, 6624.48, 33.36), reqDis = 12.0},
    {pos = vector3(-208.78, -1325.7, 30.89), reqDis = 15.0},
}

local nearBombSpot = false
local plyPos = GetEntityCoords(PlayerPedId())
for k, v in pairs(bombSpots) do
    if #(plyPos - v.pos) < v.reqDis then
        nearBombSpot = true
        break
    end
end

if nearBombSpot and IsPedInAnyVehicle(PlayerPedId(), false) then
    local veh = GetVehiclePedIsIn(PlayerPedId(), false)

    AddVehiclePhoneExplosiveDevice(veh)
    exports.pNotify:SendNotification({text = "You have placed a car bomb.", type = "success", timeout = (10000), layout = "bottomCenter",})
else
    -- Not near an LS customs or in a car.
    exports.pNotify:SendNotification({text = "You are not inside of a Customs Shop with a vehicle.", type = "error", timeout = (10000), layout = "bottomCenter",})
end
1 Like

Just updated it to use this, thank you again!

I tried the mod with the new client file that allows you to change the chance for the bomb to explode but I don’t know how to place the bomb inside the car. I’m going to Benny’s garage and typing the command but I don’t get any prompt

Do you have pNotify installed?

Nevermind I tried it now and it exploded. I had a 50% chance and thought I should have received a prompt or something when I place the bomb

You should get a notification like this if you have pNotify installed.
image

1 Like