Hi there guys,
As stated before in another post, I'm working in a RPG System like the one from Oxide 1 called LES.
Consider this to my question:
For instance, I store the group name (Test), its leader SteamID and all members names. What I want now is use a command (i.e. /group) to list all data from the player's group.Code:"GroupData": { "Test": { "Leaders": "76561198000000000" "Members": [ "Member1", "Member2", "Member3" ] }
The Name of the group and the DisplayName from the leader gave me no probs, but now, I'm not sure how to concatenate the Members data in order to display it in the chat...
Any advices?
Solved Help with table content while using "for k,v in pairs()"
Discussion in 'Rust Development' started by TheRotAG, Dec 31, 2014.
-
Code:
table.concat( table, ", ")
-
Code:
for key, _ in pairs(GroupData) do for k, v in pairs(GroupData[key].Members) do print(k, v) end end
Edit: read it wrong. Bombadir has what you're looking for. -
Man... The little bit I've worked with Lua tables, it seems like once you get the hang of the format, its no problem. But figuring it out to begin with is a pain in the old arse.
-
Gonna try table.concat()
The issue here is that I want to organize everything in a single JSON file and retrieve the info without the need of calling various methods like listing all online players just to filter whose are in a group...
From what I though, just recording the group members info inside the JSON and request it through concat to display in the chat for the player must do the trick.
As ever, thank you for you patience and cooperation guys!
[DOUBLEPOST=1420144974,1420122647][/DOUBLEPOST]Table.concat() did the trick!
Now I'm need to FIND and REMOVE entries in the table as they are requested to be deleted. In this case, when a member from the group Test asks to leave the group, I need to remove it from the table Members.
I'm used to languages that works with "WHERE" methods, how to do it in LUA?
Ouch... seems like I don't even know how to ADD a new entry to the table Members after a new member joins the group...Last edited by a moderator: Jan 1, 2015 -
Add:Code:table.insert(table, member)
Code:local member = member for i=1, #table do if table[i] == member then table.remove(table, i) break end end
-
Doing it sir Bombardir!
Any way to find the SteamID form an offline player?
[DOUBLEPOST=1420151586][/DOUBLEPOST]Table Insert did the trick, gonna try http://oxidemod.org/resources/deadplayerlist.696/ for the offline players.