How do I convert the userdata gloabl.BasePlayer.activePlayerList to a table?
As what I want to do, seems like it doesn't work with userdata like this.
Code:local targetPlayer = global.BasePlayer.activePlayerList[math.random(1, #global.BasePlayer.activePlayerList)]
Solved Convert userdata global.BasePlayer.activePlayerList to a table
Discussion in 'Rust Development' started by LaserHydra, Apr 25, 2015.
-
For what you are attempting to do there you really don't need the activePlayerList to be a table. The list is a List<BasePlayer> (more information on lists: https://msdn.microsoft.com/en-us/library/6sh2ey19(v=vs.110).aspx). This list uses a numeric key for all the values so you can easily get a BasePlayer from the list by specifying a key between square brackets.
Code:local target = global.BasePlayer.activePlayerList[0]
Code:local onlinePlayerCount = global.BasePlayer.activePlayerList.Count
-
Well im not, propably I failed like hell but i've come up with this:
Code:local target = global.BasePlayer.activePlayerList[0] local onlinePlayerCount = global.BasePlayer.activePlayerList.Count local targetPlayer = target[math.random(1, onlinePlayerCount)]
-
I thought you said you knew VB.. Yeah I'm just going to Nope out of this one.
-
[DOUBLEPOST=1429965921][/DOUBLEPOST]