Jump to content

question move player in first place


iiv03

Recommended Posts

Posted

how make the number if the highest moves the player in the first place
like toptime).

what do I use?

Loop and executeSQLQuery?

 

 

 
Posted
local highestping=0
local playername
for loop,target in ipairs(getElementsByType("player"))do
  if(getPlayerPing(target)>highestping)then
    highestping=getPlayerPing(target)
    playername=getPlayerName(target)
  end
end
if(playername)then
  print("Player "..playername.." has the highest ping ("..highestping..")")

Of course you will need to modify the values to your own code for (toptime), but it could be done with something like this...

If I am understanding what you're saying correctly anyway

n-560x95_888888_FFFFFF_000000_000000.png

Posted
5 hours ago, ReZurrecti0n said:

local highestping=0
local playername
for loop,target in ipairs(getElementsByType("player"))do
  if(getPlayerPing(target)>highestping)then
    highestping=getPlayerPing(target)
    playername=getPlayerName(target)
  end
end
if(playername)then
  print("Player "..playername.." has the highest ping ("..highestping..")")

Of course you will need to modify the values to your own code for (toptime), but it could be done with something like this...

If I am understanding what you're saying correctly anyway

i just want to know in your code how set that in dxDrawText like what say in above if he got top value number move in place first

 

 

 
Posted

Since you are talking about 'top value', I suppose you've got a table, whose indexes are numerical, which contains the players. If you draw the text within a loop, which goes through all the elements of the previously mentioned table, you can easily edit the order of the players by assigning them to a different index within the table.

In the case you don't have a loop whose indexes are numerical, try to implement one to keep it easy.

  • Thanks 1

"Keep making it simplex."

Posted (edited)
18 hours ago, Simple0x47 said:

Since you are talking about 'top value', I suppose you've got a table, whose indexes are numerical, which contains the players. If you draw the text within a loop, which goes through all the elements of the previously mentioned table, you can easily edit the order of the players by assigning them to a different index within the table.

In the case you don't have a loop whose indexes are numerical, try to implement one to keep it easy.

do you mean like this?

			local theplayers = {}
			for i,player in pairs(players) do
				local thetables = {name = getPlayerName(player), alive = getElementData(player,"state") == "alive", points = getElementData(player,"ThePoints") or "0"}
				
					table.insert(theplayers,
					thetables)
				table.sort(theplayers, function(a, b) return a.points > b.points end )
				end

 

Edited by xFabel

 

 

 
Posted

Well since your code uses the same logic, here's a more efficient way to do it:

local playerElements = getElementsByType( "player" )
local players = {}

for i = 1, #playerElements do 
	local player = playerElements[ i ]
	
	players[ i ] = { name = getPlayerName(player), alive = getElementData(player,"state") == "alive", points = tonumber( getElementData(player,"ThePoints")) or 0 }
end

table.sort( players, function( a, b ) return a.points > b.points end )

 

  • Thanks 1

"Keep making it simplex."

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...