💻
alt:V Athena Docs v3.0.0
  • Info
    • Introduction
    • Patreon & Support
    • Athena Discord
    • FAQ
  • Installation
    • Common Issues
    • Windows
    • Linux (Ubuntu 20.04+)
    • Debugging
    • Updating
  • Info
    • Admin
    • Configuration
    • Console
    • Database
    • Hotkeys
    • Identifier
  • Plugins
    • Load Plugins
    • Create Plugins
    • Mods
    • Clothing
  • Controllers
    • What is a Controller?
    • Blip Controller
    • Interaction Controller
    • Marker Controller
    • Object Controller
    • Ped Controller
    • Text Label Controller
    • World Notification Controller
  • Systems
    • Interiors
    • Inventory & Items
    • Inventory Rules
    • Jobs
    • Time
    • Weather
  • Menus
    • Menu Types
    • Action Menus
    • Input Menu
    • Wheel Menu
  • Player
    • Admin-Commands
    • Animations
    • Attach Objects
    • Credits
    • Currency
    • Commands
    • Error Screen
    • Message
    • Meta
    • Notifications
    • Particle
    • Progress Bar
    • Save
    • Shard
    • Sound
    • Spinners
    • Task Timeline
  • Custom WebViews
    • Introduction
    • Your First Page
    • CSS Framework
  • Misc
    • Custom Sounds
    • Custom Streamers
    • Custom Icons
    • Adding Locale / Translations
    • Adding Vehicle Rules
    • Adding Whitelist
    • Adding Wheel Menus
    • Adding Parking Garages
Powered by GitBook
On this page
  • Vehicle Rule Types
  • Vehicle Rule Usage
Edit on GitHub
  1. Misc

Adding Vehicle Rules

Learn how to add vehicle rules.

Vehicle rules are a special set of rules you can apply to most vehicle functionality.

They determine whether or not an action can be completed on a vehicle.

Vehicle Rule Types

enum VEHICLE_RULES {
    ENTER = 'vehicle-enter',
    EXIT = 'vehicle-exit',
    LOCK = 'vehicle-lock',
    UNLOCK = 'vehicle-unlock',
    STORAGE = 'vehicle-storage',
    ENGINE = 'vehicle-engine',
    DOOR = 'vehicle-door',
}

Vehicle Rule Usage

Remember you will need to import VehicleSystem and VEHICLE_RULES into your file

// Define the rule and what rule to use.
VehicleSystem.addCustomRule(VEHICLE_RULES.ENTER, (player, vehicle, { seat }) => {
    // Probably not a 'faction' vehicle.
    if (!vehicle.data) {
        return { status: true, response: null };
    }

    // Vehicle is not a faction vehicle.
    if (!vehicle.data.faction) {
        return { status: true, response: null };
    }

    // Vehicle is a faction vehicle at this point.
    // Player is not in a faction.
    if (!player.data.faction) {
        return { status: false, response: null };
    }

    // Faction matches player's faction.
    if (player.data.faction === vehicle.data.faction) {
        return { status: true, response: null };
    }

    // Player is not in same faction as vehicle.
    return { status: false, response: 'You do not have keys for this faction vehicle.' };
});
PreviousAdding Locale / TranslationsNextAdding Whitelist

Last updated 3 years ago