Jump to content

[HELP] Sending the data (from DB) into CEF (front-end)


Recommended Posts

Posted (edited)

I have a function on server-side that gets an array with characters on account from DB. but I don't know how to send the data from query into CEF. Is anyone know how to do that or any links on guides?

server-side

mp.events.add("server:getCharacterList", () => {
    const characterList = characters.findAll({
        where: {
            Acc_ID: player.account.ID,
        }
    });

    async function fetchCharacters() {
        try {
            return characterList.map((char) => char.toJSON());
        } catch (error){
            console.error("Error: ", error);
        }
    }

    const charactersJSON = fetchCharacters();
});

client-side

mp.events.add('client:setCharactersList', () => {
    mp.events.add("browserDomReady", (browser) => {
        if (browser === characterSelectionBrowser) {
            mp.events.callRemote("server:getCharacterList");
        }
    });
});

Frontend, an array that should get data from DB (commented code is the format of the received data.)

// let characters = [
//    {
//        ID: 1,
//        Acc_ID: 7,
//        Firstname: 'Test',
//        Lastname: 'Test',
//        Gender: 'male',
//        IsHasAppearance: false,
//        CreatedAt: '2025-07-06',
//        TimeInGame: 0,
//        LastLogin: null,
//        Armor: null,
//        Health: 100,
//        Money: 10000,
//        PhoneNumber: null,
//        FactionID: null,
//        IsCKed: false,
//        PreviousNames: null,
//        AjailTime: null,
//        JailTime: null,
//    },
//]

let characters = [];

 

Edited by streetmeat
  • streetmeat changed the title to [HELP] Sending the data (from DB) into CEF (front-end)

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.
×
×
  • Create New...