Jump to content

[ Help ]


Recommended Posts

that code i want to get the player have the most account data 
i have put events ( onPlayerLogin - onResourceStart - onPlayerChangeNick - onElementDataChange ) to put the account data ( nick ) to player 
but the girdlist doesn't get matches or add row and no debug ..
 


function getPlayersSortByaData( )
	local TopData = { }
	for i, v in ipairs( getAccounts() ) do
		if getAccountData ( v, 'nick' ) then
			table.insert (TopData,
			{
				Name = getAccountData ( v, 'nick' ) , 
				Account = getAccountName(v) ,
				aScore = getAccountData ( v, 'Data' ) or 0 , 
			} )
		end
	end
	table.sort( TopData,
	function( a, b )
		return( tonumber( a.aScore ) or 0 ) > ( tonumber( b.aScore ) or 0 )
	end )
	return TopData
end


addEvent("GetData",true)
addEventHandler("GetData",root,
function ( )
triggerClientEvent(source, "SetData", source, getPlayersSortByaData( ))
end )
 
-- client


addEvent("SetData",true)
addEventHandler("SetData",root,
	function ( Table )
	
	guiGridListClear( ScoreList )
	
	if ( Table [ 1 ].aScore ) then

	guiGridListSetItemText( ScoreList, 1, 1, Table[ 1 ].Name , false, false )
	
	guiGridListSetItemText( ScoreList, 1, 2, Table [ 1 ].aScore , false, false )
		end
	end
	)

bindKey( 'F1', 'down',
function ( )
    guiSetVisible ( TopWindow, not guiGetVisible(TopWindow) )
    showCursor ( guiGetVisible(TopWindow)  )
	if ( guiGetVisible(TopWindow) ) then
		triggerServerEvent('GetData',localPlayer)
	end
end )


 

Link to comment
5 hours ago, Ahmed Araby said:

that code i want to get the player have the most account data 
i have put events ( onPlayerLogin - onResourceStart - onPlayerChangeNick - onElementDataChange ) to put the account data ( nick ) to player 
but the girdlist doesn't get matches or add row and no debug ..
 


function getPlayersSortByaData( )
	local TopData = { }
	for i, v in ipairs( getAccounts() ) do
		if getAccountData ( v, 'nick' ) then
			table.insert (TopData,
			{
				Name = getAccountData ( v, 'nick' ) , 
				Account = getAccountName(v) ,
				aScore = getAccountData ( v, 'Data' ) or 0 , 
			} )
		end
	end
	table.sort( TopData,
	function( a, b )
		return( tonumber( a.aScore ) or 0 ) > ( tonumber( b.aScore ) or 0 )
	end )
	return TopData
end


addEvent("GetData",true)
addEventHandler("GetData",root,
function ( )
triggerClientEvent(source, "SetData", source, getPlayersSortByaData( ))
end )
 
-- client


addEvent("SetData",true)
addEventHandler("SetData",root,
	function ( Table )
	
	guiGridListClear( ScoreList )
	
	if ( Table [ 1 ].aScore ) then

	guiGridListSetItemText( ScoreList, 1, 1, Table[ 1 ].Name , false, false )
	
	guiGridListSetItemText( ScoreList, 1, 2, Table [ 1 ].aScore , false, false )
		end
	end
	)

bindKey( 'F1', 'down',
function ( )
    guiSetVisible ( TopWindow, not guiGetVisible(TopWindow) )
    showCursor ( guiGetVisible(TopWindow)  )
	if ( guiGetVisible(TopWindow) ) then
		triggerServerEvent('GetData',localPlayer)
	end
end )


 

provide the Gui Creation code like guiCreate window and and guiCreateGridlist etc .

:)

 

 

Edited by Ayush Rathore
  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...