|
| 10 Feb 2017 07:46 AM |
| I have a module script that returns this: [progress: number, complete: boolean, players (object): {username (string): ###### ########## I can access complete, and players using local members = api.getPlayers().data local complete = members.complete local number = members.number HOWEVER, it has COMPLETLY slipped my mind on how to access the 'players object' SPECFICALY "userId" What I need to do is put it in a for loop and do something for each userID I cannot believe I forgot how to do this. CONSIDERING I PROGRAMED THE API. |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 07:49 AM |
Idk what it A) formated that way B) hashtagged so I will redo it
I have a module script that returns this: [progress: number, complete: boolean, players (object): {username (string): userID (num)}]
I can access complete, and players using
local members = api.getPlayers().data local complete = members.complete local number = members.number
HOWEVER, it has COMPLETLY slipped my mind on how to access the 'players object' SPECFICALY "userId" What I need to do is put it in a for loop and do something for each userID
I cannot believe I forgot how to do this. CONSIDERING I PROGRAMED THE API.
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 10 Feb 2017 09:51 AM |
for i,v in next, members do print(v.UserId) end
?
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 10:16 AM |
No I get attempt to index 'v' a number value...... waaaaaaaht.
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 11:14 AM |
i have no idea why I can print it
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 04:29 PM |
bump - BEEN SO LONG since I have done object-oriented in roblox.
|
|
|
| Report Abuse |
|
|
| |
|
|
| 10 Feb 2017 05:23 PM |
| it's been long since you've done Object-Oriented in Roblox, ## opposed to...? Lua is the only code Roblox supports. Also, what are you trying to do here, and what is the output? We're not genies here (I wish I was) |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:26 PM |
Did you really just say LUA is the only object-oriented language.
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:31 PM |
| No, I said it was the only language Roblox supports. |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:31 PM |
| And FIY, it's stylized as "Lua" |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:31 PM |
| Anyways I am gathering all userIds from the object, the output is just 'nil' local members = api.getPlayers().data (everything is in data) I can do members.players and get the NUMBER of users, but when I do members.userId it doesn't even display there is anything. It just goes nil. local count = 0 for i,v in next, members.players do count = count + 1 print(members.players.userId)<-- nil end print(count) count works, just not userId. it is coming from a module script that I cannot share as it gets things from HTTP service, but I can assure you it is sending the data in this form: [progress: number, complete: boolean, players (object): {username (string): ###### ########## progess (how many users it has gotten to), comeplete (if all the users are here.) when I get to players it bugs out. [progress: number, complete: boolean, players (object): {username (string): ###### ########## |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:32 PM |
| Anyways I am gathering all userIds from the object, the output is just 'nil' local members = api.getPlayers().data (everything is in data) I can do members.players and get the NUMBER of users, but when I do members.userId it doesn't even display there is anything. It just goes nil. local count = 0 for i,v in next, members.players do count = count + 1 print(members.players.userId)<-- nil end print(count) count works, just not userId. it is coming from a module script that I cannot share as it gets things from HTTP service, but I can assure you it is sending the data in this form: [progress: number, complete: boolean, players (object): {username (string): ###### ########## progess (how many users it has gotten to), comeplete (if all the users are here.) when I get to players it bugs out. [progress: number, complete: bool, players (object): {username (string): user id (numba)}] |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:33 PM |
Roblox new filter system, I cant. It censors and ruins my formats.
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:36 PM |
oh btw to earlier, I program outside of Roblox mostly. I am programming in roblox for a group
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:42 PM |
Anyways I am gathering all userIds from the object, the output is just 'nil' local members = api.getPlayers().data (everything is in data)
what is api? does get:Players() return an objectvalue which has a child "data?" You call functions on thing with semicolons, as opposed to normal dots (annoying ik)
I can do members.players and get the NUMBER of users, but when I do members.userId
members=what? members being plural, I assume it is some sort of table containing "members?". Does that table/objectvalue contain a child "userId"?
What you want to do is loop through the table and get the userid's of the players inside the table, as the table itself has no userid.
function getuserids(members) userids={} for i=1,#members do --loop through "members" table.insert(userids , (members[i].UserId) )--insert member's userid in table end return(userids)--return table end
print(getuserids(game.Players))--will print a memory adress for the table. for reading table contents, do something similar, looping through the table contents and reading them separately.
it doesn't even display there is anything. It just goes nil.
local count = 0 for i,v in next,members.players do --[[next,members is not right. lua only expects one argument here I think]]
count = count + 1 print(members.players.userId)-- nil end print(count)
count works, just not userId. it is coming from a module script that I cannot share as it gets things from HTTP service, but I can assure you it is sending the data in this form: [progress: number, complete: boolean, players (object): {username (string): ###### ########## progess (how many users it has gotten to), comeplete (if all the users are here.) when I get to players it bugs out. [progress: number, complete: bool, players (object): {username (string): user id (numba)}]
not sure I understand the last #### try to give me the source of the modulescript. |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:46 PM |
What I am doing is getting all active players in a group, I have a bot setup that can do this. Reading the output of the ssh I can see it is sending the data correctly, and it has the correct data.
local job = http.post('/getPlayers/make/'..group..(rank and '/'..rank or '')..'?limit='..(limit and limit or '-2')..'&online='..(online and 'true' or 'false')).data.uid local complete, response = false repeat wait(0.5) local success success, response = http.get('/getPlayers/retrieve/'..job, true) if not success and response:match('$Response was not valid json') then error(response) elseif success then complete = response.data.complete end until complete return response end
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:48 PM |
so the problem is not that the data is nil, it is there, I just cannot call it
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:53 PM |
data is structured as:
imgur
a/76Qjb
I do realize that I completely lost the concept of the table structure after looking over it again, but I haven't been in rbx.Lua in so long. Still need to figure out how to print userId
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 06:26 PM |
game.Players.SpecificPlayerHere.UserId
simple as that
I don't really understand the other script, it is obviously not Lua and can not work in Lua (do I understand correctly you have some custom service setup hooked to your game instances?) |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 06:37 PM |
I do, I guess I have to setup some sort of function that can auto insert the .PlayerName.userId
|
|
|
| Report Abuse |
|
|