Jump to content

[Help] setElementData/getElementData


Daniels69

Recommended Posts

Hey there.

I have couple questions about setelementdata and getlementdata.

Basically what i need is. How do i get the player with the biggest elementdata which was set by script?

For e.x

On player kill somebody it gives him score like, setElementData(player , murders+1)

and how do i get the player with the biggest data? Any suggestions please.

Link to comment

Typical algorithm for this:

  
var max = 0 
var player = null 
  
for each player ingame... do 
        if (murders > max) 
               max = murders 
               player = currentplayer 
        fi 
done 

Please notice that this will consider, in case of a draw, the last ocurrence.

Link to comment
max = 0 
  
addEventHandler("onPlayerWasted", root, 
    function() 
        for _, player in ipairs(getElementsByType("player")) do 
            if (murder > max ) then 
                setElementData(player, "Kills", murder) 
           end 
           getElementData(player, "Kills") 
      end 
    end 
) 

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