Mbtdaa Posted March 13, 2014 Share Posted March 13, 2014 hi whats the problem function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end WindowTOP = guiCreateWindow(328, 125, 613, 514, "", false) guiSetProperty(WindowTOP, "CaptionColour", "FF00FF00") guiSetVisible(WindowTOP, false) guiWindowSetSizable(WindowTOP, false) guiWindowSetMovable(WindowTOP, false) centerWindow ( WindowTOP ) GridListTOP = guiCreateGridList(9, 27, 594, 477, false, WindowTOP) guiGridListClear ( GridListTOP ) guiSetProperty( GridListTOP, "Disabled", "true" ) rank = guiGridListAddColumn(GridListTOP, "Rank", 0.2) name = guiGridListAddColumn(GridListTOP, "Name", 0.2) money = guiGridListAddColumn(GridListTOP, "Money", 0.2) kills = guiGridListAddColumn(GridListTOP, "Kills", 0.2) deaths = guiGridListAddColumn(GridListTOP, "Deaths", 0.2) aRow = guiGridListAddRow( GridListTOP ) aRoww = guiGridListAddRow( GridListTOP ) aRowww = guiGridListAddRow( GridListTOP ) aRowwww = guiGridListAddRow( GridListTOP ) aRowwwww = guiGridListAddRow( GridListTOP ) guiGridListSetItemColor ( GridListTOP, aRow,rank, 0-0-255 ) guiGridListSetItemColor ( GridListTOP, aRoww,name , 255-255-0 ) guiGridListSetItemColor ( GridListTOP, aRoww,money , 127-255-0 ) guiGridListSetItemColor ( GridListTOP, aRowww,kills , 255-0-0 ) guiGridListSetItemColor ( GridListTOP, aRowwww,deaths , 250, 154, 255 ) bindKey ( "F2" , "down" , function () if guiGetVisible ( WindowTOP , true ) then guiSetVisible ( WindowTOP , false ) showCursor ( false ) outputChatBox ( "Closed" , 255 , 0 , 0 , true ) else guiSetVisible ( WindowTOP , true ) showCursor ( true ) outputChatBox ( "Opened" , 0 , 255 , 0 , true ) end end ) function createPlayerList ( ) if ( name ) then for id, player in ipairs ( getElementsByType ( "player" ) ) do local r, g, b = getPlayerNametagColor ( player ) guiGridListSetItemText ( GridListTOP, aRoww, name, color (getPlayerName ( player )), false, false ) guiGridListSetItemColor ( GridListTOP, aRoww, name, r, g, b ) end end end addEventHandler ( "onClientResourceStart", resourceRoot, createPlayerList ) function color ( name ) return type(name)=='string' and string.gsub ( name, '#%x%x%x%x%x%x', '' ) or name end 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( ) local players = getPlayersSortByKills ( ) for i = 1, 30 do if ( players [ i ] )then guiGridListSetItemText( GridListTOP, aRow, 1, i ..'-', false, false ) guiGridListSetItemText (GridListTOP, aRowwwww, 1,tonumber(v.Money_), false, false) guiGridListSetItemText( GridListTOP, aRowww, 1, tostring( players [ i ].kills ), false, false ) guiGridListSetItemText( GridListTOP, aRowwww, 1, getElementData ( players [ i ].element, 'Deaths' ), false, false ) end end end function getPlayersSortByKills ( ) local players = { } for index, player in ipairs ( getElementsByType ( "player" ) ) do table.insert ( players, { element = player, kills = getElementData ( player, "Kills" ) or 0, } ) end table.sort ( players, function ( a, b ) return ( tonumber ( a.kills ) or 0 ) > ( tonumber ( b.kills ) or 0 ) end ) return players end Link to comment
justn Posted March 13, 2014 Share Posted March 13, 2014 Can you please use /debugscript 3 and then say whats the problem? Link to comment
pa3ck Posted March 13, 2014 Share Posted March 13, 2014 Yes, as Twerky said you'll need to post the errors. Also, I took a look at your code and I saw you have guiGridListSetItemColor ( GridListTOP, aRow,rank, 0-0-255 ) but it should be guiGridListSetItemColor ( GridListTOP, aRow,rank, 0, 0, 255) If you change them, it might solve the problem, try it, if it still won't work, use /debugscript 3 and post the error(s). Link to comment
Mbtdaa Posted March 14, 2014 Author Share Posted March 14, 2014 i edit the cod function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end WindowTOP = guiCreateWindow(328, 125, 613, 514, "", false) guiSetProperty(WindowTOP, "CaptionColour", "FF00FF00") guiSetVisible(WindowTOP, false) guiWindowSetSizable(WindowTOP, false) guiWindowSetMovable(WindowTOP, false) centerWindow ( WindowTOP ) GridListTOP = guiCreateGridList(9, 27, 594, 477, false, WindowTOP) guiSetProperty( GridListTOP, "Disabled", "true" ) guiGridListAddColumn(GridListTOP, "Rank", 0.2) guiGridListAddColumn(GridListTOP, "Name", 0.2) guiGridListAddColumn(GridListTOP, "Money", 0.2) guiGridListAddColumn(GridListTOP, "Kills", 0.2) guiGridListAddColumn(GridListTOP, "Deaths", 0.2) function U( ) guiGridListClear( GridListTOP ) local players = getPlayersSortByKills ( ) for i = 1, 30 do local aRow = guiGridListAddRow( GridListTOP ) if ( players [ i ] )then guiGridListSetItemText( GridListTOP, aRow, 1, i ..'-', false, false ) guiGridListSetItemText( GridListTOP, aRow, 2, getPlayerName ( players [ i ].element ), false, false ) guiGridListSetItemText( GridListTOP, aRow, 3, tostring( players [ i ].kills ), false, false ) guiGridListSetItemText( GridListTOP, aRow, 4, getElementData ( players [ i ].element, 'Deaths' ), false, false ) end end end function getPlayersSortByKills ( ) local players = { } for index, player in ipairs ( getElementsByType ( "player" ) ) do table.insert ( players, { element = player, kills = getElementData ( player, "Kills" ) or 0, } ) end table.sort ( players, function ( a, b ) return ( tonumber ( a.kills ) or 0 ) > ( tonumber ( b.kills ) or 0 ) end ) return players end bindKey ( "F2" , "down" , function () if guiGetVisible ( WindowTOP , true ) then guiSetVisible ( WindowTOP , false ) showCursor ( false ) outputChatBox ( "Closed" , 255 , 0 , 0 , true ) else guiSetVisible ( WindowTOP , true ) showCursor ( true ) outputChatBox ( "Opened" , 0 , 255 , 0 , true ) end end ) server addEventHandler( "onPlayerQuit" ,root, function( ) local accP = getPlayerAccount( source ) if ( accP and not isGuestAccount( accP ) ) then local Deaths = tonumber( getElementData( source, "Deaths" ) ) or 0 local Kills = tonumber ( getElementData( source, "Kills" ) ) or 0 setAccountData(accP, "PlayerDeaths", Deaths ) setAccountData(accP, "PlayerKills", Kills ) end end ) addEventHandler( "onPlayerLogin", root, function( _,acc ) local DataDeaths = getAccountData(acc, "PlayerDeaths" ) local DataKills = getAccountData(acc, "PlayerKills" ) if ( DataDeaths and DataKills ) then setElementData( source, "Deaths", DataDeaths ) setElementData( source, "Kills", DataKills ) end end ) no problem in debugscript and i have iQuestion how can i set color off kill red and deaths yalow and money green and name blue thx, Link to comment
Mbtdaa Posted March 14, 2014 Author Share Posted March 14, 2014 (edited) guiGridListSetItemColor thx dude but i have 1 row how can i do that and pleasefix the top for me <3 Edited March 15, 2014 by Guest Link to comment
Moderators Citizen Posted March 15, 2014 Moderators Share Posted March 15, 2014 if ( players [ i ] )then guiGridListSetItemText( GridListTOP, aRow, 1, i ..'-', false, false ) guiGridListSetItemColor( GridListTOP, aRow, 1, , , ) guiGridListSetItemText( GridListTOP, aRow, 2, getPlayerName ( players [ i ].element ), false, false ) guiGridListSetItemColor( GridListTOP, aRow, 2, , , ) guiGridListSetItemText( GridListTOP, aRow, 3, tostring( players [ i ].kills ), false, false ) guiGridListSetItemColor( GridListTOP, aRow, 3, , , ) guiGridListSetItemText( GridListTOP, aRow, 4, getElementData ( players [ i ].element, 'Deaths' ), false, false ) guiGridListSetItemColor( GridListTOP, aRow, 4, , , ) end But replace ', , ' by the values of the color you want ( 255, 0, 0 means full red) Link to comment
Mbtdaa Posted March 15, 2014 Author Share Posted March 15, 2014 if ( players [ i ] )then guiGridListSetItemText( GridListTOP, aRow, 1, i ..'-', false, false ) guiGridListSetItemColor( GridListTOP, aRow, 1, , , ) guiGridListSetItemText( GridListTOP, aRow, 2, getPlayerName ( players [ i ].element ), false, false ) guiGridListSetItemColor( GridListTOP, aRow, 2, , , ) guiGridListSetItemText( GridListTOP, aRow, 3, tostring( players [ i ].kills ), false, false ) guiGridListSetItemColor( GridListTOP, aRow, 3, , , ) guiGridListSetItemText( GridListTOP, aRow, 4, getElementData ( players [ i ].element, 'Deaths' ), false, false ) guiGridListSetItemColor( GridListTOP, aRow, 4, , , ) end But replace ', , ' by the values of the color you want ( 255, 0, 0 means full red) same problem guiGridListAddColumn(GridListTOP, "Rank", 0.2) guiGridListAddColumn(GridListTOP, "Name", 0.2) guiGridListAddColumn(GridListTOP, "Money", 0.2) guiGridListAddColumn(GridListTOP, "Kills", 0.2) guiGridListAddColumn(GridListTOP, "Deaths", 0.2) function U( ) guiGridListClear( GridListTOP ) local players = getPlayersSortByKills ( ) for i = 1, 30 do local aRow = guiGridListAddRow( GridListTOP ) local aRoww = guiGridListAddRow( GridListTOP ) local aRowww = guiGridListAddRow( GridListTOP ) local aRowwww = guiGridListAddRow( GridListTOP ) if ( players [ i ] )then guiGridListSetItemText( GridListTOP, aRow, 1, i ..'-', false, false ) guiGridListSetItemColor( GridListTOP, aRow, 1, 0, 0, 255 ) guiGridListSetItemText( GridListTOP, aRoww, 2, getPlayerName ( players [ i ].element ), false, false ) guiGridListSetItemColor( GridListTOP, aRoww, 2, 255, 255, 0 ) guiGridListSetItemText( GridListTOP, aRowww, 3, tostring( players [ i ].kills ), false, false ) guiGridListSetItemColor( GridListTOP, aRowww, 3, 255, 0, 0 ) guiGridListSetItemText( GridListTOP, aRowwww, 4, getElementData ( players [ i ].element, 'Deaths' ), false, false ) guiGridListSetItemColor( GridListTOP, aRowwww, 4, 250, 154, 255 ) end end end function getPlayersSortByKills ( ) local players = { } for index, player in ipairs ( getElementsByType ( "player" ) ) do table.insert ( players, { element = player, kills = getElementData ( player, "Kills" ) or 0, } ) end table.sort ( players, function ( a, b ) return ( tonumber ( a.kills ) or 0 ) > ( tonumber ( b.kills ) or 0 ) end ) return players end bindKey ( "F2" , "down" , function () if guiGetVisible ( WindowTOP , true ) then guiSetVisible ( WindowTOP , false ) showCursor ( false ) outputChatBox ( "Closed" , 255 , 0 , 0 , true ) else guiSetVisible ( WindowTOP , true ) showCursor ( true ) outputChatBox ( "Opened" , 0 , 255 , 0 , true ) end end ) Link to comment
Mbtdaa Posted March 15, 2014 Author Share Posted March 15, 2014 What is the problem? nothing show no kills no name nothng and i dont have error in debugscript Link to comment
Castillo Posted March 15, 2014 Share Posted March 15, 2014 Are you sure there are no errors? they won't show in the server console, you must be ingame and do /debugscript 3. Link to comment
Mbtdaa Posted March 15, 2014 Author Share Posted March 15, 2014 Are you sure there are no errors? they won't show in the server console, you must be ingame and do /debugscript 3. yes i'm sure no errors Link to comment
Mbtdaa Posted March 15, 2014 Author Share Posted March 15, 2014 Post the complete script. function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end WindowTOP = guiCreateWindow(328, 125, 613, 514, "", false) guiSetProperty(WindowTOP, "CaptionColour", "FF00FF00") guiSetVisible(WindowTOP, false) guiWindowSetSizable(WindowTOP, false) guiWindowSetMovable(WindowTOP, false) centerWindow ( WindowTOP ) GridListTOP = guiCreateGridList(9, 27, 594, 477, false, WindowTOP) guiGridListAddColumn(GridListTOP, "Rank", 0.2) guiGridListAddColumn(GridListTOP, "Name", 0.2) guiGridListAddColumn(GridListTOP, "Money", 0.2) guiGridListAddColumn(GridListTOP, "Kills", 0.2) guiGridListAddColumn(GridListTOP, "Deaths", 0.1) function U( ) guiGridListClear( GridListTOP ) local aRow = guiGridListAddRow( GridListTOP ) local aRoww = guiGridListAddRow( GridListTOP ) local aRowww = guiGridListAddRow( GridListTOP ) local aRowwww = guiGridListAddRow( GridListTOP ) local players = getPlayersSortByKills ( ) for i = 1, 30 do if ( players [ i ] )then guiGridListSetItemText( GridListTOP, aRow, 1, i ..'-', false, false ) guiGridListSetItemColor( GridListTOP, aRow, 1, 0, 0, 255 ) guiGridListSetItemText( GridListTOP, aRoww, 2, getPlayerName ( players [ i ].element ), false, false ) guiGridListSetItemColor( GridListTOP, aRoww, 2, 255, 255, 0 ) guiGridListSetItemText( GridListTOP, aRowww, 3, tostring( players [ i ].kills ), false, false ) guiGridListSetItemColor( GridListTOP, aRowww, 3, 255, 0, 0 ) guiGridListSetItemText( GridListTOP, aRowwww, 4, getElementData ( players [ i ].element, 'Deaths' ), false, false ) guiGridListSetItemColor( GridListTOP, aRowwww, 4, 250, 154, 255 ) end end end function getPlayersSortByKills ( ) local players = { } for index, player in ipairs ( getElementsByType ( "player" ) ) do table.insert ( players, { element = player, kills = getElementData ( player, "Kills" ) or 0, } ) end table.sort ( players, function ( a, b ) return ( tonumber ( a.kills ) or 0 ) > ( tonumber ( b.kills ) or 0 ) end ) return players end bindKey ( "F2" , "down" , function () if guiGetVisible ( WindowTOP , true ) then guiSetVisible ( WindowTOP , false ) showCursor ( false ) outputChatBox ( "Closed" , 255 , 0 , 0 , true ) else guiSetVisible ( WindowTOP , true ) showCursor ( true ) outputChatBox ( "Opened" , 0 , 255 , 0 , true ) end end ) server addEventHandler( "onPlayerLogout" ,root, function( ) local accP = getPlayerAccount( source ) if ( accP and not isGuestAccount( accP ) ) then local Deaths = tonumber( getElementData( source, "Deaths" ) ) or 0 local Kills = tonumber ( getElementData( source, "Kills" ) ) or 0 setAccountData(accP, "PlayerDeaths", Deaths ) setAccountData(accP, "PlayerKills", Kills ) end end ) addEventHandler( "onPlayerLogin", root, function( _,acc ) local DataDeaths = getAccountData(acc, "PlayerDeaths" ) local DataKills = getAccountData(acc, "PlayerKills" ) if ( DataDeaths and DataKills ) then setElementData( source, "Deaths", DataDeaths ) setElementData( source, "Kills", DataKills ) end end ) Link to comment
Castillo Posted March 15, 2014 Share Posted March 15, 2014 function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end WindowTOP = guiCreateWindow(328, 125, 613, 514, "", false) guiSetProperty(WindowTOP, "CaptionColour", "FF00FF00") guiSetVisible(WindowTOP, false) guiWindowSetSizable(WindowTOP, false) guiWindowSetMovable(WindowTOP, false) centerWindow ( WindowTOP ) GridListTOP = guiCreateGridList(9, 27, 594, 477, false, WindowTOP) guiGridListAddColumn(GridListTOP, "Rank", 0.2) guiGridListAddColumn(GridListTOP, "Name", 0.2) guiGridListAddColumn(GridListTOP, "Money", 0.2) guiGridListAddColumn(GridListTOP, "Kills", 0.2) guiGridListAddColumn(GridListTOP, "Deaths", 0.1) function U ( ) guiGridListClear ( GridListTOP ) local players = getPlayersSortByKills ( ) for i = 1, 30 do if ( players [ i ] )then local row = guiGridListAddRow ( GridListTOP ) guiGridListSetItemText( GridListTOP, row, 1, i ..'-', false, false ) guiGridListSetItemColor( GridListTOP, row, 1, 0, 0, 255 ) guiGridListSetItemText( GridListTOP, row, 2, getPlayerName ( players [ i ].element ), false, false ) guiGridListSetItemColor( GridListTOP, row, 2, 255, 255, 0 ) guiGridListSetItemText( GridListTOP, row, 3, tostring ( players [ i ].kills ), false, false ) guiGridListSetItemColor ( GridListTOP, row, 3, 255, 0, 0 ) guiGridListSetItemText ( GridListTOP, row, 4, tostring ( players [ i ].deaths ), false, false ) guiGridListSetItemColor ( GridListTOP, row, 4, 250, 154, 255 ) end end end function getPlayersSortByKills ( ) local players = { } for _, 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 bindKey ( "F2" , "down" , function () if guiGetVisible ( WindowTOP , true ) then guiSetVisible ( WindowTOP , false ) showCursor ( false ) outputChatBox ( "Closed" , 255 , 0 , 0 , true ) else guiSetVisible ( WindowTOP , true ) showCursor ( true ) outputChatBox ( "Opened" , 0 , 255 , 0 , true ) U ( ) end end ) Problems: 1: You weren't executing "U" function, which is what adds the players to list. 2: You were adding wrong the rows. Link to comment
Mbtdaa Posted March 15, 2014 Author Share Posted March 15, 2014 function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end WindowTOP = guiCreateWindow(328, 125, 613, 514, "", false) guiSetProperty(WindowTOP, "CaptionColour", "FF00FF00") guiSetVisible(WindowTOP, false) guiWindowSetSizable(WindowTOP, false) guiWindowSetMovable(WindowTOP, false) centerWindow ( WindowTOP ) GridListTOP = guiCreateGridList(9, 27, 594, 477, false, WindowTOP) guiGridListAddColumn(GridListTOP, "Rank", 0.2) guiGridListAddColumn(GridListTOP, "Name", 0.2) guiGridListAddColumn(GridListTOP, "Money", 0.2) guiGridListAddColumn(GridListTOP, "Kills", 0.2) guiGridListAddColumn(GridListTOP, "Deaths", 0.1) function U ( ) guiGridListClear ( GridListTOP ) local players = getPlayersSortByKills ( ) for i = 1, 30 do if ( players [ i ] )then local row = guiGridListAddRow ( GridListTOP ) guiGridListSetItemText( GridListTOP, row, 1, i ..'-', false, false ) guiGridListSetItemColor( GridListTOP, row, 1, 0, 0, 255 ) guiGridListSetItemText( GridListTOP, row, 2, getPlayerName ( players [ i ].element ), false, false ) guiGridListSetItemColor( GridListTOP, row, 2, 255, 255, 0 ) guiGridListSetItemText( GridListTOP, row, 3, tostring ( players [ i ].kills ), false, false ) guiGridListSetItemColor ( GridListTOP, row, 3, 255, 0, 0 ) guiGridListSetItemText ( GridListTOP, row, 4, tostring ( players [ i ].deaths ), false, false ) guiGridListSetItemColor ( GridListTOP, row, 4, 250, 154, 255 ) end end end function getPlayersSortByKills ( ) local players = { } for _, 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 bindKey ( "F2" , "down" , function () if guiGetVisible ( WindowTOP , true ) then guiSetVisible ( WindowTOP , false ) showCursor ( false ) outputChatBox ( "Closed" , 255 , 0 , 0 , true ) else guiSetVisible ( WindowTOP , true ) showCursor ( true ) outputChatBox ( "Opened" , 0 , 255 , 0 , true ) U ( ) end end ) Problems: 1: You weren't executing "U" function, which is what adds the players to list. 2: You were adding wrong the rows. thx it's working but can i set a font to row ? Link to comment
Castillo Posted March 15, 2014 Share Posted March 15, 2014 You can't change the grid list text font. Link to comment
Mbtdaa Posted March 15, 2014 Author Share Posted March 15, 2014 You can't change the grid list text font. ok solid the top don't refresh . Link to comment
Moderators Citizen Posted March 15, 2014 Moderators Share Posted March 15, 2014 You can't change the grid list text font. ok solid the top don't refresh . You said it was working ! Stop breaking the code and ask for help again. If you mean't auto-update, then use a setTimer to call U function every 2 secs when the "top" is visible. Link to comment
Mbtdaa Posted March 15, 2014 Author Share Posted March 15, 2014 You can't change the grid list text font. ok solid the top don't refresh . You said it was working ! Stop breaking the code and ask for help again. If you mean't auto-update, then use a setTimer to call U function every 2 secs when the "top" is visible. i I just open the top and see it i did not focus sorry # 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