AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Question about order (https://forums.alliedmods.net/showthread.php?t=334790)

StrikerM 10-19-2021 22:16

Question about order
 
Hello.

I want to make a /rank cmd that shows in console first 10 people with the biggest points.
I am with another friend and he has 10 points i have 15, it shows me 2 times instead of both of us.

Code:

public test(id)
{
        new string[300];
        Data[0] = id;
        format(string, charsmax(string), "SELECT * FROM `players` ORDER BY `Points` DESC LIMIT 10"), SQL_ThreadQuery(Handler, "GiveRankInformation", string, Data, 5);
        return PLUGIN_HANDLED;
}

new PlayerName2[32], PlayerPoints[32];
public GiveRankInformation(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
        new id = Data[0];
        if(SQL_NumResults(Query) > 0)
        {
                id++;
                SQL_ReadResult(Query, 1, PlayerName2[id], 32), PlayerPoints[id] = SQL_ReadResult(Query, 5);
                new Players[32], iNum, id2;
                  get_players(Players, iNum, "ch");
                for(new i = 0; i < id; i++)
                {
                        id2 = Players[i];
                        client_print(id2, print_console, "%s %s - Points: %d - %d", TAG, PlayerName2[id], PlayerPoints[id], id);
                }
        }
        return PLUGIN_HANDLED;
}


Bugsy 10-19-2021 23:36

Re: Question about order
 
You need to call SQL_NextRow( Query ) somewhere after SQL_ReadResult()

StrikerM 10-20-2021 03:15

Re: Question about order
 
DONE, THX


All times are GMT -4. The time now is 11:41.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.