Giter Site home page Giter Site logo

callbacks's People

Contributors

itsxscrubz avatar

Watchers

 avatar

callbacks's Issues

Callbacks:TriggerCallback inside a RegisterNUICallback with a cb answer only work once

If you put a Callbacks:TriggerCallback INSIDE a RegisterNUICallback, the cb for the NUI will only end on the first occurence.

So if i triger registerNUI call back, it triger the callback:triger call back DO SOME STUFF THEN CB(DATA)

ON THE SECOND REGISTERNUICALLBACK it triger the callback:triger call back DO SOME STUFF AND NO MORE CB(DATA) it dont work.

I must not have at least 1 brain cell...

I can't figure out why I cannot get this to work. I am missing something simple I am sure...

I will admit I am new to LUA and new to Redm/Fivem framework (Python / Ruby guy).

First, I have the resource added and started in the resource.cfg
At the top of my client and server I have placed this:
Callbacks = exports['callbacks']:FetchCallbacks()

I have a RegisterNUICallback() that calls the Trigger (I assumed this could work very similar to the register command example)

  local storeprice
 print("REGISTER NUI CALLBACK IS REACHED")
print("STORE ID IN NUI CALLBACK IS: ", store_id)
  Callbacks:TriggerCallback('get_store_cost', function(store_id)
    print("DATA SENT TO TRIGGER CALLBACK: ", store_id)
  end, storeprice)
  cb({price = storeprice})
end)

The two print statements before the Callbacks:TriggerCallback work. The third inside the Callbacks:TriggerCallback never gets called.

And on my Server side I have this:

  Callbacks:RegisterCallback('get_store_cost', function(idstore, source, cb)
    print("Made it here")
    MySQL.Async.fetchAll('select price, store_bank from stores WHERE store_id=@id_store', 
    {
      ['id_store'] = idstore
    }, function(results)
      if #results > 0 then 
        total_price = round_monies(results[1].price + results[1].store_bank)
        cb(total_price)
      end
    end)
  end)
end
registerCallbacks()

The print "Made it here" never gets executed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.