export default function worldInteraction() {
    var atmBrowser: BrowserMp;

    //INTERACT: ATM
    mp.events.add("SERVER:ShowAtmUi", (atmId) => {
        mp.gui.cursor.show(true, true);
        mp.gui.chat.show(false);
        mp.game.ui.displayHud(false);
        mp.game.ui.displayRadar(false);

        atmBrowser = mp.browsers.new("package://assets/html/atm/index.html");
    });

    mp.events.add("CEF:closeATM", () => {
        mp.gui.cursor.show(false, false);
        mp.gui.chat.show(true);
        mp.game.ui.displayHud(true);
        mp.game.ui.displayRadar(true);

        atmBrowser.destroy();
    });

    mp.events.add("CEF:atmAction", (site, inputField1, inputField2) => {

        mp.events.callRemote("CLIENT:ATM_MANAGER:ATM_ACTION", site, inputField1, inputField2);      
    });

    mp.events.add("SERVER:WORLD_INTERACTION:ATM_ERROR", (errorId, p2) => {
        switch (errorId) {

            //Nicht genügend BALANCE im ATM
            case 0:
                atmBrowser.execute(`noBalance();`);
                break;
        }
    });
} 