Coder Social home page Coder Social logo

stuyk / altv-os-context-menu Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 7.0 144 KB

alt:V Context Menu for Right-Clicking on Objects In-Game. Runescape Style.

Home Page: https://stuyk.com/

License: GNU General Public License v3.0

JavaScript 82.31% HTML 5.81% Less 11.88%
altv ragemp fivem esx

altv-os-context-menu's Introduction

Open Source - Context Menu - alt:V

❤️ Become a Sponsor of my Open Source Work

⌨️ Learn how to script for alt:V

💡 Need a Roleplay Script? Try Athena!

⭐ This repository if you found it useful!


Description

This allows you to create a simple context menu for players to utilize. Which means they can hold left alt and right-click on objects to select different objects based on their models. Which is great for creating in-depth options for players to utilize.

Installing Dependencies / Installation

I cannot stress this enough. Ensure you have NodeJS 13+ or you will have problems.

  • NodeJS 13+
  • An Existing or New Gamemode
  • General Scripting Knowledge

After simply add the name of this resource to your server.cfg resource section.

altv-os-context-menu

Then simply clone this repository into your main server resources folder.

cd resources
git clone https://github.com/Stuyk/altv-os-context-menu

Ensure your package.json includes this property:

"type": "module"

Configuring A Menu

All menus must be created on client-side. They only need to be initialized once. They are attached to an identifier and an entity id.

Go in-game. Hold alt and right-click on any object. Open your console with F8 then look at the model number for the object.

alt.emit('context:CreateMenu')

Argument Description
model The model of the model you wish to append options to.
title The name of the menu.

Example

alt.on('context:Ready', () => {
    alt.emit('context:CreateMenu', 1329570871, 'Trash Can');
});

Appending to Menu

All menus have an identifier. Use the identifier to apply options to a menu.

alt.emit('context:CreateMenu')

Argument Description
model The model of the model you wish to append options to.
contextOptionName The name of the option you are appending.
eventCallbackName The event to call when the option is selected. Comes through alt.emit or alt.onClient
isServer If true. Then the callbackName event will come through alt.onClient. Otherwise alt.emit

Example

alt.on('context:Ready', () => {
    alt.emit('context:CreateMenu', 1329570871, 'Trash Can');
    alt.emit('context:AppendToMenu', 1329570871, 'Look in Trash', 'trashcan:Look', false);
    alt.emit('context:AppendToMenu', 1329570871, 'Dig in Trash', 'trashcan:Dig', true);
});

Example - Recieving the Event on Client-side.

alt.on('trashcan:Look', data => {
    alt.log(JSON.stringify(data));
});

Example - Recieving the Event on Server-side.

alt.onClient('trashcan:Dig', (player, data) => {
    console.log(data);
    alt.log(`${player.name} has dug in the trash. What an animal!`);
});

Other alt:V Open Source Resources

altv-os-context-menu's People

Contributors

stuyk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.