shieldCan-Check Hooks

Hook functions that run before actions are executed. Return false to deny with an optional reason.

Can-check hooks allow you to intercept and control nearly every action in zyke_garages. Each hook function is called before its respective action executes. By default, all hooks return true, allowing the action to proceed.

To deny an action, return false along with an optional reason string. The reason is displayed to the player as a notification.

File Locations

Side
File

Server

server/unlocked/can_checks.lua

Client

client/unlocked/can_checks.lua

Both files are unencrypted and safe to edit directly.

circle-info

Types / Classes

All types / classes can be found in shared/unlocked/types.lua.


How Reason Strings Work

When you return false, you can provide a second return value, a reason string, which is shown to the player as a notification.

Server-side reasons

On the server, the reason string is returned in the callback response to the client. The client passes it to Z.notify(), which means it should be a locale key from your translations file.

If no reason is provided, a generic "noPermission" fallback is used.

Example:

function CanSpawnVehicle(source, vin, garageId)
    if (someCondition) then
        return false, "noAccessToGarage"
    end

    return true
end

Client-side reasons

On the client, the reason string is passed directly to Z.notify(). This means it should also be a locale key. If the reason is nil, no notification is shown at all.

Example:


Server-Sided Hooks

All server-sided hooks are in server/unlocked/can_checks.lua.

Can Lock Vehicle

Called before a vehicle is locked via the key fob. Example:

Can Unlock Vehicle

Called before a vehicle is unlocked via the key fob. Example:

Can Toggle Engine

Called before a vehicle's engine is toggled via the key fob. Example:

Can Lockpick (Server)

Called before a player lockpicks a vehicle. NOTE that this check also exists client-sided as CanLockpick in client/unlocked/can_checks.lua. Both checks must pass for the action to succeed. Example:

Can Hotwire (Server)

Called before a player hotwires a vehicle. NOTE that this check also exists client-sided as CanHotwire in client/unlocked/can_checks.lua. Both checks must pass for the action to succeed. Example:

Can Spawn Vehicle

Called before a vehicle is spawned (taken out of a garage). Example:

Can Store Vehicle (Server)

Called before a vehicle is stored (parked) in a garage. Example:

Can Drive Away From Interior

Called before a vehicle is driven out of a garage interior. Example:

Can Set New Owner

Called before a vehicle's ownership is changed. NOTE that source can be a server ID, identifier, or "server" for internal transfers. Example:

Can Transfer Garage

Called before a vehicle is transferred to another garage. Example:

Can Give Temp Keys

Called before temporary keys are given for an NPC vehicle. Example:

Can Purchase Key

Called before a key is purchased from a garage. Example:

Can Impound Vehicle

Called before a vehicle is impounded. Example:

Can Pay Impound

Called before an impound fee is paid. Example:

Can Apply Fake Plate

Called before a fake plate is applied to a vehicle. Example:

Can Remove Fake Plate

Called before a fake plate is removed from a vehicle. Example:

Can Set New Plate

Called before a vehicle's plate is permanently changed. Example:

Can Scratch VIN

Called before a VIN is marked as scratched (untraceable). Example:

Can Delete Scratched Vehicle

Called before a vehicle with a scratched VIN is deleted. Example:


Client-Sided Hooks

All client-sided hooks are in client/unlocked/can_checks.lua.

Can Open Garage

Called before a garage menu is opened. Example:

Can Enter Garage Interior

Called before a player enters a garage interior. Example:

Can Store Vehicle (Client)

Called before a player stores a vehicle in a garage. This is a separate check from the server-sided CanStoreVehicle. Example:

Can Steal Temp Keys

Called before a player starts searching for temporary keys in an NPC vehicle. Example:

Can Rob NPC Keys

Called before a player robs keys from an NPC by aiming a weapon at them. Example:

Can Open Vehicle Management

Called before a player opens the vehicle management menu. Example:

Can Lockpick (Client)

Called before a player attempts to lockpick a vehicle. NOTE that this check also exists server-sided as CanLockpick in server/unlocked/can_checks.lua. Both checks must pass for the action to succeed. Example:

Can Hotwire (Client)

Called before a player attempts to hotwire a vehicle. NOTE that this check also exists server-sided as CanHotwire in server/unlocked/can_checks.lua. Both checks must pass for the action to succeed. Example:

Can Summon Vehicle

Called before a vehicle is summoned to the player via the key fob. Example:

Can Open Locksmith

Called before the locksmith menu is opened. Example:


Common Patterns

Deny an action for a specific garage

Deny an action based on vehicle data

Gate an action behind a specific item

Deny actions during an event or condition

Last updated