Raised This Month: $45 Target: $400
 11% 

Question about order


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StrikerM
Member
Join Date: Nov 2019
Old 10-19-2021 , 23:16   Question about order
Reply With Quote #1

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;
}
StrikerM is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-20-2021 , 00:36   Re: Question about order
Reply With Quote #2

You need to call SQL_NextRow( Query ) somewhere after SQL_ReadResult()
__________________
Bugsy is offline
StrikerM
Member
Join Date: Nov 2019
Old 10-20-2021 , 04:15   Re: Question about order
Reply With Quote #3

DONE, THX

Last edited by StrikerM; 10-20-2021 at 04:42.
StrikerM is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:02.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode