shawnyg
|
  |
| Joined: 21 Apr 2011 |
| Total Posts: 1428 |
|
|
| 03 Aug 2013 10:52 AM |
| I'm trying to figure out how to make a script that finds out who has the most points... Like Their name is in a gui and a value is in it, but after a certain number of seconds, HOW WOULD I FIND OUT WHO HAS THE MOST!? |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2013 11:04 AM |
| Iterate through players... If their value is greater than all the rest, THEY HAVE THE MOST. |
|
|
| Report Abuse |
|
|
shawnyg
|
  |
| Joined: 21 Apr 2011 |
| Total Posts: 1428 |
|
|
| 03 Aug 2013 11:06 AM |
| Like... script please? I don't want to do if name.value>nam.value and blahblahblah |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2013 11:08 AM |
PLAYER = NIL SCORE = ZERO for VARS in ITERATOR, TABLE do if PLAYERS SCORE > SCORE then SCORE = PLAYERS SCORE PLAYER = THE CURRENT PLAYER end end PRINT(PLAYER HAS THE MOST POINTS)
Now make it properly ;) |
|
|
| Report Abuse |
|
|
shawnyg
|
  |
| Joined: 21 Apr 2011 |
| Total Posts: 1428 |
|
| |
|
|
| 03 Aug 2013 11:13 AM |
| You can script, you make it. This is not free models, you know. |
|
|
| Report Abuse |
|
|
Vector2D
|
  |
| Joined: 11 May 2013 |
| Total Posts: 195 |
|
|
| 03 Aug 2013 11:15 AM |
local player, score = 0;
for _, v in pairs(game:GetService('Players'):GetPlayers()) if (v.leaderstats.Points > score) then score = v.leaderstats.Points; player = v.Name; end; end; |
|
|
| Report Abuse |
|
|
Vector2D
|
  |
| Joined: 11 May 2013 |
| Total Posts: 195 |
|
|
| 03 Aug 2013 11:20 AM |
@shawnyg Even though you were being sarcastic, that *was* actually helpful. It is the most efficient way to do what you are asking for, and you didn't really have to do anything to make it actually work. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2013 11:21 AM |
| I support independant thought over just giving out code, it helps them learn. |
|
|
| Report Abuse |
|
|
Vector2D
|
  |
| Joined: 11 May 2013 |
| Total Posts: 195 |
|
|
| 03 Aug 2013 11:24 AM |
@Nu99 If they read your pseudocode, I am sure they would understand how it works. If not, then I wasted all of a minute replying to just another person who wants to peruse the art of scripting, but doesn't do anything to reach the goal. This is pretty BASIC (hehe, puns), anyways. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2013 11:25 AM |
Beginners Assisted Systematic Input Code?
What DOES BASIC stand for? |
|
|
| Report Abuse |
|
|
Vector2D
|
  |
| Joined: 11 May 2013 |
| Total Posts: 195 |
|
|
| 03 Aug 2013 11:29 AM |
Close.
Beginners' All-purpose Symbolic Instruction Code |
|
|
| Report Abuse |
|
|
shawnyg
|
  |
| Joined: 21 Apr 2011 |
| Total Posts: 1428 |
|
|
| 03 Aug 2013 12:21 PM |
| I AM a scripter... I just wanted to know how I could do the way I thought of, but shorter. |
|
|
| Report Abuse |
|
|
shawnyg
|
  |
| Joined: 21 Apr 2011 |
| Total Posts: 1428 |
|
|
| 03 Aug 2013 12:26 PM |
I'm not saying to go in 'Players'.. The value is in a gui and it has the players name in a text button and the value is under it.. Here's script I have so you know what I mean..
wait(1) p = game.Players:GetChildren() for i = 1, #p do local find = script.Parent.plist:findFirstChild(i) if find ~= nil then find.Text = p[i].Name find.TextColor = p[i].TeamColor end end
function opa(pa) p = game.Players:GetChildren() for i = 1, #p do local find = script.Parent.plist:findFirstChild(i) if find ~= nil then find.Text = p[i].Name find.TextColor = p[i].TeamColor end end end
function opr(pr) p = game.Players:GetChildren() for i = 1, #p do local find = script.Parent.plist:findFirstChild(i) if find ~= nil then find.Text = p[i].Name find.TextColor = p[i].TeamColor end end end
game.Players.PlayerAdded:connect(opa) game.Players.ChildRemoved:connect(opr)
I also have a value under 1,2,3,4 etc.. (1,2,3,4 or the button names.) I have a script there for when you click a button, it adds one point to the value. How would I make a script that tells me which value is biggest? |
|
|
| Report Abuse |
|
|
Vector2D
|
  |
| Joined: 11 May 2013 |
| Total Posts: 195 |
|
|
| 03 Aug 2013 12:30 PM |
| I gave you a script which is the most efficient you can get. Edit it, 'scripter'. |
|
|
| Report Abuse |
|
|
Absurdism
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 2568 |
|
|
| 03 Aug 2013 12:35 PM |
Efficiency is a virtue.
values = {} player = {} for _,v in pairs(Game.Players:GetPlayers()) do table.insert(player, v.Name) table.insert(values, v.leaderstats.Points.Value) end iterationMax = math.max(unpack(values)) print(player[iterationMax].." has the most points.") |
|
|
| Report Abuse |
|
|
Absurdism
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 2568 |
|
|
| 03 Aug 2013 12:36 PM |
Ah. Late post. Use Vector2D's. I make nonsensical table variables, whereas his is much more efficient. |
|
|
| Report Abuse |
|
|
Vector2D
|
  |
| Joined: 11 May 2013 |
| Total Posts: 195 |
|
|
| 03 Aug 2013 12:55 PM |
@Absurdism Would unpacking a table, whose iterations are %playername% and their values are the points of said player, pose an issue? |
|
|
| Report Abuse |
|
|
Absurdism
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 2568 |
|
|
| 03 Aug 2013 01:16 PM |
| Of course not. I was trying to think of an effective way. Yours works efficiently, but mine can be a bit more useful depending on the situation. |
|
|
| Report Abuse |
|
|
Vector2D
|
  |
| Joined: 11 May 2013 |
| Total Posts: 195 |
|
|
| 03 Aug 2013 01:21 PM |
@Absurdism I try to go for usefulness, most times, but an efficient script can always be adapted. |
|
|
| Report Abuse |
|
|
shawnyg
|
  |
| Joined: 21 Apr 2011 |
| Total Posts: 1428 |
|
|
| 03 Aug 2013 09:33 PM |
| @Vector, Last time I checked, this is Scripting Helpers... not here's a script now edit it.. |
|
|
| Report Abuse |
|
|
shawnyg
|
  |
| Joined: 21 Apr 2011 |
| Total Posts: 1428 |
|
|
| 03 Aug 2013 09:55 PM |
| Could someone make it how I descripbed it the first time.. |
|
|
| Report Abuse |
|
|
Vector2D
|
  |
| Joined: 11 May 2013 |
| Total Posts: 195 |
|
|
| 03 Aug 2013 11:12 PM |
| I did help you. If you lack the intelligence to finish what I've given you, then you don't deserve that. |
|
|
| Report Abuse |
|
|
shawnyg
|
  |
| Joined: 21 Apr 2011 |
| Total Posts: 1428 |
|
| |
|