Wonderlarr Posted December 13, 2020 Share Posted December 13, 2020 (edited) After following this guide on RPC's, I successfully managed to get traditional RPC's implemented in my mod, however I'm having trouble with Client RPC's. I need to have code that is only executed on the client. This is what I'm using to get it working so far, and I bet I did something wrong. local function ClientPrintfn() print("CLIENT test") end AddClientModRPCHandler("hkr_RPC", "ClientPrint", ClientPrintfn) local function SendTestRPC() local userids = {} for i, player in ipairs(AllPlayers) do table.insert(userids, player.userid) end SendModRPCToClient(GetClientModRPC("hkr_RPC", "ClientPrint"), userids, nil) end GLOBAL.TheInput:AddKeyDownHandler(108, SendTestRPC) This is contained in my modmain, and that keydown handler is just a way to debug it, it would normally get called from an event listener. My problem is that my code seems to be doing absolutely nothing, and i think it's occuring within SendTestRPC(), specifcally when trying to get all the players. Is that line outdated? Edited December 13, 2020 by TheSkylarr wasn't clear Link to comment Share on other sites More sharing options...
penguin0616 Posted December 13, 2020 Share Posted December 13, 2020 Check your log files for RPC errors. They are usually silent and don't show up as an in-game error, they just go straight to the log. 1 Link to comment Share on other sites More sharing options...
Developer zarklord_klei Posted December 14, 2020 Developer Share Posted December 14, 2020 Client RPCs go from the server to the client, the server doesn't know what keys your pressing, so it can't fire the key down event. 1 1 1 Link to comment Share on other sites More sharing options...
Wonderlarr Posted December 15, 2020 Author Share Posted December 15, 2020 22 hours ago, zarklord_klei said: Client RPCs go from the server to the client, the server doesn't know what keys your pressing, so it can't fire the key down event. Really? I figured it worked so that the Client sent the keypress to the server, and that keypress fires it, thanks for clearing this up for me! 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