Giter Club home page Giter Club logo

chat-scaleform's Introduction

chat-scaleform

chat scaleform functionality for RAGE:MP

Controls

  • T (GLOBAL chat)
  • Y (TEAM chat)
  • U (LOCAL chat)
  • alt + shift (Changes to the secondary language if supported)
  • PAGE_UP (Scroll history up) works only when input is opened
  • PAGE_DOWN (Scroll history down)  works only when input is opened

Known Issues

  • Message colors for player's message isn't supported due to scaleform.
  • Chat supports only one extra language and needs to be mapped before being used.

Language mapping

Special thanks to chrysls for his awesome contribution in creating Multi-language support. Although it's currently limited into English + secondary language, but we're aiming for more than two languages support in the future. Currently the first supported language is Russian which is provided in client_packages/chat/mapping/ru.js. Feel free expand our language database by your awesome contribution.

How to contribute to language mapping

If you're a developer and want to expand our language mapping. Create an javascript file in client_packages/chat/mapping/ and copy the form from _base.js and replace each key with its own unicode decimal. For more information about the keys, please check virtual key codes. To produce the unicode decimal for each key, you're required to run this small code provided by chrysls to log each letter key in upper/lower case.

document.body.addEventListener('keyup', function(e){
  console.log('' + e.code.charCodeAt(e.code.length - 1) + ': ' + e.key.charCodeAt(0));
});

API

Client-side

// Property getter/setter Boolean (Disables/Enables chat input)
mp.gui.chat.disabledInput = true;
mp.gui.chat.disabledInput

// Property getter Boolean (Check if chat is open)
mp.gui.chat.enabled;

// Function to clear localPlayer's chat feed
mp.gui.chat.clear();
// Trigger chat's visibility (visible: Boolean);
mp.gui.chat.visible(visible);
/*
* msg: string
* scope: string (message's scope (Author [scope] msg))
* author: string
* authorColor: int hudColorID (https://wiki.rage.mp/index.php?title=Fonts_and_Colors) (Default: white)
*/
mp.gui.chat.sendMessage(msg, scope, author, authorColor);

/*
* Registers command locally for client.
* name: string (command name)
* arg1: command's arguement
*/

mp.gui.chat.addCommand(name, function (arg1, arg2) {
	// do whatever...
});

/*
* Removes command locally for client.
* name: string (command name)
*/

mp.gui.chat.removeCommand(name);

Server-side

/*
* Sends message to all players in server
* msg: string
* scope: string (message's scope (Author [scope] msg))
* author: string (Default: [SERVER])
* authorColor: int hudColorID (https://wiki.rage.mp/index.php?title=Fonts_and_Colors) (Default: white)
*/

mp.players.announce(msg, scope, author, authorColor);

/*
* Sends messaage to all players in specified dimension
* dimension: int
* msg: string
* scope: string (message's scope (Author [scope] msg))
* author: string
* authorColor: int hudColorID (https://wiki.rage.mp/index.php?title=Fonts_and_Colors) (Default: white)
*/

mp.players.announceInDimension(dimension, msg, scope, author, authorColor);

/*
* Sends messaage to all players in specified dimension
* position: Vector3
* range: int
* msg: string
* scope: string (message's scope (Author [scope] msg))
* author: string
* authorColor: int hudColorID (https://wiki.rage.mp/index.php?title=Fonts_and_Colors) (Default: white)
*/
mp.players.announceInRange(position, range, msg, scope, author, authorColor);

/*
* Registers commands in chat
* name: string (command name)
* player: command executer
* arg1: Arguement after command
*/

mp.events.addChatCommand(name, function (player, arg1, arg2) {
	// Do what you want...
});

/*
* Removes command from server
* name: string (command name)
*/
mp.events.removeChatCommand(name);

/*
* Sends message to all players in server
* msg: string
* scope: string (message's scope (Author [scope] msg))
* author: string
* authorColor: int hudColorID (https://wiki.rage.mp/index.php?title=Fonts_and_Colors) (Default: white)
*/

player.sendChatMessage(msg, scope, author, authorColor);

// Clears player's chat
player.clearChat();

chat-scaleform's People

Contributors

carbowix 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.