pitermcflebor / pmc-callbacks Goto Github PK
View Code? Open in Web Editor NEWFiveM server-client | client-server callbacks system
License: MIT License
FiveM server-client | client-server callbacks system
License: MIT License
RegisterCommand("testnew", function(source, args, rawCommand)
exports['pmc-callbacks']:TriggerServerCallback {
eventName = 'Lumberjack:server:secrettoken',
args = {'test'},
timeout = 5000,
timedout = function(result)
print('timed out')
end,
callback = function(result)
print('gotcha', result)
end
}
end, false)
(nil stack trace) SCRIPT ERROR: error object is not a string
How to fix this? I get it without any traces to derive the origin of the error
I get this error
[ script:Test] SCRIPT ERROR: attempt to get length of a nil value
[ script:Test] > handler (@pmc-callbacks/import.lua:57)
This is my code
-- Client
RegisterNUICallback('test:nuiCallback', function (args, cb)
local data = TriggerServerCallback {
eventName = 'test:serverCallback'
}
cb({ data = data })
end)
-- Server
RegisterServerCallback {
eventName = 'test:serverCallback',
eventCallback = function(source, args)
return 'Test Data'
end
}
Hey, so Im using the example. And so im having an issue with it,
script.js:
function checkPlate(plateNumber) { plateNumber = "hey"; $.post("http://mart/checkplatemaaaaal"); }
client.lua:
RegisterNUICallback('checkplatemaaaaal', function() TriggerServerCallback { eventName = 'mart:testingAwesomeCallback', args = { 'some', 'args', 'here' }, callback = function(result) print('gotcha', result) end } end)
server.lua:
RegisterServerCallback { eventName = 'mart:testingAwesomeCallback', eventCallback = function(source, ...) return 'return something' end }
nothing gets printed, I tried everything I could.
i'd appreciate if someone could provide me a working example.
I have two resources.
I want to trigger server callback of resource 2 from client side of resource 1.
When I do so, it shows me an error:
Error loading script @resource-2/server.lua in resource resource-1: @resource-2/server.lua:31: attempt to call a nil value (global 'RegisterServerCallback')
RegisterServerCallback {
eventName = 'somename',
eventCallback = function(source)
local player = source
local funcres = somefunction(player)
local result = 0
if something == true then
result = funcres
else
result = 0
end
return result
end
}
local result = TriggerServerCallback {
eventName = 'somename',
args = {'none'}
}
There is an undocumented 3rd parameter Timeout which needs to be set otherwise the request fails.
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.