Giter Club home page Giter Club logo

altmp-js-action-manager's Introduction

altmp-js-action-manager

Description

This adds client-side utilities to help you create client-side actions.

RoadMap:

  • Add container utilities. (foreach, get(id), and more...)
  • Add some getters & setters. (Position, rotation)
  • Add client-side streaming. (Not mandatory)
  • Maybe marker support as well. (Not really sure if it would be useful)

Dependencies

This utility depends on https://github.com/Kudze/altmp-js-3dtext-spawner

Instalation

  1. Install https://github.com/Kudze/altmp-js-3dtext-spawner
  2. Clone the repository.
  3. Install as regular alt:v resource.

Most basic example (invisible & stationary)

import ALTAction from "altmp-js-action-manager";

const someGroundItemID = 100;
let action = ALTAction.new(
    { //<-- Position
        "x": 0,
        "y": 0,
        "z": 0
    },
    () => { //<-- Callback. (The code which is executed if action is done.)
        alt.emitServer(
            "takeItem",
            someGroundItemID
        );
    },
    undefined //<-- 3DText type.
);

Position types:

  1. Static (shown in first example)
  2. Dynamic (Action is attached to (moving with) physics-enabled 3D prop)
import ALTAction from "altmp-js-action-manager";
import ALTProp from "altmp-js-prop-spawner";

let prop = ALTProp.new(
    "prop_pineapple",
    {x: 0, y: 0, z: 80},
    {
        dynamic: true
    }
);

const someGroundItemID = 100;
let action = ALTAction.new(
    () => {
        return prop.getPosition()
    },
    () => { //<-- Callback. (The code which is executed if action is done.)
        alt.emitServer(
            "takeItem",
            someGroundItemID
        );
    },
    undefined //<-- 3DText type.
);

3DText types:

(On 2nd and 3rd examples 3DText will always be attached to action)

(On 4th example this is customizeable)

  1. No 3DText (shown in first example)
  2. Regular Action 3D text
import ALTAction from "altmp-js-action-manager";

const someGroundItemID = 100;
let action = ALTAction.new(
    { //<-- Position
        "x": 0,
        "y": 0,
        "z": 0
    },
    () => { //<-- Callback. (The code which is executed if action is done.)
        alt.emitServer(
            "takeItem",
            someGroundItemID
        );
    },
    { //<-- 3DText type.
        title: "Pineapple",
        action: "pick up"
    }
);
  1. Custom 3D text
import ALTAction from "altmp-js-action-manager";

const someGroundItemID = 100;
let action = ALTAction.new(
    { //<-- Position
        "x": 0,
        "y": 0,
        "z": 0
    },
    () => { //<-- Callback. (The code which is executed if action is done.)
        alt.emitServer(
            "takeItem",
            someGroundItemID
        );
    },
    "~o~I'm a action with a custom 3D text!" //<-- 3DText type.
);
  1. Fully customizable 3D Text
import ALTAction from "altmp-js-action-manager";

const someGroundItemID = 100;
let action = ALTAction.new(
    { //<-- Position
        "x": 0,
        "y": 0,
        "z": 0
    },
    () => { //<-- Callback. (The code which is executed if action is done.)
        alt.emitServer(
            "takeItem",
            someGroundItemID
        );
    },
    () => { //<-- 3DText (Executed only upon creation).
        //(Create some custom Text3D...)
        return someText3D;
    }
);

altmp-js-action-manager's People

Contributors

kudze avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

1stfabone

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.