Jump to content

Sort a PointSystem DD/DM


ReSe

Recommended Posts

Hey! Im going to create nice pointsystem but im already thinking how to sort it.

Script save the AccountName and PointValue of players and must sort them from biggest PointValue because i would like to get player current rank in points.

I think the best is SQLlite to do this what you think? Maybe it can be easiest with another one idk.

Link to comment

What about that idea?

To get number of bigger values then one player have :D ?

I mean we search in SQL for bigger values then our player have and that's his rank + 1

Something like that:

We have 10 players with points, 5 of them have more then we so our rank is 5 + 1 = 6 so we are 6th.

Script count the number with more points and then we add + 1 to it and here we are :D

How should our dbQuery look ?

Link to comment

Yea SQL have it :)

It work nice :) But how get the position of our player ?

local sortquery = dbQuery (playerstatistic, "SELECT * FROM PlayerPoints ORDER BY points DESC") 
    local positon = dbPoll(sortquery,-1) 

I don't really understand table which is created by dbPoll, how can i read a number of a row from it ? I mean i will look for same accountname and get the row number of it :)

Link to comment

Ok i will try to use one of the examples.

local result, numrows, errmsg = dbPoll ( qh, -1 )

local result, numrows, errmsg = dbPoll ( qh, -1 ) 
  
if numrows > 0 then 
  
    for result, row in pairs ( result ) do 
        -- by using a second loop (use it if you want to get the values of all columns the query selected): 
        for column, value in pairs ( row ) do 
            -- column = the mysql column of the table in the query 
            -- value = the value of that column in this certain row 
        end 
  
        -- or without a second loop (use it if you want to handle every value in a special way): 
        outputChatBox ( row["column"] ) -- it will output the value of the column "column" in this certain row 
    end 
  
end 

How to get values in each row?

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