|
| 26 Dec 2011 03:14 PM |
I haven't used LUA for months.
I forgot some of these functions. How can I do it?
I need a function that pick players in game and tell script the name. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
dennisvdz
|
  |
| Joined: 14 Dec 2008 |
| Total Posts: 3710 |
|
|
| 26 Dec 2011 03:19 PM |
What's LUA? Launch Under Attack?
Also, no requests. |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2011 03:20 PM |
I simply just forgot. It's not much of request.
Dennisvdz, if you do not even know LUA meaning. Then you must be a HUGE newbie forumer of this forum. |
|
|
| Report Abuse |
|
|
dennisvdz
|
  |
| Joined: 14 Dec 2008 |
| Total Posts: 3710 |
|
|
| 26 Dec 2011 03:24 PM |
I guess you don't know what LUA means, since only Lua is usual around here.
Lua website: 'Please do not write it as "LUA", which is both ugly and confusing, because then it becomes an acronym with different meanings for different people. So, please, write "Lua" right!'
And there isn't exactly a pick-random-player-name function.
local p = game.Players:GetChildren() local name = "" if #p > 0 then name = p[math.random(1,#p) end |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2011 04:48 PM |
"local p = game.Players:GetChildren() local name = "" if #p > 0 then name = p[math.random(1,#p) end"
Umg! So inefficient!
name = (Game.Players:GetPlayers())[math.random(#Game.Players.NumPlayers)] |
|
|
| Report Abuse |
|
|
dennisvdz
|
  |
| Joined: 14 Dec 2008 |
| Total Posts: 3710 |
|
|
| 26 Dec 2011 04:51 PM |
| Your code doesn't even work at all. |
|
|
| Report Abuse |
|
|
| |
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 26 Dec 2011 04:52 PM |
"#Game.Players.NumPlayers"
Nice one king, trolololol. |
|
|
| Report Abuse |
|
|
dennisvdz
|
  |
| Joined: 14 Dec 2008 |
| Total Posts: 3710 |
|
|
| 26 Dec 2011 04:52 PM |
Not really. Take a better look at your #'s.
And what happens when there are 0 players? ERRORRRRR. |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2011 04:53 PM |
* name = (Game.Players:GetPlayers())[math.random(Game.Players.NumPlayers)]
There. |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2011 04:54 PM |
| If there's 0 players, then there's nobody there to expirience the corruption... |
|
|
| Report Abuse |
|
|
dennisvdz
|
  |
| Joined: 14 Dec 2008 |
| Total Posts: 3710 |
|
|
| 26 Dec 2011 04:55 PM |
bad argument #1 to 'random' (interval is empty)
Oh dear! |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2011 04:55 PM |
| I was originally going to type #Game.Players:GetPlayers(), but then I remembered that NumPlayers existed and forgot to remove the #. Happy?? |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2011 04:55 PM |
| As I said, if there's 0 players, the game shuts down anyway. |
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 26 Dec 2011 04:56 PM |
"And what happens when there are 0 players? ERRORRRRR."
ply = Game.Players.NumPlayers) name = (ply > 0) and (Game.Players:GetPlayers())[math.random(ply)].Name or 'No players.'
There Mr. Perfection. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 26 Dec 2011 04:56 PM |
| If there's no one in the place, the script shouldn't be running. |
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 26 Dec 2011 04:56 PM |
Ermh n_ñ *
ply = Game.Players.NumPlayers name = (ply > 0) and (Game.Players:GetPlayers())[math.random(ply)].Name or 'No players.' |
|
|
| Report Abuse |
|
|
dennisvdz
|
  |
| Joined: 14 Dec 2008 |
| Total Posts: 3710 |
|
|
| 26 Dec 2011 04:56 PM |
| Can't help you prefer a core script goes boom. |
|
|
| Report Abuse |
|
|
dennisvdz
|
  |
| Joined: 14 Dec 2008 |
| Total Posts: 3710 |
|
|
| 26 Dec 2011 04:57 PM |
@Spectrumw: You waste the game's memory. :P
[insert trollface here] |
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 26 Dec 2011 04:58 PM |
@dennis Your doesn't even work, so yeah. n_n |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2011 04:58 PM |
| Your script would waste more memory. |
|
|
| Report Abuse |
|
|
dennisvdz
|
  |
| Joined: 14 Dec 2008 |
| Total Posts: 3710 |
|
|
| 26 Dec 2011 04:59 PM |
| Nah, I use local instead of global vars. |
|
|
| Report Abuse |
|
|