Vennox

Chat API in 1.0 dev

Recommended Posts

so have a custom chat made using CEF and is being loaded using this:

mp.gui.chat.show(false);
let chatbox = mp.browsers.new('package://sampchat_assets/index.html');
chatbox.markAsChat();

aaand i updated to 1.1dev (directly from 0.3.7) and now it s ducked up (the T key opens that thing where u write, but i can t get any message get shown on the chat. i also see that the font is the one used in my custom chat, so i guess its something with marking it as a chat.

 

i'm aware of this ( from Make sure to implement new chat API initerface (look for default chat implementation for example) 

Quote

Make sure to implement new chat API initerface (look for default chat implementation for example)

but i couldn't find any documentation about the new API, neither the default chat impletentation to take as example (where that should be?)

 

sorry for being a dumbass

Share this post


Link to post
Share on other sites

Check the 'ui' folder in the root path where you installed RAGE.

Share this post


Link to post
Share on other sites
10 hours ago, Xabi said:

Check the 'ui' folder in the root path where you installed RAGE.

and where do i put it in the server so the players will download it like client resources

Share this post


Link to post
Share on other sites
1 hour ago, Vennox said:

and where do i put it in the server so the players will download it like client resources

You just have to copy the API from that file into your chat's javascript file, there's no need to take that file anywhere.

Share this post


Link to post
Share on other sites
Posted (edited)
On 3/25/2020 at 9:57 PM, Xabi said:

You just have to copy the API from that file into your chat's javascript file, there's no need to take that file anywhere.

not working. everytime i fire up ragemp, the file (ui>js>main.js) resets to its original. also, i have some client-side vars that depend on the CEF chat. how do i port those?

i had the file sampchat.js inside client_packages, that was loaded using require("sampchat.js"); in index.js. then, inside sampchat.js i created some variables and binds and loaded the chat in CEF (the code below)

Spoiler
global.chatOpen = false;
mp.gui.chat.show(false);
let chatbox = mp.browsers.new('package://sampchat_assets/index.html');
chatbox.markAsChat();
mp.keys.bind(0x54, true, function() {
    if(inDialog){
        //mp.gui.chat.push("t pressed");
        chatbox.execute(`$(skipchatopen())`);
    }
});

mp.keys.bind(0x0D, true, function() {
    if(inDialog){
        WindowDialog.execute(`$(onButtonClick(0))`);
    }
});

mp.keys.bind(0x1B, true, function() {
    if(inDialog){
        WindowDialog.execute(`$(onButtonClick(-1))`);
    }
});

mp.keys.bind(0x4E, true, function() {
    if(!inDialog && !chatOpen){
        mp.events.callRemote("player_action_toggle_lock_client_handle");
    }
});

mp.events.add("chatState", (enable) => {
    chatOpen = enable;
});

 

in sampchat_assets i had all the chat CEF things, that are supposed to go in the ui folder:

Spoiler

4R2tq5G.png

 

Edited by Vennox

Share this post


Link to post
Share on other sites

If your chat is 0.3.7 compatible adding this wrapper should bring 1.1 compatibility as well:


let api = {"chat:push": chatAPI.push, "chat:clear": chatAPI.clear, "chat:activate": chatAPI.activate, "chat:show": chatAPI.show}; 

for(let fn in api)
{
	mp.events.add(fn, api[fn]);
}

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.