itsxscrubz / callbacks Goto Github PK
View Code? Open in Web Editor NEWNextGen Callbacks
NextGen Callbacks
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 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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.