Kenix Posted October 14, 2011 Share Posted October 14, 2011 I want to get a player with the highest number of kill's data for example how do I do? I have elementData and i need check it Help Guys. Link to comment
BriGhtx3 Posted October 14, 2011 Share Posted October 14, 2011 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 Link to comment
Kenix Posted October 14, 2011 Author Share Posted October 14, 2011 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
Aibo Posted October 14, 2011 Share Posted October 14, 2011 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
Kenix Posted October 14, 2011 Author Share Posted October 14, 2011 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
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