Bigfootmech Posted February 28, 2021 Share Posted February 28, 2021 (edited) Does anyone know why a mod RPC command WON'T work during start up, but WILL run on a key press? Spoiler -- example modmain for a server-side mod local NAMESPACE = "MyNamespace" local RPCFake = "HOWhekDOwork" local function FakeListenerAction() print("EASILY SEARCHABLE STRING") print("What is going on!!!") end local function RegisterFakeRPCListener() AddClientModRPCHandler(NAMESPACE, RPCFake, FakeListenerAction) AddModRPCHandler(NAMESPACE, RPCFake, FakeListenerAction) end local function CallFakeRPC() SendModRPCToServer(GetModRPC(NAMESPACE, RPCFake)) SendModRPCToClient(GetClientModRPC(NAMESPACE, RPCFake), nil, "var") end RegisterFakeRPCListener() CallFakeRPC() -- ignored / doesn't work GLOBAL.TheInput:AddKeyDownHandler(string.byte("t"), function() CallFakeRPC() -- works end) Edited February 28, 2021 by Bigfootmech Link to comment Share on other sites More sharing options...
Wonderlarr Posted February 28, 2021 Share Posted February 28, 2021 @Bigfootmech I've run into this problem as well while trying to add some abilities to my mod, RPC's aren't called correctly until the client is fully loaded is what I found, and stuff like that is called just before that's the case. I could be wrong about this though, RPC's aren't my strong suit. Link to comment Share on other sites More sharing options...
penguin0616 Posted February 28, 2021 Share Posted February 28, 2021 Are you testing in a game with caves? BOTH RPCs don't work? 1 Link to comment Share on other sites More sharing options...
Bigfootmech Posted February 28, 2021 Author Share Posted February 28, 2021 (edited) 11 minutes ago, penguin0616 said: Are you testing in a game with caves? BOTH RPCs don't work? I'm testing the game with caves (going up and down to trigger client mod load) Both RPCs don't work on mod load. (hang on, let me double check for error) One of them works on pressing "t" after I load in (correct behaviour) So as Skylarr said, I'm assuming it's something to do with timing. Although as far as I can tell, it seems to be C-side, since I can't plumb TheNet So I was wondering if anyone knew more Edited February 28, 2021 by Bigfootmech Link to comment Share on other sites More sharing options...
penguin0616 Posted February 28, 2021 Share Posted February 28, 2021 (edited) RPCs generally don't get sent unless the server is able to identify the source & target. So you'd have to wait until you are loaded in. Edited February 28, 2021 by penguin0616 1 Link to comment Share on other sites More sharing options...
Bigfootmech Posted February 28, 2021 Author Share Posted February 28, 2021 Huh. There is an error in the log. [00:00:01]: Error encoding lua RPC mod namespace Link to comment Share on other sites More sharing options...
Bigfootmech Posted March 1, 2021 Author Share Posted March 1, 2021 Well, good news, and bad news :P I'm pretty sure it happens inside TheNet:SendModRPCToServer("MyNamespace", 1) I also can't find the string inside /scripts/ But there is a hit for "Error encoding lua RPC mod namespace" inside \bin\dontstarve_steam.exe:13290 and \bin\dontstarve_dedicated_server_nullrenderer.exe:12285 So, it seems to be a C-side error with "encoding mod namespace" at the time of running the mod. I'm assuming then, that the mod (or maybe ALL the mods) need to load before any ModRPCs can be sent? This is less than ideal for me, when the only time I want to send an RPC is on mod load I might already have a workaround though. Since TheNet:SendRemoteExecute() seems to work Link to comment Share on other sites More sharing options...
penguin0616 Posted March 1, 2021 Share Posted March 1, 2021 SendRemoteExecute is how the console sends commands to the Remote. It won't do anything unless you have permissions set on the server. 1 Link to comment Share on other sites More sharing options...
Bigfootmech Posted March 1, 2021 Author Share Posted March 1, 2021 (edited) Wait, I was looking at the wrong place >.< There's no point looking at server-side startup. The call is actually sent by the client. Then I'm seeing a "Error decoding lua RPC sender" server side (even though SendRemoteExecute works fine to my local hosting, and shows userID) Still seems to be C-side though 46 minutes ago, penguin0616 said: SendRemoteExecute is how the console sends commands to the Remote. It won't do anything unless you have permissions set on the server. Ah, I was thinking I could check permissions on the command myself. Guess not. There also might be the option of something like DoTaskInTime Alternatively, detect an event server-side for end of migration, and start communication from there. Possibly even using Net vars (but that seems kind of horrible for sharing a long string once) I can make it work I just wanted to try make it work as "tightly" as possible Edited March 1, 2021 by Bigfootmech 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