Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /roof command #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Simple-Vehicle-Control-Script

A simple script which allows you to control certain aspects of your vehicle, such as doors, engine and more...

**v0.3.2 Features:**
* **/trunk:** Opens and closes the trunk.
* **/hood:** Opens and closes the hood.
* **/rdoors:** Opens and closes the two rear doors. (Mostly for use in vans)
* **/engine (on/off):** Switches the vehicle engine on and off.
* **/lock:** Locks and unlocks vehicle doors.
* **/save:** (doesn't actually save the vehicle) Selects as the active vehicle.
* **/sveh:** Toggles "control saved vehicle only" mode. (Read changelog for more info)

[Join our discord server!](https://discord.gg/K7P8d2h)
--------
- **/roof:** Raises and lowers convertible roof.
- **/trunk:** Opens and closes the trunk.
- **/hood:** Opens and closes the hood.
- **/rdoors:** Opens and closes the two rear doors. (Mostly for use in vans)
- **/engine (on/off):** Switches the vehicle engine on and off.
- **/lock:** Locks and unlocks vehicle doors.
- **/save:** (doesn't actually save the vehicle) Selects as the active vehicle.
- **/sveh:** Toggles "control saved vehicle only" mode. (Read changelog for more info)

## [Join our discord server!](https://discord.gg/K7P8d2h)

https://forum.fivem.net/t/release-simple-vehicle-control-script/63438
17 changes: 17 additions & 0 deletions vehicle-control/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ engineoff = false
saved = false
controlsave_bool = false

-- R O O F --
RegisterNetEvent('roof')
AddEventHandler('roof',function()
local player = GetPlayerPed(-1)
if (IsPedSittingInAnyVehicle(player)) then
local vehicle = GetVehiclePedIsIn(player,false)
local roofstate = GetConvertibleRoofState(vehicle)
if (roofState == 0) then
LowerConvertibleRoof(vehicle, false)
else if (roofState == 2)
RaiseConvertibleRoof(vehicle, false)
else
ShowNotification("~r~Wait for your roof to be fully extended/retracted")
end
end
end)

-- E N G I N E --
IsEngineOn = true
RegisterNetEvent('engine')
Expand Down
11 changes: 10 additions & 1 deletion vehicle-control/server.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
-- R O O F --
AddEventHandler('chatMessage', function(s, n, m)
local message = string.lower(m)
if message == "/roof" then
CancelEvent()
--------------
TriggerClientEvent('roof', s)
end
end)
-- E N G I N E --
AddEventHandler('chatMessage', function(s, n, m)
local message = string.lower(m)
Expand Down Expand Up @@ -68,4 +77,4 @@ AddEventHandler('chatMessage', function(s, n, m)
--------------
TriggerClientEvent('controlsave', s)
end
end)
end)