Joker_Mta Posted August 31, 2012 Posted August 31, 2012 GUIEditor_Window = {} GUIEditor_Grid = {} GUIEditor_Window = {} GUIEditor_Grid = {} local x,y = guiGetScreenSize() GUIEditor_Window[1] = guiCreateWindow(x/2-179,y/2-203,358,405,"kill / Deaths",false) guiSetVisible(GUIEditor_Window[1] ,false) GUIEditor_Grid[1] = guiCreateGridList(9,24,340,372,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],1) guiGridListAddColumn(GUIEditor_Grid[1],"Player Name",0.5) guiGridListAddColumn(GUIEditor_Grid[1],"Player Kills",0.2) guiGridListAddColumn(GUIEditor_Grid[1],"Player Deaths",0.2) setElementData(localPlayer, "Kills", 0) setElementData(localPlayer, "Deaths", 0) addEventHandler("onClientPlayerWasted",root, function(killer) if killer then local k = getElementData(killer,"Kills") or 0 setElementData(killer, "Kills",k+1) end local d = getElementData(source, "Deaths") or 0 setElementData(source, "Deaths",d+1) end) function U() guiGridListClear(GUIEditor_Grid[1]) for i, player in ipairs (getElementsByType ("player")) do local row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText(GUIEditor_Grid[1], row, 1, getPlayerName(player), false, false) guiGridListSetItemText(GUIEditor_Grid[1], row, 2, getElementData(player,"Kills") or 0, false, false) guiGridListSetItemText(GUIEditor_Grid[1], row, 3, getElementData(player,"Deaths") or 0, false, false) if i == 20 then break end end end addEventHandler("onClientResourceStart",resourceRoot,U) addEventHandler("onClientPlayerWasted",root,U) Hello please I want to be the order of the top kill down
Castillo Posted August 31, 2012 Posted August 31, 2012 GUIEditor_Window = {} GUIEditor_Grid = {} GUIEditor_Window = {} GUIEditor_Grid = {} local x,y = guiGetScreenSize() GUIEditor_Window[1] = guiCreateWindow(x/2-179,y/2-203,358,405,"kill / Deaths",false) guiSetVisible(GUIEditor_Window[1] ,false) GUIEditor_Grid[1] = guiCreateGridList(9,24,340,372,false,GUIEditor_Window[1]) guiGridListAddColumn(GUIEditor_Grid[1],"Player Name",0.5) guiGridListAddColumn(GUIEditor_Grid[1],"Player Kills",0.2) guiGridListAddColumn(GUIEditor_Grid[1],"Player Deaths",0.2) setElementData ( localPlayer, "Kills", 0 ) setElementData ( localPlayer, "Deaths", 0 ) addEventHandler ( "onClientPlayerWasted", root, function ( killer ) if ( killer and killer ~= source ) then local k = getElementData ( killer, "Kills" ) or 0 setElementData ( killer, "Kills", ( k + 1 ) ) end local d = getElementData ( source, "Deaths" ) or 0 setElementData ( source, "Deaths", ( d + 1 ) ) U ( ) end ) function U ( ) guiGridListClear ( GUIEditor_Grid[1] ) local players = getPlayersSortByKills ( ) for index = 1, 20 do local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, tostring ( getPlayerName ( players [ index ].element ) ), false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 2, tostring ( players [ index ].kills ), false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 3, tostring ( players [ index ].deaths ), false, false ) end end addEventHandler ( "onClientResourceStart", resourceRoot, U ) function getPlayersSortByKills ( ) local players = { } for index, player in ipairs ( getElementsByType ( "player" ) ) do table.insert ( players, { element = player, kills = getElementData ( player, "Kills" ) or 0, deaths = getElementData ( player, "Deaths" ) or 0 } ) end table.sort ( players, function ( a, b ) return ( tonumber ( a.kills ) or 0 ) > ( tonumber ( b.kills ) or 0 ) end ) return players end Try it. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted September 1, 2012 Posted September 1, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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