Skip to content

v0.0.7-b1

Latest
Compare
Choose a tag to compare
@shr0x shr0x released this 17 Aug 12:25
· 2 commits to main since this release
d12b138

Version 0.0.7 (QoL)

Additional

[+] Added /do to describe a rp action.
[+] Added /s(hout) to shout out a message.
[+] Added /w(hisper) to whisper another player (/w [target] [message]).
[+] Added /admins to list all online admins. (for level 1 admin)
[+] Added /givecash (/givemoney) [player] [amount].
[+] Added /goto for level 1 admins & a bunch of admin teleport locations.
[+] Added /gethere for level 1 admins to teleport a player to their position.

[+] Added chat module with various chat methods (see below).
[+] Added in-vehicle interaction, you can now interact with the vehicle you're in by pressing G.
[+] Added player nametags.
[+] Added player.setEmoteText(color: array4d, text: string, timeout: number /*seconds*/);
[+] Added DynamicPoint.createBlip(sprite: number, position Vector3, ...options);
[+] Added DynamicPoint.destroyBlip();
[+] Added player-crawling, not being used currently but it might in future.
[+] Added DynamicPoint.createMarker(type: number, position: Vector3, scale: number, ...options);
[+] Added DynamicPoint.destroyMarker();
[+] Added new interactive progress bar for inventory.
[+] Added Client.isDead (get) -> Returns true if a player is in death state, false if not.

[+] Added player-attachments with slightly changes and a bunch of attachments which may come handy to you for your creative content. (Credits: https://rage.mp/files/file/144-efficient-attachment-sync/)
--->player.addAttachment(name:string, attach:boolean);

[+] Added player.character.cash property (get/set)
[+] Added player.giveMoney(amount: number, logMessage?:string);

[+] (UI) Added player cash to HUD.
[+] (UI) Added a way to exit the interaction menu when in the first page.
[+] (UI) Added native menu.
[+] (UI) Added interactive button, supports progress bar & input.
[+] (UI) (WIP) Added player settings menu, to change account password, manage display settings & keybindings.

Changes:

[/] Few changes on creator icons.
[/] Increased size of radial menu.
[/] Players can no longer open inventory or use quick slots while they're in injured state.
[/] Updated draw distance for interactable NPC text label.
[/] Moved some inventory exported enums to shared folder.
[/] You can now press ESC(escape) to close most of the pages that you're allowed to.

New


Radial Menu Changes

Now it has a center button to exit the menu if in first page.
radial

Interaction UI

interaction
interaction2
interaction3

Example

//Example of how to show a button
const buttonData: RageShared.Interfaces.IInteractButton = {
    button: "Esc",
    autoStart: false,
    time: 0,
    count: 0,
    image: "default",
    rarity: 0,
    header: "Hello World",
    description: "This is a description"
};
RAGERP.cef.emit(player, "hud", "showInteractionButton", buttonData);

//Example of how to hide it
RAGERP.cef.emit(player, "hud", "showInteractionButton", null);

Player emotes

Creates a player emote text-label above their head.

Example

player.setEmoteText([255, 255, 255, 255], "Hello world", 7);

emotes

Chat methods

RAGERP.chat.sendNearbyMessage(position: Vector3, radius: number, message: string);
RAGERP.chat.sendSyntaxError(player: PlayerMp, message: string);
//color must be 32-bit hex (eg 0x00AA00AA)
RAGERP.chat.sendAdminWarning(color: number, message: string, level: number = ADMIN_LEVEL_ONE);
/* Sends a syntax error message */
RAGERP.chat.sendSyntaxError(player: PlayerMp, message: string);

//Example
RAGERP.commands.add({
    name: "message",
    run: (player: PlayerMp, text: string) => {
        if (!text.length) return RAGERP.chat.sendSyntaxError(player, "/message [text]"); //returns "Usage: /message [text]"
        //do what you want
    }
});

Player Crawling (client-side only)

import {Client} from './path/to/classes/Client.class.ts';

//enable or disable player-crawling animation for local player.
Client.toggleCrawling();

Native Menu (currently, server-side only)

Native menu will make your job easier as developer to create stuff for players to quickly interact with.
Currently it supports 3 button types, default button, a string list switcher (left and right) and a checkbox.

//initialize a new native menu:
new NativeMenu(player: PlayerMp, id: number, header: string, desc: string, items: Array<[]>);

//A promise awaiting the response of item data that player has selected in native menu
nativemenu.onItemSelected(player).then((data) => {
    //do what you want
});

//destroy a menu for given player
nativemenu.destroy(player);


//example
RAGERP.commands.add({
    name: "testnativemenu",
    adminlevel: RageShared.Enums.ADMIN_LEVELS.LEVEL_SIX,
    run: async (player: PlayerMp) => {
    
        const items = [
            { name: "test", type: RageShared.Enums.NATIVEMENU_TYPES.TYPE_DEFAULT, uid: 0 },
            { name: "test 2", type: RageShared.Enums.NATIVEMENU_TYPES.TYPE_DEFAULT, uid: 1 },
            { name: "test 3", type: RageShared.Enums.NATIVEMENU_TYPES.TYPE_DEFAULT, uid: 2 }
        ]
    
        player.nativemenu = new NativeMenu(player, 0, "Hello World", "This is a description", items);

        player.nativemenu.onItemSelected(player).then((res) => {
            if (!res) return player.nativemenu?.destroy(player);
            
            const data = RAGERP.utils.parseObject(res);
            
            console.log("onItemSelected called, with result: ", data);

            switch (data.listitem) {
                case 0: {
                    console.log("player selected the first item in native menu");
                    return;
                }
                default: {
                    return console.log(`player selected index ${data.listitem} | name: ${data.name} | uid: ${data.uid}`);
                }
            }
        });
    }
});

menu

Settings

Settings menu is currently done only in UI and is not connected with backend, however here's a screenshot of how it looks like, in this menu you'll be able to cchange your account's password, display settings and keybinding.
settings

Inventory progress bar

Inventory progress bar will allow you to show players an interactive progress bar which they can cancel at any time
An example would be when they're using an item, such as when they're eating, you can create a new progress bar with the given item, animation and time which player can cancel when they have to by pressing ESC

interface IUsingItemData {
    item: RageShared.Inventory.Interfaces.IBaseItem;
    animDict?: string;
    animName?: string;
    flag?: number;
    attachObject?: string;
}

/*
  * @param {PlayerMp} player - The player interacting with the item.
  * @param {string} description - The description of the progress bar.
  * @param {number} time - The duration of the progress bar in seconds.
  * @param {IUsingItemData} data - The data related to the item being used.
  * @param {() => void} onFinish - Callback function to execute when the progress bar finishes.
 */
player.character.inventory.startUsingItem(player: PlayerMp, description: string, time: number, data: IUsingItemData, handler: () => void)


//example (NOTE: this item does not exist, its just an example)
const items = player.character.inventory.getItemsInCategoryByType([RageShared.Inventory.Enums.INVENTORY_CATEGORIES.POCKETS], RageShared.Inventory.Enums.ITEM_TYPES.ITEM_TYPE_BURGER);
if (!items.length) return;

const actionData = {
    item: items[0],
    animDict: "mp_player_inteat@burger",
    animName: "mp_player_int_eat_burger",
    flag: 49,
    attachObject: "item_hamburger"
}

player.character.inventory.startUsingItem(player, "Press ESC to cancel this action", 5, actionData, async () => {
    console.log("Player has finished eating a burger!");
});