1. 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)]
    
     
  2. 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]
    As it is a List and because of the methods that were made available through the lua bindings you can use the property fields and methods that are available for Lists in C#. This way you can just get the amount of values in that list by getting the Count property:
    Code:
    local onlinePlayerCount = global.BasePlayer.activePlayerList.Count
    Now that you know this you should be able to fix the code you have posted originally and rewrite that to something that works with a minor modification without using a table :)
     
  3. 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)]
    but now it only gives me the number of the user in the list (i guess). What I would need is the displayName. Let me guess, I failed? ^_^
     
  4. I thought you said you knew VB.. Yeah I'm just going to Nope out of this one.
     
  5. I said I startet with VB and I kinda knew some stuff. But its also some time ago when I worked with it last time so well whatever ^^
    [DOUBLEPOST=1429965921][/DOUBLEPOST]
    okay nevermind, I got it. Damn stupid failure.