Skip to content

Commit

Permalink
v2
Browse files Browse the repository at this point in the history
  • Loading branch information
loaf-scripts committed Feb 22, 2024
1 parent b7a75f6 commit e690c13
Show file tree
Hide file tree
Showing 30 changed files with 1,642 additions and 1,314 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Lua.diagnostics.globals": ["debugprint", "infoprint", "lib", "cache", "ClearInterval", "SetInterval"]
}
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2024 Loaf Scripts

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
171 changes: 108 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,111 @@
# loaf_spikestrips
FiveM Spikestrips, only bursts the tyres that are actually touching the spikestrip.
YouTube Showcase: https://www.youtube.com/watch?v=D3UtNxFXnpU

## Features
* Animation when laying down a spikestrip
* You can remove spikestrips
* Only the tyre that is touching the spikestrip will burst, unlike some other resources which bursts all tyres.
* Performance friendly, uses ~0.01ms
* Standalone, but has support for ESX and QBCore

## Standalone, ESX & QBCore
The script works with ESX, QBCore or standalone without any framework.

### Use with ESX
#### Installation
* Run the esx.sql file
* Rename from `loaf_spikestrips-main` to `loaf_spikestrips`
* Drag the resource to your server resources folder
* Add `ensure loaf_spikestrips` to your server.cfg
#### Configuration
* Set `Config.Framework` to `"esx"`
* Modify `FrameworkFeatures` to your liking.
#### esx_policejob compatibility
Visit [this page](https://github.com/loaf-scripts/loaf_spikestrips/wiki/esx_policejob-compatibility) for a guide on how to use the resource together with esx_policejob

### Use with QBCore
#### Installation
* Add the following code to your QBShared.Items file, located in [qb-core/shared.lua:51](https://github.com/qbcore-framework/qb-core/blob/main/shared.lua#L51) by default:
# Loaf - Spike Strips V2

Spike strip script for FiveM that only bursts the tires that are touching the spikes.

Showcase: https://www.youtube.com/watch?v=iarfWQxAMAg

<details>
<summary>Changes from V1</summary>

- Better performance
- Now supports more tires (previously only 4). This makes it work correctly on e.g a Dubsta 6x6
- Audio when placing a spike strip
- Target inteaction to pick up spike strips
- Option to spawn entities on the server or locally
- Animation when picking up
- Better support for frameworks
- Version checking
- Logs
- A bunch of quality of life features
- /clearspikestrips admin command to clear all spike strips
- Notifications
- Automatically delete after a certain time
- Delete on script stop
- Option to only allow placing on roads
- And a lot more

</details>

## Performance

6 spikestrips placed, `Config.BurstNPC` disabled:

- not in a vehicle: 0.00ms
- in a vehicle: 0.01ms
- in a vehicle, very close: 0.03-0.06ms

6 spikestrips placed, `Config.BurstNPC` enabled with NPC's driving over:

- not in a vehicle: 0.03-0.04ms
- in a vehicle: 0.05ms
- in a vehicle, very close: 0.08ms

## Installation

1. Download the latest [release](./releases/latest)
2. Install all [dependencies](#dependencies)
3. [Add the item](#adding-the-item) to your server
4. [Configure](#configuration) the script to your liking
5. Add `ensure loaf_spikestrips` to your server.cfg
6. Either restart your server, or start the resource by running `refresh` and then `ensure loaf_spikestrips` in your server console

If you use esx_policejob, you can remove the built in functionality by removing `p_ld_stinger_s` from [the table](https://github.com/esx-framework/esx_policejob/blob/c62253c1fc9993e024bc68c50954035419995289/client/main.lua#L1378) in the `-- Enter / Exit entity zone events` thread in `esx_policejob/client/main.lua`.

If you use qb-policejob, you can remove the built in functionality by removing [the thread](https://github.com/qbcore-framework/qb-policejob/blob/63026f9051f10abf703cc1b56ea5073a0c301c4f/client/objects.lua#L237) in `qb-policejob/client/object.lua` that handles the spike strip.

### Dependencies

- [ox_lib](https://github.com/overextended/ox_lib/releases/latest)

### Adding the item

You can use the included `spikestrip.png` as the item image.

<details>
<summary>Default ESX</summary>
Run the following query in your database:

```sql
INSERT INTO `items` (`name`, `label`, `weight`) VALUES ("spikestrip", "Spike strip", 500);
```

</details>

<details>
<summary>ox_inventory</summary>
Add to ox_inventory/data/items.lua:

```lua
["spikestrip"] = {
["name"] = "spikestrip",
["label"] = "Spikestrip",
["weight"] = 25,
["type"] = "item",
["image"] = "spikestrip.png",
["unique"] = false,
["useable"] = true,
["shouldClose"] = true,
["combinable"] = nil,
["description"] = "A spikestrip"
},
label = "Spike strip",
weight = 500,
stack = true
}
```
* For the not WarMenu menu, you need [qb-menu](https://github.com/qbcore-framework/qb-menu)
* Rename from `loaf_spikestrips-main` to `loaf_spikestrips`
* Drag the resource to your server resources folder
* Add `ensure loaf_spikestrips` to your server.cfg
* Move the spikestrip.png file to your qb-inventory/html/images folder
#### Configuration
* Set `Config.Framework` to `"qb"`
* Modify `FrameworkFeatures` to your liking.
#### qb-policejob compatibility
Visit [this page](https://github.com/loaf-scripts/loaf_spikestrips/wiki/qb-policejob-compatibility) for a guide on how to use the resource together with qb-policejob

### Use standalone
#### Installation
* Rename from `loaf_spikestrips-main` to `loaf_spikestrips`
* Drag the resource to your server resources folder
* Add `ensure loaf_spikestrips` to your server.cfg
#### Configuration
* Set `Config.Framework` to `"none"`
* Modify the `police` table in the server.lua file to change who is able to place spike strips.

## Credits
* `@Jay ;)#6969` - helped with adding support for qb-core
* @warxander - [warmenu](https://github.com/warxander/warmenu)

</details>

<details>
<summary>qb-inventory</summary>
Add to qb-core/shared/items.lua:

```lua
spikestrip = { name = 'spikestrip', label = 'Spike strip', weight = 500, type = 'item', image = 'spikestrip.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Useful for stopping the bad guys' },
```

</details>

## Configuration

**Config.SpawnMethod** - The method used to spawn the spike strip. This can be one of the following:
| Value | Description |
| ----- | ----------- |
| `"local"` | The spike strip entity is spawned locally on each client, and deleted when out of view. |
| `"networked"` | The entity is spawned networked by the person who places it |
| `"server"` | The entity is spawned by the server |

### Logs

The script supports logging via Discord webhooks or [ox_lib](https://overextended.dev/ox_lib/Modules/Logger/Server).

If you wish to use ox_lib, set `Config.LogSystem` to `"ox_lib"`. For discord, set it to `"discord"` and set your webhook in `loaf_spikestrips/server/logs.lua`
Loading

0 comments on commit e690c13

Please sign in to comment.