We are finding that people are stealing other peoples cars and now able to use the light script even when they shouldn’t have permission. They cannot edit the lights or add new ones… but they can still drive around with cars that have the lights and use them with keybinds - and its a problem
but I don’t think its the end of the world or anything. If someones car is stolen then so be it lol. But…
An idea/suggestion:
Is it possible to save with user only? Not plate? OR alternatively
If it is possible, maybe we have something that checks the permission based on who the user is. If the user does not have permission… then it kicks them out of the car. Much like how Ace Perms work only in this case its not ace perms its your script telling the identifier.
For example here is client code from a customized vehicle restriction script (Badger Vehicle Restrictions) that maybe could work if integrated to use your script’s identifier instead of ace perms in this case:
restrictions = Config.VehicleRestrictions;
myRoles = nil;
RegisterNetEvent("BadgerVehicles:CheckPermission:Return")
AddEventHandler("BadgerVehicles:CheckPermission:Return", function(roles)
myRoles = roles;
end)
lastChecked = nil;
hasPerm = nil;
Citizen.CreateThread(function()
TriggerServerEvent("BadgerVehicles:CheckPermission");
while true do
Citizen.Wait(1000)
local ped = PlayerPedId()
local veh = nil
if IsPedInAnyVehicle(ped, false) then
veh = GetVehiclePedIsUsing(ped)
else
veh = GetVehiclePedIsTryingToEnter(ped)
end
local model = GetEntityModel(veh)
if (model ~= nil) then
local driver = GetPedInVehicleSeat(veh, -1)
if (lastChecked ~= nil) and (lastChecked == model) and (hasPerm ~= nil) and (not hasPerm) then
if driver == ped then
ShowInfo(Config.RestrictedMessage)
-- DeleteEntity(veh)
local player = PlayerPedId()
local vehicle = GetVehiclePedIsIn(player, false)
local flag = 256 -- This number can be changed to dictate how the ped leaves the vehicle
TaskLeaveVehicle(player, vehicle, flag)
ClearPedTasksImmediately(ped)
end
print("[DiscordVehicleRestrictions] Vehicle was last checked, but is not a driver...")
end
end
if veh ~= nil and DoesEntityExist(veh) and lastChecked ~= model then
local driver = GetPedInVehicleSeat(veh, -1)
-- Check if it has one of the restricted vehicles
local requiredPerm = nil;
hasPerm = false;
for role, val in pairs(myRoles) do
if (val == true) then
local vehicles = Config.VehicleRestrictions[role];
for i = 1, #vehicles do
if GetHashKey(vehicles[i]) == model then
requiredPerm = true;
hasPerm = true;
end
end
end
end
if not hasPerm then
local vehicles = Config.VehicleRestrictions;
for role, vehicleList in pairs(vehicles) do
for i = 1, #vehicleList do
if GetHashKey(vehicleList[i]) == model then
requiredPerm = true;
end
end
end
end
lastChecked = model;
-- If doesn't have permission, it's a restricted vehicle to them
if not hasPerm and (requiredPerm ~= nil) then
if driver == ped then
ShowInfo(Config.RestrictedMessage)
-- DeleteEntity(veh)
local player = PlayerPedId()
local vehicle = GetVehiclePedIsIn(player, false)
local flag = 256 -- This number can be changed to dictate how the ped leaves the vehicle
TaskLeaveVehicle(player, vehicle, flag)
ClearPedTasksImmediately(ped)
end
else
hasPerm = true;
end
end
end
end)
function ShowInfo(text)
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName(text)
DrawNotification(false, false)
end
server example
RegisterServerEvent("BadgerVehicles:CheckPermission")
AddEventHandler("BadgerVehicles:CheckPermission", function()
local src = source;
local userRoles = {}
for k, v in ipairs(GetPlayerIdentifiers(src)) do
if string.sub(v, 1, string.len("discord:")) == "discord:" then
identifierDiscord = v
end
end
if tostring(identifierDiscord) == "394446211341615104" then
-- It is the one and only Badger, we must pay our respects
TriggerClientEvent('chatMessage', -1, '^1[^5DiscordVehicleRestrictions^1] ^3Script creator ^1Badger ^3has joined the server!...');
end
if identifierDiscord then
local roleIDs = exports.Badger_Discord_API:GetDiscordRoles(src)
if not (roleIDs == false) then
for i = 1, #roleIDs do
for role, vehicles in pairs(Config.VehicleRestrictions) do
if exports.Badger_Discord_API:CheckEqual(role, roleIDs[i]) then
userRoles[role] = true;
print("[DiscordVehicleRestrictions] " .. GetPlayerName(src) .. " has received permission for role: " .. tostring(role) );
if Config.InheritanceEnabled then
local inheritedRoles = Config.Inheritances[role];
if inheritedRoles ~= nil then
-- There is inheritted roles
for j = 1, #inheritedRoles do
userRoles[ inheritedRoles[j] ] = true;
print("[DiscordVehicleRestrictions] " .. GetPlayerName(src) .. " has inherited role: " .. tostring(role) );
end
end
end
end
end
end
else
print("[DiscordVehicleRestrictions] " .. GetPlayerName(src) .. " did not receive permissions because roles == false")
end
elseif identifierDiscord == nil then
print("[DiscordVehicleRestrictions] " .. "identifierDiscord == nil")
end
-- Trigger client event
TriggerClientEvent("BadgerVehicles:CheckPermission:Return", src, userRoles);
end)
Obviously this script uses vehicle models instead of identifiers as it checks if the user has perms for that model but in this case maybe some other way you can figure out… just an idea. Not a big deal really.
