Jump to content

State Valentin

Members
  • Posts

    23
  • Joined

  • Last visited

Posts posted by State Valentin

  1. I'm having a chat cef interface.

    When a player starts spamming in the chat (Press T > Types something > Press Enter) 

     

    Sometimes this bug happens:

    mp.events.add('disableChatInput', () => {

    mp.gui.cursor.show(false, false);

    interfaceOpened = false; // => interfaceOpened is never set to false. keeps being true. Why ? 

    });

    Vue.js code:

        sendMessage: function() {
    
          let value = $("#text").val().trim();
    
          if (value.length > 0) {
    
            if (value[0] == "/") {
    
              value = value.substr(1);
    
              mp.invoke("command", value);
    
            }
    
            else {
    
              mp.invoke("chatMessage", value);
    
            }
    
            this.oldMessage = $("#text").val();
    
          }
    
          mp.trigger("disableChatInput");
    
          this.toggleInput(false);
    
          $("#text").val('');
    
        }

     

    Any idea what to do ? 

     

    Client event: 

    mp.events.add('disableChatInput', () => {
    
    mp.gui.cursor.show(false, false);
    
    interfaceOpened = false;
    
    });

     

    I can't let this bug unfixed. The player remains with the cursor on the screen and interface opened = true. I'm thinking maybe the event is not reaching at all ? 

    I've tested this theory.  Had a small notify with numbers to let me know if the number on the chat is the same as the notify send from the client event.

    The result: The event is called. So i'm thinking maybe you can't spam the cursor show function ? 

  2. Hello, i want to know where it's my problem ? I can't make the voice chat work. 

    My code it's the following:

     

     

     
    
    mp.events.add('playerJoin', player => {
    
      mp.players.forEach((_player) => {
          if(player == _player) return false;
          player.disableVoiceTo(_player);
      });
    
    });
    
    mp.events.add('toggleVoice', player => {
      if(player.loggedIn == true) {
        if(player.vars.voice.status == true) {
          player.vars.voice.status = false;
        } 
        else {
          player.vars.voice.status = true;
        }
        player.call('setVoiceToggle', [player.vars.voice.status]);
      }
    });
    
    mp.events.add('startTalking', player => {
      if(player.loggedIn == true) {
        if(player.vars.voice.channel == 0)
        {
          mp.players.forEachInRange(player.position, 10, (_player) => { 
              //if(player == _player) return false; for testing.
              if(_player.vars.voice.channel != 0) return false;
              if(_player.vars.voice.status != true) return false;
              player.enableVoiceTo(_player);
              console.log('voice found');
            }
          );
        }
        else if(player.vars.voice.channel == 1) // walkie talkie in the future
        {
          mp.players.forEach((_player) => {
              if(player == _player) return false;
              if(_player.vars.voice.channel != 1) return false;
              if(_player.vars.voice.status != true) return false;
              player.enableVoiceTo(_player);
          });
        }
      }
    });
    
    mp.events.add('stopTalking', player => {
      if(player.loggedIn == true) {
        player.voiceListeners.forEach((listener) => {
          player.disableVoiceTo(listener);
        });
      }
    });

     

    Client-side:

    mp.keys.bind(0x58, true, function() {
      if(playerLogged == true) {
        hud.execute(`gui.hud.setMicrophoneStatus(true);`);
        mp.events.callRemote("startTalking");
        player.voiceVolume = 1.0;
      }
    });
    
    mp.keys.bind(0x58, false, function() {
      if(playerLogged == true) {
        hud.execute(`gui.hud.setMicrophoneStatus(false);`);
        mp.events.callRemote("stopTalking");
      }
    });

     

    I have this in my conf.json 

    "voice-chat" : true

     

    I can't get it, why it's not working ? Other servers are using the voice chat fine. 

    the key functions works (the set microphone status changes the color of a font awesome icon)

    And i get to 'found' in the server-side when i'm talking near someone. And also the variables are not a problem:

     

        player.vars = {
          voice: {
            status: true,
            channel: 0
          }
        }

     

  3. The result is always this:

    83jZQRx.png

    Why ? For example if i try to get into this interior:

    Regal 1 Apartment apa_v_mp_h_07_a new Vector3(-787.029, 315.7113, 217.6385);

     

    Where is my mistake ? 

     

    //client-side
    
    mp.events.add('loadInterior', (x,y,z,ipl) => {
      var interior = mp.game.interior.getInteriorAtCoords(x, y, z);
      mp.game.interior.enableInteriorProp(interior, ipl);
      mp.game.interior.refreshInterior(interior);
    });
    
    //server-side
    
    mp.events.addCommand("gotoxyz", (player, fullText, x, y, z, ipl) => {
      player.outputChatBox("You teleported.");
      player.position = new mp.Vector3(x,y,z);
      player.call('loadInterior', [x,y,z, ipl]);
      console.log('x: ' + x + ' y: ' + y + ' z: ' + z + ' ipl: ' + ipl);
    });

     

  4. Right now i'm having:

     

    var alert = { type: 'danger', message: 'works!' };

     

    in clientside i'm using:

    browser.execute("window.app.setMessage('" + data.type + "', '" + data.message + "');");

     

    because i can't use browser.execute("app.alert = " + alert);

    and in vue that's a function. 

     

    setMessage: function(type, message) {
          this.alert = {
            type: type,
            message: message
          }
        }

     

     

    So how i'm supposed to send a object into the Vue JS ? Please help.

  5. On 9/9/2018 at 1:07 PM, Armyw0w said:

    ai luat macar bacul :))?

    Nu am avut șanța să îl dau din păcate, mi-am propus că în 2019 - 2020 să îmi continui studiile. 

     

    On 10/7/2018 at 12:05 AM, FiestaZero said:

    Salut! Ce faceti? :)

     

    Bine, îmi fac timp să învăț in Weekend Koa.Js + MongoDB + Marko / Vue / Angular.

    + Seriale si astept data de 23 Octombrie sa apara primul dlc din Spider-Man (PS4)

  6. Ok so my index.js from server-side looks like this:

     

    // Loading official packages of the server
    
    const glob = require('glob');  
    const config = require('./config.js');
    
    glob ('./packages/semp/Assets/**/*.js', function(err,files) {  
      for (file of files) {
        require(file.replace('./packages/semp/','./'));
        if(config.env == 'dev') { 
          console.log(file); 
        }
      }
    });

     

    I want to do the same to the client-side packages. But how can i do that if i can't load an npm package with Vanilla JS ? Any fix to that ? 

  7. 21 hours ago, paccoderpster said:

    Server-Side (js)

    
    player.call("loadAgeBrowser", [age]);

    Client-Side

    You need to have a placeholder in your HTML. Like that:

    
    Welcome, you're now <div id='age'></div> years older.
    
    let browser = mp.browsers.new(SOME_URL);
    
    mp.events.add('loadAgeBrowser', (age) => {
    	browser.execute(`document.getElementById('age').innerHTML = ${age}`); //Call JS-Code in the Browser
    });

    I don't know why there are using Vue.js, but i'm using jQuery, since bootstrap is based upon that. But you should use whatever you want and fits your needs/skills the best.

    There is no ultimate answer to this question, but in most cases, i would say no. I use multiple sites (Intercom for apartments, player stats overview, stores, ...) in a single browser, which i destroy after every use. So when i open the overview while the store is open, the store closes and the overview opens. If i would open a second browser and close the second one, i would have to check if the first is still open, because 

    
    mp.gui.cursor.show(false, false);

    would deactivate the cursor for the first browser. I don't know how well the garbage collection works in JS, so this might could slow down the client.

    
    let browserInfo = {
        browser: null,
        active: false
    };
    
    function loadBrowser(package) {
        if (browserInfo.active)
            browserInfo.browser.destroy();
        browserInfo.browser = mp.browsers.new(package);
        browserInfo.active = true;
        mp.gui.cursor.show(true, true);
    }
    
    //Abort-Button is clicked
    mp.events.add("abort", () => {
        if (browserInfo.active)
            browserInfo.browser.destroy();
        browserInfo.active = false;
        mp.gui.cursor.show(false, false);
    });

     

     

    Thank you very much !!!!

    • Like 1
  8. So far i've understand that using player.call you can call an client-side event on a specific player but also send variables to be used on the client-side

    And then for example i can use mp.browser.new to show that player an index.html with 'Welcome, you're now X years older.'

    The question is: How can i use an variable let's say let Age = 20; on the index.html ?  

    Another questions:

    • I've seen that most people use Vue to create Interfaces, why ?
    • Is it better to use mp.browser.new once and then just hide and show interfaces that are created on one page ? (SPA) An example or some hints would be great. I have some ideas now to use browser.execute to do so .. 

     

     

     

×
×
  • Create New...