Jump to content

When I attempt to make a server call from CEF, method is called twice


Recommended Posts

Posted (edited)

Hi All,

I am using VUE and when i do a on click to make a call to MP event it cllas twice. This is a pain as if i want to spawn a car in from cef, it spawns twice. 

 

I have tried all the normal onclick.prevent / stop to no avail.

I wouldnt of thought it was anything to do with my modal i have this issue on all my CEFS

 

 

Many thanks

Here is my code:

  <div class="modal-footer">
                <slot name="footer">
                  <button class="modal-default-button modal--confirm"  @click.prevent="$emit('buy-selected-veh')">
                    CONFIRM
                  </button>
                  <button class="modal-default-button modal--cancel" @click="$emit('close')">
                     Cancel
                   </button>
                </slot>
              </div>
 
 
...............................................................................
<modal v-if="showModal" @close="showModal = false"  @buy-selected-veh="purchaseSelectedVeh(currentItem)">
                        <!--
                      you can use custom content here to overwrite
                      default content
                    -->
 
                   
                        <h3 slot="header">PURCHASE CONFIRMATION</h3>
                           <slot slot="body">
                             Are you sure you want to purchase <b>{{currentItem.name}}</b> for ${{currentItem.price.toLocaleString('en', {useGrouping:true})}}?
                           </slot>
 
                      </modal>
 
------------------------------------------
const app = new Vue({
    el: "#app",
    store : [],
   data: {
      showModal: false,
      currentItem: { price: 50000, name: 'Truffade Thrax', imgURL: "https://static.wikia.nocookie.net/gtawiki/images/5/55/Thrax-GTAO-front.png" },
        
      items: [
        { price: 50000, name: 'Truffade Thrax', imgURL: "https://static.wikia.nocookie.net/gtawiki/images/5/55/Thrax-GTAO-front.png" },
    { price: 30000, name: 'Bravado Banshee 900R', imgURL: "https://static.wikia.nocookie.net/gtawiki/images/0/0b/Banshee900R-GTAO-front.png" },
       { price: 10000, name: 'kawaski H2', imgURL: "https://img.gta5-mods.com/q85-w800/images/kawasaki-ninja-h2-h2r-add-on-tunable/84c2cb-GTA5%202016-10-23%2015-44-31-70.jpg" },
      { price: 80000, name: 'Porsche 911 GT3 RS', imgURL: "https://img.gta5-mods.com/q95/images/2019-porsche-911-gt3-rs-add-on/efd5be-9.jpg" },
          { price: 20000, name: 'Ford Focus RS', imgURL: "https://img.gta5-mods.com/q95/images/ford-focus-rs-2017-add-on-replace-tuning-template-multi-livery/66172e-GTA5%2016-04-2017%2003-28-50-191.jpg" },
      ]
   
    },
 
    methods: {
      loadItems: function (str) {
        items = JSON.parse(str);
        mp.trigger("cMisc-CallServerEvent", "LOG", str);
 
      },
      exit: function () {
        mp.trigger("cCloseCef");
 
      },
      purchaseItemConfirmation: function(item){
         this.showModal = true;
         this.currentItem = item;
 
      },
      purchaseSelectedVeh: function(item){
 
       
        mp.trigger("cMisc-CallServerEvent", "purchaseVehicle", JSON.stringify(item));
 
         mp.trigger("cCloseCef");
      }
    },
   
  });
 
 
 
 
 
 
 
Edited by MICHAEL08
Posted

Create an anti-spam like system for every button, register only 1 press per 0.5 sec or something like that, I had issue with mouse event being called twice, maybe try with @mousedown or @mouseup

  • 3 weeks later...
Posted

Actually, I noticed that happens when you have nested mp.events.add() calls. Dont put one handler into another, keep them always at the root level

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...