Badandy Posted April 14, 2019 Share Posted April 14, 2019 Hi, I'm having issues getting SharedData that is set on the Server (C#) on the client (JS) with getVariable. I currently get "undefined" on the client. I have looked it up many times and now I'm here asking this question. The code below outlines the following: The client connects to the server and at this time, its setSharedData. After the command testData is used, it triggers a client side event that fires and prints out the sharedData value. Here is my code: Server Side (C#): public void OnPlayerConnected(Client player) { player.SetSharedData("test", "test"); } [Command("testdata")] public void CMD_testData(Client client) { client.SendChatMessage("Testing Data on Client!"); client.TriggerEvent("showData"); } Client Side (JS): function showData() { let vartest = mp.players.local.getVariable('test'); mp.gui.chat.push("DATA TEST: "+vartest); } mp.events.add('showData',showData); Any help anyone can give is appreciated. Thank you. Link to comment Share on other sites More sharing options...
Badandy Posted April 15, 2019 Author Share Posted April 15, 2019 After further analysis, I have found out that the C# function "setSharedData" isn't putting data into the key that I specified. I tested that by outputting it on the server and also using "hasSharedData" with that returning false. I was scripting the server side initially with JS but moved the JS files out of the directory. Am I missing anything? Link to comment Share on other sites More sharing options...
Badandy Posted April 15, 2019 Author Share Posted April 15, 2019 After reinstalling the bridge and using the updater.exe again, it now works. Must of been an issue on my part when I set up the bridge. Thank you 1 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