.:HyPeX:. Posted March 29, 2014 Share Posted March 29, 2014 Well, i aswell as other 2 players see me correctly (Stable), but the other 2 just flash, i had to record it shortly to show it: (They also see me stable whilst they are flashing) Code: function DrawLobby() start = 0 if DrawedLobby then GlobalPlayerDrawTable = PositionOrdering(GlobalPlayerDrawTable) for i,v in pairs(TableReturn) do local Kills = getElementData(i, "Kills") local x,y = guiGetScreenSize() dxDrawText(getPlayerNametagText(i), x*0.23, y*0.3 + (v * (y*0.056)), x, y, tocolor(255,255,255, 255),2, "default-bold","left", "top", false,false,true,true) dxDrawText(" #FFFFFF"..Kills, x*0.45, y*0.3 + (v * (y*0.056)), x, y, tocolor(0,50,150, 255),2, "default-bold","left", "top", false,false,true,true) if getElementData(getLocalPlayer(), "Squad") == getElementData(i, "Squad") then color = tocolor(0, 176, 21, 180) else color = -1275068416 end if i == getLocalPlayer() then color = tocolor(250, 225, 40, 180) end dxDrawRectangle(0.22205881774426 * x, 0.29036459326744 * y + (v * (y*0.056)),( 0.50661766529083 * x ) - ( 0.22205881774426 * x ), ( 0.34635415673256 * y - 0.29036459326744 * y ), color) start = start + 1 end end end function PositionOrdering(Table) PTableValues = {} PTable = {} if ( Table ) then for i,v in pairs(Table) do PTableValues[i] = v table.insert(PTable, v) end table.sort(PTable, function(a,b) return a>b end) TableReturn = {} for i,v in ipairs(PTable) do for k,s in pairs(PTableValues) do if v == s then TableReturn[k] = i break end end end return TableReturn else return false end end function SetLobbyDraw(v) if draw then draw = nil removeEventHandler("onClientRender", getRootElement(), DrawLobby) else draw = true addEventHandler("onClientRender", getRootElement(), DrawLobby) end end bindKey( "tab", "down", SetLobbyDraw) bindKey( "tab", "up", SetLobbyDraw) Link to comment
Gallardo9944 Posted March 29, 2014 Share Posted March 29, 2014 The idea is simple. table.sort can return purely random positions if you are comparing the same things. Remove sorting and you will not experience this. Or just sort it once and for all. Link to comment
.:HyPeX:. Posted March 29, 2014 Author Share Posted March 29, 2014 The idea is simple. table.sort can return purely random positions if you are comparing the same things. Remove sorting and you will not experience this. Or just sort it once and for all. But, it shouldnt be always sorting them from bigger to smaller as specified? Link to comment
.:HyPeX:. Posted March 29, 2014 Author Share Posted March 29, 2014 bump, how can i make that it will not get the same player here? (If 2 players have the same value, i want to make it random whos better.) TableReturn = {} for i,v in ipairs(PTable) do for k,s in pairs(PTableValues) do if v == s then TableReturn[k] = i break end end end 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