Next time, do try to properly use formatted text. Thing that you sent here is a pain to read. Anyway.
You got one thing wrong, you are returning an function, but not the one you want.
For now(I’ll use C# name), function you are calling is void. It does not return anything.
You know why? Because ESX.TriggerServerCallback uses function as its second parameter.
To properly return given callback try this, use Citizen.CreateThread or CreateThread to call the function.
function Test()
local retval
ESX.TriggerServerCallback('Test', function(value)
retval = value
end)
while not retval do
Citizen.Wait(10)
end
return retval
end
Citizen.CreateThread(function()
print(Test())
end)
This example here will return callback value as soon as its available. You must be aware that until value is returned, Thread won’t be executed further until function has returned.
You’ve removed 3 lines of code and replaced values with other types of functions. If It works the nothing stops anyone from using it. But goodluck to new people down there trying to understand it. (I’m not against using other ways to achieve the same result, but there is a major difference between the first and second example. Second not so simple, at least in way of explaining to some major beginner.)