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.
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
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!
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)
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.
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
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