Jump to content

Sorginator

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by Sorginator

  1. Hey guys,

    I tried to trigger an event from CEF to client-side Javascript. It worked, but the event triggers 4x rather than just 1x.
    At the CEF apparently, not, because that triggers only 1x, I have tested.
    Nevertheless, 4 chatbox outputs arrive when I execute the following code...
    Does anyone have any idea what this could be?

    HTML & JS CEF

    <head>
    	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    	<link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    	<div class="all">
    		<div class="Testdiv" id="TestDiv1"></div>
          	<script>
              document.getElementById("TestDiv1").addEventListener('click', function (event) {
                mp.trigger('testEvent1', event);
                var elem = document.getElementById("TestDiv1");
                elem.parentNode.removeChild(elem);
              });
         	</script>
    	</div>
    </body>

    Clientside Script

    mp.events.add('testEvent1', (testArg1) => {
    	mp.gui.chat.push("Testtext: " + testArg1);
    });

    I also tried an alternative spelling in the script part of the HTML / Javascript code

    $('#Testdiv').click(() => {
      mp.trigger('testEvent1', "Blabla");
    });

     

     

  2. Hey guys,

    I tried to pass an array to a function in the cef, but it failed.

    Test Code:

    // Javascript
    let array = ["Test1", "Test2"];
    mp.keys.bind(0x59, true, function() {
    	browser = mp.browsers.new("package://test/cef/index.html");
    	browser.execute('testFunc("' + array + '")');
    });
    
    //CEF
    function testFunc(testArray) {
        var testDiv = document.createElement("div");
    	testDiv.className='tttTt';
    	testDiv.id = "testDiv1";
    	testDiv.innerText = testArray[0];
    }

     

    I've also tried the following code:

    // Javascript
    let array = ["Test1", "Test2"];
    mp.keys.bind(0x59, true, function() {
    	browser = mp.browsers.new("package://test/cef/index.html");
        let jsonStrng = JSON.stringify(array);
    	browser.execute('testFunc("' + jsonStrng + '")');
    });
    
    //CEF
    function testFunc(testArrayJSON) {
      	let testArray = JSON.parse(testArrayJSON);
        var testDiv = document.createElement("div");
    	testDiv.className='tttTt';
    	testDiv.id = "testDiv1";
    	testDiv.innerText = testArray[0];
    }

     

    Can you tell me what I did wrong or/and how to pass arrays from Javascript to the CEF?

  3. At first thanks for your replie @MrPancakers :)

    I've tried to use this function with the following code:

    mp.events.add("playerEnterVehicle", (player, vehicle, seat) => {
    	if (player = mp.players.local) {
    		vehicle.setInvincible(false);
    	}
    });

    By entering a vehicle I get an error, that "setInvinvible" is not a function, so i tried the following:

    mp.events.add("playerEnterVehicle", (player, vehicle, seat) => {
    	if (player = mp.players.local) {
    		mp.gui.chat.push(vehicle.setInvincible + "")
    	}
    });

    After entering a vehicle another time, the chat says "undefined".

    Did I write something wrong, or where is my failure?

  4. Hello,

    I've a problem with the vehicle system an no idea how to fix it.

    When I spawn a vehicle, it doesn't get any damage, but I get the first time into the vehicle, it can get damage. However, when I get out again, I can do what I want, it gets no more damage (only visually, it will still got damaged). Even a renewed entry brings nothing.
    The effect always occurs after the first time getting out of the vehicle.

    Every player on my server has the same Problem, so it's not a problem of my client (only) i think.

    Is there a way to fix it?

×
×
  • Create New...