iSkilz Posted October 29, 2015 Share Posted October 29, 2015 I just can't figure this out... The following line will always point to host's cursor (from what I've tested), but should point to the player's cursor.local TeleportSelf = function(inst)local pt = GLOBAL.TheInput:GetWorldPosition() -- << this line...This line is inside a function for a Teleport spell, inside the modmain file for a character mod. I'm fairly certain this line is the culprit, because 'inst' is fine, but 'pt' is alway's the host's. Please, if you have any idea how to fix it, please tell me. Huge thanks in advance. Link to comment Share on other sites More sharing options...
DarkXero Posted October 29, 2015 Share Posted October 29, 2015 @iSkilz, if the server/host is running the code, then TheInput refers to the server/host. If you have your own custom action which is triggered by clicking on the screen, then the info you want will be in the act.pos of the action, and you should call TeleportSelf from there and pass the position. Link to comment Share on other sites More sharing options...
iSkilz Posted October 29, 2015 Author Share Posted October 29, 2015 @DarkXeroI could not figure it out via your suggestion.. Ok, I'm ready for a solution. Here are all the pieces of the puzzle.. modmain::...local TeleportSelf = function(inst) local pt = GLOBAL.TheInput:GetWorldPosition() -- << ...endAddModRPCHandler("homura", "teleportself", TeleportSelf)homura::...local common_postinit = function(inst) ... if not inst.components.keyhandler then inst:AddComponent("keyhandler") end inst.components.keyhandler:AddActionListener("homura", 116, "teleportself") -- [T]end...What the code currently does:- player presses T, and teleport's to host's mouse cursor. What the code should do:- player presses T, and teleport's to own mouse cursor. Thanks for taking the time to look into this. And huge thanks to anyone who can actually solve this problem. I really couldn't do it without you... Link to comment Share on other sites More sharing options...
Maris Posted October 29, 2015 Share Posted October 29, 2015 (edited) You should send X and Y of client's cursor to host via RPC.I'm still not sure how to do this, but PeterA says that it is possible by sending number variables through RPC. P.S. I had only few variants in my mod so I made a few RPC functions without numbers. P.P.S. I belive that there exists a better way to do what you want. Edited October 29, 2015 by Maris Link to comment Share on other sites More sharing options...
Kzisor Posted October 29, 2015 Share Posted October 29, 2015 @Maris, if you look at the function SendModRPCToServer you will notice the '...' as the last parameter. That parameter means that an unidentified number of additional parameters are being sent to the function.function SendModRPCToServer(id_table, ...) assert(id_table.namespace ~= nil and MOD_RPC_HANDLERS[id_table.namespace] ~= nil and MOD_RPC_HANDLERS[id_table.namespace][id_table.id] ~= nil) TheNet:SendModRPCToServer(id_table.namespace, id_table.id, ...)endThis gets transferred to the server and then pushed in the 'data' field of HandleModRPC.function HandleModRPC(sender, tick, namespace, code, data) if MOD_RPC_HANDLERS[namespace] ~= nil then local fn = MOD_RPC_HANDLERS[namespace][code] if fn ~= nil then table.insert(RPC_Queue, { fn, sender, data, tick }) else print("Invalid RPC code: ", namespace, code) end else print("Invalid RPC namespace: ", namespace, code) endendThe data variable will be an unsorted list of values that you sent along with the request from the client. Example code:AddModRPCHandler("example", "example", function(inst, ...) local additional_arguments = {...} for k, v in pairs(additional_arguments) do print("Key: ",k, " Value: ", v) endend)SendModRPCToServer(GetModRPCHandler("example", "example"), "this", "is", "this", "additional", "argument", "list", "sent")Regards,Kzisor/Ysovuka Link to comment Share on other sites More sharing options...
iSkilz Posted October 30, 2015 Author Share Posted October 30, 2015 You should send X and Y of client's cursor to host via RPC. How can I get the X and Y of clients cursor? Link to comment Share on other sites More sharing options...
DarkXero Posted October 31, 2015 Share Posted October 31, 2015 How can I get the X and Y of clients cursor? If you runlocal pt = GLOBAL.TheInput:GetWorldPosition() -- << this lineon the client side, the TheInput will refer to the client input. X = pt.x(pt.y equals 0)Y = pt.z Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now