Skip to content

Commit

Permalink
Update v4.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Musiker15 committed Sep 28, 2024
1 parent 9f844f6 commit b3a747a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 46 deletions.
19 changes: 8 additions & 11 deletions client/vehiclekeys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ getInventory = function()
end

getKeyFromInventory = function(plate)
plate = MSK.Trim(plate)
plate = MSK.String.Trim(plate, true)

if getInventory() == 'ox_inventory' then
local inventory = exports.ox_inventory:GetPlayerItems()

for k, v in pairs(inventory) do
if v.name == Config.VehicleKeys.item and MSK.Trim(v.metadata.plate or v.metadata.Plate or '') == plate then
if v.name == Config.VehicleKeys.item and MSK.String.Trim(v.metadata.plate or v.metadata.Plate or '', true) == plate then
return true
end
end
elseif getInventory() == 'qs-inventory' then
local inventory = exports['qs-inventory']:getUserInventory()

for k, v in pairs(inventory) do
if v.name == Config.VehicleKeys.item and MSK.Trim(v.info.plate or v.info.Plate or '') == plate then
if v.name == Config.VehicleKeys.item and MSK.String.Trim(v.info.plate or v.info.Plate or '', true) == plate then
return true
end
end
elseif getInventory() == 'core_inventory' then
local inventory = MSK.Trigger('msk_enginetoggle:getInventory', 'core_inventory')

for k, v in pairs(inventory) do
if v.name == Config.VehicleKeys.item and MSK.Trim(v.metadata.plate or v.metadata.Plate or '') == plate then
if v.name == Config.VehicleKeys.item and MSK.String.Trim(v.metadata.plate or v.metadata.Plate or '', true) == plate then
return true
end
end
Expand Down Expand Up @@ -66,8 +66,10 @@ getIsKeyOwner = function(vehicle)
isKeyOwner = getKeyFromInventory(plate)
end

for k, v in pairs(Config.Whitelist.vehicles) do
if GetEntityModel(vehicle) == IsModelValid(v) and v or GetHashKey(v) then
for k, v in pairs(Config.Whitelist.vehicles) do
local modelHash = type(v) == 'number' and v or GetHashKey(v)

if GetEntityModel(vehicle) == modelHash then
ignoreVehicle = true
break
end
Expand All @@ -80,11 +82,6 @@ getIsKeyOwner = function(vehicle)
end
end

local canToggleEngine = false
if isKeyOwner or ignoreVehicle or ignorePlate then
canToggleEngine = true
end

return (isKeyOwner or ignoreVehicle or ignorePlate)
end
exports('getIsKeyOwner', getIsKeyOwner)
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_enginetoggle'
description 'EngineToggle for Vehicles'
version '4.2.5'
version '4.2.6'

lua54 'yes'

Expand Down
6 changes: 3 additions & 3 deletions server/hotwire.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ end

getAlarmStage = function(source, plate)
local result = MySQL.query.await(('SELECT * FROM %s WHERE plate = @plate'):format(VEHICLE_TABLE_NAME), {
['@plate'] = MSK.Trim(plate, true)
['@plate'] = MSK.String.Trim(plate)
})

if result and result[1] then
Expand Down Expand Up @@ -100,14 +100,14 @@ RegisterNetEvent('msk_enginetoggle:saveAlarmStage', function(plate, stage)

local result = MySQL.query.await(('SELECT * FROM %s WHERE %s = @owner AND plate = @plate'):format(VEHICLE_TABLE_NAME, OWNER_COLUMN_NAME), {
['@owner'] = identifier,
['@plate'] = MSK.Trim(plate, true)
['@plate'] = MSK.String.Trim(plate)
})

if result and result[1] and result[1][OWNER_COLUMN_NAME] == identifier then
MySQL.update(('UPDATE %s SET alarmStage = @alarmStage WHERE %s = @owner AND plate = @plate'):format(VEHICLE_TABLE_NAME, OWNER_COLUMN_NAME), {
['@alarmStage'] = stage,
['@owner'] = identifier,
['@plate'] = MSK.Trim(plate, true),
['@plate'] = MSK.String.Trim(plate),
})
else
Config.Notification(playerId, Translation[Config.Locale]['not_vehicle_owner'], 'error')
Expand Down
31 changes: 14 additions & 17 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,20 @@ GetPlayerJob = function(Player)
end

if Config.AdminCommand.enable then
for k, group in pairs(Config.AdminCommand.groups) do
ExecuteCommand(('add_ace group.%s command.%s allow'):format(group, Config.AdminCommand.command))
end
local allowedGroups = Config.AdminCommand.groups

for i = 1, #allowedGroups do
ExecuteCommand(('add_ace group.%s command.%s allow'):format(allowedGroups[i], Config.AdminCommand.command))
end

local isAceAllowed = function(source)
for k, group in pairs(Config.AdminCommand.groups) do
if IsPlayerAceAllowed(source, ('command.%s'):format(group)) then
return true
end
end
return false
local isAceAllowed = function(playerId, command)
return IsPlayerAceAllowed(playerId, ('command.%s'):format(command))
end

RegisterCommand(Config.AdminCommand.command, function(source, args, rawCommand)
local src = source

if not isAceAllowed(src) then
if not isAceAllowed(src, Config.AdminCommand.command) then
return Config.Notification(src, 'You don\'t have permission to do that!', 'error')
end

Expand All @@ -86,12 +83,12 @@ RegisterNetEvent('msk_enginetoggle:addTempKey', function(plate)
local playerId = source
plate = tostring(plate)

if Config.VehicleKeys.script == 'VehicleKeyChain' then
exports["VehicleKeyChain"]:AddTempKey(playerId, plate)
elseif Config.VehicleKeys.script == 'vehicle_keys' then
exports["vehicle_keys"]:giveVehicleKeysToPlayerId(playerId, plate, 'temporary')
elseif Config.VehicleKeys.script == 'msk_vehiclekeys' then
if Config.VehicleKeys.script == 'msk_vehiclekeys' then
exports["msk_vehiclekeys"]:AddKey({source = playerId}, plate, 'temporary')
elseif Config.VehicleKeys.script == 'VehicleKeyChain' then
exports["VehicleKeyChain"]:AddTempKey(playerId, plate)
elseif Config.VehicleKeys.script == 'vehicles_keys' then
exports["vehicles_keys"]:giveVehicleKeysToPlayerId(playerId, plate, 'temporary')
elseif Config.VehicleKeys.script == 'okokGarage' then
TriggerEvent("okokGarage:GiveKeys", plate, playerId)
else
Expand All @@ -114,7 +111,7 @@ RegisterNetEvent('msk_enginetoggle:enteredVehicle', function(plate, seat, netId,

local result = MySQL.query.await(('SELECT * FROM %s WHERE %s = @owner AND plate = @plate'):format(VEHICLE_TABLE_NAME, OWNER_COLUMN_NAME), {
['@owner'] = identifier,
['@plate'] = MSK.Trim(plate, true)
['@plate'] = MSK.String.Trim(plate)
})

if result and result[1] then
Expand Down
16 changes: 2 additions & 14 deletions server/versionchecker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ local CheckResourceName = function()
end
end

local Split = function(str, delimiter)
assert(str and type(str) == 'string', 'Parameter "str" has to be a string on function MSK.Split')
assert(delimiter and type(delimiter) == 'string', 'Parameter "delimiter" has to be a string on function MSK.Split')
local result = {}

for match in str:gmatch("([^"..delimiter.."]+)") do
result[#result + 1] = match
end

return result
end

local PrintKeyScripts = function()
local VehicleScript = ("^3[%s]^0"):format(Config.VehicleKeys.script)

Expand Down Expand Up @@ -66,8 +54,8 @@ local CheckVersionCallback = function(status, response, headers)
return
end

local current = Split(currentVersion, '.')
local latest = Split(latestVersion, '.')
local current = MSK.String.Split(currentVersion, '.')
local latest = MSK.String.Split(latestVersion, '.')

for i = 1, #current do
if current[i] > latest[i] then
Expand Down

0 comments on commit b3a747a

Please sign in to comment.