[FREE] [ESX] NKHD Plate Switcher V2

image

Its a bit Buggy with the California but its okay.

Basically everything works, only if I have a white California license plate and remove the tape then it is suddenly the black california plate so it isnt resetting the plate correctly. Do you have a fix for this?

It is going to be fixed in the V3

Good to hear that! Do you know when the V3 will be released?

Not yet.

1 Like

what can i do that my vehicle keys from quasar and the garage system from quasar still works?

Unfortiently, I have no Fix for that, because the Plate is set to " " nothing

Is there a way to make the license plate number visually disappear while still keeping it in the system? Because with some garage scripts, this issue prevents the car from being parked or unlocked.

While reviewing the script, I noticed a few logical issues and edge cases that don’t seem to have been considered.

One major concern is that many resources rely on the GetVehicleNumberPlateText native to retrieve a vehicle’s plate, query their database, and determine ownership or perform other related logic.

This script replaces the vehicle’s plate with an empty string (" "). Doing so can easily break compatibility with systems such as Vehicle Keys, Garages, Impound, and other resources that use the plate as the primary identifier. Those systems would attempt to verify ownership of a vehicle with the plate " ", which would obviously fail.

Even more concerning, if another resource were to accidentally assign ownership or vehicle keys to a vehicle whose plate is " ", it could unintentionally grant access to every taped vehicle on the server, since they would all share the same plate value.


Another issue is the following code:

while true do
    TriggerServerEvent('nkhd_changePlate:getIdentifier')
    TriggerServerEvent('nkhd_changePlate:getPlateData')
    Citizen.Wait(100)
end

This is extremely expensive. It continuously triggers two server events every 100 ms, which performs a database query. That results in constant database activity for every connected client, even when no relevant state has changed.


This design also introduces another logical issue. Consider the following event handler:

RegisterNetEvent('nkhd_changePlate:receivePlateSwitcherData')
AddEventHandler('nkhd_changePlate:receivePlateSwitcherData', function(data)
    for _, row in ipairs(data) do
        identifiern = row.identifier
        platen = row.plate
        modeln = row.model
    end
end)

The loop simply stores the values from the last row in the returned dataset. Since this data is global rather than scoped per player, the client only ends up tracking the most recently taped vehicle on the entire server.

As a result, if Player A tapes a vehicle and later Player C tapes another vehicle, Player A’s cached data will be overwritten with Player C’s information. This causes checks such as:

if identifiert == identifiern then

to fail for Player A, since identifiern now belongs to Player C. In practice, only the player associated with the latest taped vehicle would satisfy this condition, preventing previous players from untaping their own vehicles.


I’ve shared a few of the issues I observed while reviewing the script. I’m also thinking through the best ways to address them, but I don’t want to suggest solutions that I haven’t properly thought through yet.

I’ll spend some more time evaluating the different approaches and will hopefully come back with well-considered suggestions in a little while.

Feel free to reach me out on Discord → osmiumop. You can also find my work on OsmFX Mods. (sorry for the plug)