Persian MO 82 Posted December 25, 2014 I m working on a DM mission.in this mission, last man standing alive will get a point and then game moving for next round.I get a code for trigger to do this but in hint board player won't sort by score,e.g player with 2 time win staying under player with one win. here is code in trigger act: Comment "By Renz"; if (isNil "ref") then { ref = []; playerScores = []; }; textArray = []; livingCount = {isPlayer _x && alive _x} count thisList; if ( livingCount == 0 ) then { hint "Draw!"; } else { systemChat "Last Man detected"; lastMan = objNull; }; {if (isPlayer _x && alive _x) then {lastMan = _x} } forEach thisList; unitID = name lastMan; index = (ref find unitID); if (index == -1) then { ref pushBack unitID; playerScores pushBack [unitID, 1]; } else { (playerScores select index) set[1, ((playerScores select index) select 1) + 1]; }; sortedScores = [playerScores, [], {(_x select 1)}, "ASCEND"] call BIS_fnc_sortBy; textArray = []; { _line = format["%3. %1 - %2",(_x select 0), (_x select 1),(_forEachIndex + 1)]; textArray pushBack _line } forEach sortedScores; countData = count sortedScores; if (count sortedScores < 5) then { for "_i" from 1 to (5 - countData) do { textArray pushBack ""; }; }; hint format["thisList: %6\n netID: %7 \n lastMan: %1\n livingCount: %2\n ref: %3 \n pScores: %4\n sortedScores %5",lastMan,livingCount,ref,pScores,sortedScores,thisList,unitID]; paragraph = format["Leader Board\n%1 \n%2 \n%3 \n%4 \n%5 ", (textArray select 0), (textArray select 1),(textArray select 2),(textArray select 3),(textArray select 4)]; GlobalHint = paragraph; publicVariable "GlobalHint"; hint GlobalHint; if (isServer) then { publicVariable "playerScores"; publicVariable "ref"; }; countstart = false; how i change this code to get players list sort by score in hint? Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted December 27, 2014 I don't know if that's what you're searching for, but it seems to work: [color=#FF8040]playersArray [color=#8B3E2F][b]=[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#191970][b]if[/b][/color][color=#8B3E2F][b]([/b][/color][color=#191970][b]isPlayer[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color] [color=#8B3E2F][b]{[/b][/color] playersArray [color=#191970][b]pushBack[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color] [color=#191970][b]forEach[/b][/color] thisList[color=#8B3E2F][b];[/b][/color] [color=#1874CD]_playersAliveCount[/color] [color=#8B3E2F][b]=[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#191970][b]alive[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b]}[/b][/color] [color=#191970][b]count[/b][/color] playersArray[color=#8B3E2F][b];[/b][/color] [color=#191970][b]for[/b][/color] [color=#7A7A7A]'_i'[/color] [color=#191970][b]from[/b][/color] [color=#FF0000]0[/color] [color=#191970][b]to[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#1874CD]_playersAliveCount[/color] [color=#8B3E2F][b]-[/b][/color] [color=#FF0000]1[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]do[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#1874CD]_player1[/color] [color=#8B3E2F][b]=[/b][/color] playersArray [color=#191970][b]select[/b][/color] [color=#1874CD]_i[/color][color=#8B3E2F][b];[/b][/color] [color=#191970][b]for[/b][/color] [color=#7A7A7A]'_j'[/color] [color=#191970][b]from[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#1874CD]_i[/color] [color=#8B3E2F][b]+[/b][/color] [color=#FF0000]1[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]to[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#1874CD]_playersAliveCount[/color] [color=#8B3E2F][b]-[/b][/color] [color=#FF0000]1[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]do[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#1874CD]_player2[/color] [color=#8B3E2F][b]=[/b][/color] playersArray [color=#191970][b]select[/b][/color] [color=#1874CD]_j[/color][color=#8B3E2F][b];[/b][/color] [color=#191970][b]if[/b][/color][color=#8B3E2F][b]([/b][/color][color=#8B3E2F][b]([/b][/color][color=#1874CD]_player2[/color] [color=#191970][b]getVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]'score'[/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b])[/b][/color] [color=#8B3E2F][b]<[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#1874CD]_player1[/color] [color=#191970][b]getVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]'score'[/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color] [color=#8B3E2F][b]{[/b][/color] playersArray [color=#191970][b]set[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#1874CD]_i[/color][color=#8B3E2F][b],[/b][/color] [color=#1874CD]_player2[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] playersArray [color=#191970][b]set[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#1874CD]_j[/color][color=#8B3E2F][b],[/b][/color] [color=#1874CD]_player1[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#1874CD]_player1[/color] [color=#8B3E2F][b]=[/b][/color] [color=#8B3E2F][b]+[/b][/color][color=#1874CD]_player2[/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#1874CD]_rankList[/color] [color=#8B3E2F][b]=[/b][/color] [color=#7A7A7A]''[/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#1874CD]_rankList[/color] [color=#8B3E2F][b]=[/b][/color] [color=#1874CD]_rankList[/color] [color=#8B3E2F][b]+[/b][/color] [color=#191970][b]format[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]'<t align=[color=#7A7A7A]""[/color]left[color=#7A7A7A]""[/color]>%1</t><t align=[color=#7A7A7A]""[/color]right[color=#7A7A7A]""[/color]>%2</t><br />'[/color][color=#8B3E2F][b],[/b][/color] [color=#191970][b]name[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b],[/b][/color] [color=#000000]_x[/color] [color=#191970][b]getVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]'score'[/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color] [color=#191970][b]forEach[/b][/color] playersArray[color=#8B3E2F][b];[/b][/color] [color=#191970][b]hintSilent[/b][/color] [color=#191970][b]parseText[/b][/color] [color=#1874CD]_rankList[/color][color=#8B3E2F][b];[/b][/color][/color] Kudos to Killzone_Kid for his SQF to BBCode Converter. Share this post Link to post Share on other sites