Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New RPC functions #43

Open
Disinterpreter opened this issue Jun 18, 2020 · 4 comments
Open

New RPC functions #43

Disinterpreter opened this issue Jun 18, 2020 · 4 comments
Labels
enhancement New feature or request future

Comments

@Disinterpreter
Copy link
Member

Disinterpreter commented Jun 18, 2020

Is your feature request related to a problem? Please describe.
If you check out my #41 you can see, I use triggers, because the current RPC system is really weird.

Describe the solution you'd like
I'd like to suggest make a new RPC system it will better, simple and it will contains documentation.

Additional context

Current realization:

amx/amx/server/util.lua

Lines 44 to 50 in dd50399

function clientCall(player, fnName, ...)
local called = triggerClientEvent(player, 'onClientCall', resourceRoot, fnName, ...)
if called == nil or called == false then
called = false --if it's null set it to false to prevent stuff like 'concatenating nil values'
end
return called
end

amx/amx/client/util.lua

Lines 55 to 63 in dd50399

server = setmetatable(
{},
{
__index = function(self, k)
self[k] = function(...) triggerServerEvent('onCall', resourceRoot, k, ...) end
return self[k]
end
}
)

@Disinterpreter Disinterpreter added enhancement New feature or request future labels Jun 18, 2020
@qaisjp
Copy link
Contributor

qaisjp commented Jun 18, 2020

What's the actual problem with the RPC system? This issue isn't really clear about what the problem is.

@Disinterpreter
Copy link
Member Author

What's the actual problem with the RPC system? This issue isn't really clear about what the problem is.

When I tried to use it. I had got a weird function behavior. For me server. did not make a call from a server (maybe I made it incorrectly). And about clientCall can we make something which can return data from client from the function? Or we will got a problem with asynchronous operations?

@qaisjp
Copy link
Contributor

qaisjp commented Jun 19, 2020

Server RPC
I think you need to do server:setPlayerName(localPlayer, "test") with the :. Did that not work?

Client RPC
clientCall -- we could implement something by incorporating coroutines. The caller would also have to specifically opt into it, as usually we don't care about the return value. We can call it client.async:stuff. But it might be a wee bit complicated as it would freeze the entire AMX virtual machine. Ideally we add stuff to mtasa-blue to expose other properties that are synced (e.g. reloading), or do the syncing ourselves.

Client RPC: doing the syncing ourselves
Since amx is statically compiled, perhaps we could do some pre-analysis to check what functions are called (if possible), so we don't sync extra information unnecessarily.

@Disinterpreter
Copy link
Member Author

Server RPC
I think you need to do server:setPlayerName(localPlayer, "test") with the :. Did that not work?

About Server RPC. I'll check it out later. Maybe it was a problem of my code.

Ideally we add stuff to mtasa-blue to expose
About Client RPC

I hope it will be important for mtasa-blue. There are few features which we must add to mtasa-blue I suppose. I can set up a label for issues which contains this depension from mtasa-blue and I'll be create issues there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request future
Projects
None yet
Development

No branches or pull requests

2 participants