Hey everyone! I’m attempting to learn .lua for my own little hobby. I’ve went ahead with a go with some a simple script that essentially toggles vehicle extras by using chat commands (even though someone has probably done this).
Is there anything anyone would suggest to either make this better, or just make it less complicated? It is only supposed to toggle Extra 1.
Server.lua
RegisterCommand('extra1', function()
TriggerClientEvent("extra1", -1)
end)
Client.lua
RegisterNetEvent('extra1')
AddEventHandler('extra1', function()
local extraId = 1
local ped = PlayerPedId()
if IsPedInAnyVehicle(ped, false) then
local vehicle = GetVehiclePedIsUsing(ped)
if vehicle ~= nil then
if (DoesExtraExist(vehicle, extraId)) then
if (IsVehicleExtraTurnedOn(vehicle, extraId)) then
SetVehicleExtra(vehicle, extraId, 1)
else
SetVehicleExtra(vehicle, extraId, 0)
end
end
end
end
end, false)
I appreciate all criticism, thanks everyone!