Sex* Posted April 16, 2013 Share Posted April 16, 2013 Then two people on the server or more i have these errors: 198 line function: function RaceMode:updateRanks() -- Make a table with the active players local sortinfo = {} for i,player in ipairs(getActivePlayers()) do sortinfo[i] = {} sortinfo[i].player = player sortinfo[i].checkpoint = getPlayerCurrentCheckpoint(player) sortinfo[i].cpdist = distanceFromPlayerToCheckpoint(player, sortinfo[i].checkpoint ) end -- Order by cp table.sort( sortinfo, function(a,b) return a.checkpoint > b.checkpoint or ( a.checkpoint == b.checkpoint and a.cpdist < b.cpdist ) end ) The 198 line: ( a.checkpoint == b.checkpoint and a.cpdist < b.cpdist Link to comment
DiSaMe Posted April 16, 2013 Share Posted April 16, 2013 That means distanceFromPlayerToCheckpoint returns nil. Link to comment
Sex* Posted April 16, 2013 Author Share Posted April 16, 2013 But how to fix it then? EDIT: So i add something like this? g_Checkpoints = nil Link to comment
Moderators IIYAMA Posted April 19, 2013 Moderators Share Posted April 19, 2013 = distanceFromPlayerToCheckpoint(player, sortinfo[i].checkpoint ) or 0 Link to comment
Sex* Posted April 20, 2013 Author Share Posted April 20, 2013 So something like this? function RaceMode:updateRanks() -- Make a table with the active players local sortinfo = {} for i,player in ipairs(getActivePlayers()) do sortinfo[i] = {} sortinfo[i].player = player sortinfo[i].checkpoint = getPlayerCurrentCheckpoint(player) sortinfo[i].cpdist = distanceFromPlayerToCheckpoint(player, sortinfo[i].checkpoint ) end -- Order by cp table.sort( sortinfo, function(a,b) return a.checkpoint > b.checkpoint or ( a.checkpoint == distanceFromPlayerToCheckpoint(player, sortinfo[i].checkpoint ) or 0 end ) Link to comment
Sex* Posted April 20, 2013 Author Share Posted April 20, 2013 Doesnt work..(that one i made...) Link to comment
Moderators IIYAMA Posted April 20, 2013 Moderators Share Posted April 20, 2013 I don't know why you return a boolean to table.sort, it is probably because I got another scripting style and I haven't used it that much. try this: table.sort( sortinfo, function(a,b) return a.checkpoint > b.checkpoint or ( a.checkpoint == (tonumber(distanceFromPlayerToCheckpoint(player, sortinfo[i].checkpoint)) or 0)) end ) updated. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now