I would use this same function in js
Can someone help me ?Code:Interface.GetMod().DataFileSystem.GetDatafile("Hunt_Data");
Reading datafile? (JS)
Discussion in 'Rust Development' started by xandy3_sjb, Jan 23, 2016.
-
Wulf Community Admin
See the API docs: Rust.
-
ok, to convert the json , I'm not finding itCode:
data.GetData("exemple"); -
Wulf Community Admin
The datafile is already JSON, why does it need to be converted? -
I can not read the array that is inside this file "exemple"
-
Wulf Community Admin
What is your current code? You can take a look at some .js plugins that use it:
-
my code
playerList.jsonCode:var ListInfo = { Title : "ListInfo", Author : "WilyWork", Version : V(0, 0, 1), Description : "list info all players", Init: function() { var playerList = data.GetData("playerList"); if(playerList){ playerList.forEach(function(player){ print(player.name); print(player.city); }); }else{ print("playerList undefined!"); } } }
Code:{ "76561197960383027": { "city": "Salvador", "name": "VimDM4" }, "76561197960409264": { "city": "Salvador", "name": "Rafaliw" }, "76561197960423352": { "city": "Salvador", "name": "Plaksnor" } } -
Wulf Community Admin
JavaScript, not C#.
-
My bad
