Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 11 Sep 2014 10:20 PM |
If your not advanced then return false end Script: local playerCheckpoints = {} _G. custom = {} while _G. players==nil do wait() end local map = game.Workspace[game.Lighting.Stats.MapValue.Value] for i,v in pairs(_G. players) do playerCheckpoints[v]=1 end game:GetService("Players").PlayerRemoving:connect(function(player) playerCheckpoints[player] = nil end) for i,v in pairs(game.Players:GetPlayers()) do v.Character.Humanoid.Died:connect(function() playerCheckpoints[v]=nil end) end
local function ProjectToLine(point, lineOrigin, lineGoto) local dir = (lineGoto - lineOrigin).unit local objectSpacePoint = point - lineOrigin return lineOrigin + dir * dir:Dot(objectSpacePoint) end
local connections = {}
local function sortPositions(a, b) return a[2] > b[2] end local function GetPositions() highest=12 local playerPositions = {} local numCheckpoints = 0 for _, v in pairs(connections) do v:disconnect() end for _, child in pairs(map:GetChildren()) do if child.Name:match("^Check%d+$") then numCheckpoints = numCheckpoints + 1 table.insert(connections, child.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then playerCheckpoints[player] = tonumber(child.Name:sub(6)) end end)) end end if numCheckpoints < 2 then error("Less than two checkpoints exist") end for player, checkpoint in pairs(playerCheckpoints) do -- Declarations and checks for nils local lastCheckpoint = map:FindFirstChild("Check" .. checkpoint) local lap = player:WaitForChild("Laps") if not lastCheckpoint then error("Checkpoint Part #" .. checkpoint .. " not found") end local nextCheckpoint = map:FindFirstChild("Check" .. checkpoint + 1) or map:FindFirstChild("Check1") if not nextCheckpoint then error("Checkpoint Part #" .. checkpoint + 1 .. " not found") end local character = player.Character if not character then warn(player.Name .. "'s Character is nil") else local torso = character:FindFirstChild("Torso") if not torso then warn(player.Name .. " has no Torso") else local vec = nextCheckpoint.Position - lastCheckpoint.Position local projectedPos = ProjectToLine(torso.Position, lastCheckpoint.Position, nextCheckpoint.Position) if game.Lighting.Players[player.Name].FinishPlace.Value==0 then table.insert(playerPositions, {player, checkpoint - (nextCheckpoint.Position - projectedPos).magnitude / vec.magnitude}) else table.insert(playerPositions, {player,checkpoint - (nextCheckpoint.Position - projectedPos).magnitude / vec.magnitude}) highest=highest-1 end end end end table.sort(playerPositions, sortPositions) local outTable = {} for index, value in ipairs(playerPositions) do table.insert(outTable, value[1]) end return outTable end
while wait(0.5) do local places = GetPositions() for i = 1, #places do print(i .. " - " .. places[i].Name) end for i,v in pairs(places) do _G. custom[v]=i end end
Now I have a value in each player called "Lap", and I want something like this: if player lap 2 and player2 lap3 then player2 is 1st
qq Help |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 11 Sep 2014 10:24 PM |
Lol, 'advanced'.
And if you're going to supply a 100 line script please do include an output. |
|
|
| Report Abuse |
|
|
|
| 11 Sep 2014 10:28 PM |
| Posting a bunch of code and asking for a solution is not going to work. At the very least you need to explain the code with comments or something. |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 11 Sep 2014 10:28 PM |
| Well true dat, except this isn't a "error". But really a idea on how to add laps to work with my system. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 11 Sep 2014 10:34 PM |
Well figure out at least what you'd need to do and then come back again asking how, with the section of code that you need that's not 100+ lines long, if you don't understand it.
Posting a huge code and asking us to add something to it is almost scamming. Please figure out what to do then Elaborate on what you need help with. |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 11 Sep 2014 10:36 PM |
| Let me explain, I don't want you to edit the code. I'm asking ideas on making laps compatible to this script. And I understand this since I wrote it. |
|
|
| Report Abuse |
|
|
|
| 11 Sep 2014 10:38 PM |
| Narrow down the error with prints inside the if statements |
|
|
| Report Abuse |
|
|
|
| 11 Sep 2014 10:39 PM |
| But we don't understand it because we didn't write it, so it's hard for us to then give you code that's compatible with it. Not trying to sound harsh or anything, but it's just difficult to do. |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 11 Sep 2014 10:44 PM |
| I'm sorry, looks like I don't belong here. I'll stop bothering you guys! |
|
|
| Report Abuse |
|
|
|
| 11 Sep 2014 10:45 PM |
"If your not advanced then return false end"
you're* return false to what we're not in a function
gramer plez screpting knowldg pliz |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 11 Sep 2014 10:46 PM |
Look, I'm 11. I get it, I'm not good with grammar.
|
|
|
| Report Abuse |
|
|
|
| 11 Sep 2014 10:50 PM |
No, it's totally okay for you to be here! This is how you learn. Trial and error.
For a lap system, things are difficult to do because someone can be ahead of another person even if they're on the same lap. However, if you want to sort solely by current lap, you could put them all into a table and use the 'table.sort' function:
table.sort(players, function(player1, player2) return player1.Lap.Value > player2.Lap.Value end) |
|
|
| Report Abuse |
|
|