Jump to content

Question


Kenix

Recommended Posts

I think it would be easier with MySQL. Don't you have any code?

When you use MySQL, you could use :

SELECT MAX(kills) FROM players 

Read my post better

  
function getMaxData( data ) 
    local name = "" 
    for i,v in pairs( getElementsByType("player") ) do 
        local count = getElementData(v,data)  
        if v == math.max( count ) then 
            name = getPlayerName( v ) 
        end 
    end 
    return name 
end  
  

Link to comment

something like that probably. but you better use SQL for things like that.

  
function getPlayerWithTopKills() 
  local player = false 
  local kills = 0 
  for i, p in ipairs(getElementsByType("player")) do 
    if kills < getElementData(p, "kills") then 
      kills = getElementData(p, "kills") 
      player = p 
    end 
  end 
  return player, kills 
end 
  

PS: math.max has different purpose/usage.

Link to comment
something like that probably. but you better use SQL for things like that.
  
function getPlayerWithTopKills() 
  local player = false 
  local kills = 0 
  for i, p in ipairs(getElementsByType("player")) do 
    if kills < getElementData(p, "kills") then 
      kills = getElementData(p, "kills") 
      player = p 
    end 
  end 
  return player, kills 
end 
  

Thx all for help!

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