Don't show name.
#1

Hello all. I have problem here:

Код:
stock TOP10(playerid)
{
	new String[ 200 ],savingstring[ 60 ];
	mysql_query("SELECT Name,Kills FROM players ORDER BY Kills DESC LIMIT 10");
	mysql_store_result();
	new AllPlayers;
	strcat(String,"Players TOP10 kills\n\n");
	while(mysql_retrieve_row())
	{
		AllPlayers++;
		new UserName[24],UserKills[11];
		sscanf(savingstring,"p<|>s[24]d",UserName,UserKills);

		format(String, sizeof(String), "%s%d. %s %d kills\n", String, AllPlayers, UserName, strval(UserKills));
	}
mysql_free_result();
ShowPlayerDialog( playerid, 21, DIALOG_STYLE_MSGBOX, "TOP 10", String, "OK", "" );
return 1;
}
All is well, but don't show player name:

ex:

Код:
1.  1 kills
Reply
#2

Try using
pawn Код:
new UserName[MAX_PLAYER_NAME]
Reply
#3

i don't think so. MAX_PLAYER_NAME is same 24.
Reply
#4

pawn Код:
new UserName[24];
GetPlayerName(playerid,UserName,sizeof(UserName));
Reply
#5

https://sampwiki.blast.hk/wiki/MySQL#mysql_fetch_row_format

That should point you in the right direction.
Reply
#6

And this is exactly why you should learn how to debug.

pawn Код:
sscanf(savingstring,"p<|>s[24]d",UserName,UserKills);
Where does 'savingstring' get assigned a value? Right, nowhere. How do you expect to get data from an empty string? Furthermore, you're trying to save an integer into a string (UserKills).
Reply
#7

What bad now?

Код:
stock TOP10(playerid)
{
	new String[ 200 ],savingstring[ 100 ];
	mysql_query("SELECT Kills,Deaths FROM players ORDER BY Kills DESC LIMIT 10");
	mysql_store_result();
	new AllPlayers;
	strcat(String,"TOP10 kills\n\n");
	while(mysql_retrieve_row())
	{
		AllPlayers++;
		new UserName[24],UserKills;
		mysql_fetch_row(savingstring);
		sscanf(savingstring, "p<|>s[24]i", UserName, UserKills);
		format(String, sizeof(String), "%s%d. %s %d kills\n", String, AllPlayers, UserName, UserKills);
	}
mysql_free_result();
ShowPlayerDialog( playerid, 8, DIALOG_STYLE_MSGBOX, "TOP 10", String, "OK", "" );
return 1;
}
Reply
#8

what's bad here?
Reply
#9

Now i try do diffrent, almost done, but problem here:

Код:
stock TOP10(playerid)
{
	new String[ 500 ],savingstring[ 1000 ];
	mysql_query("SELECT Name,Kills FROM players ORDER BY Kills DESC LIMIT 10");
	mysql_store_result();
	new Allplayers;
	strcat(String,"TOP10 kills\n\n");
	while(mysql_fetch_row_format(savingstring))
	{
		Allplayers ++;
		new Username[24],Userkills;
		mysql_fetch_row(savingstring);
		sscanf(savingstring, "p<|>s[24]i", Username, Userkills);
		format(String, sizeof(String), "%s%d. %s %d kills\n", String, Allplayers, Username, Userkills);
	}
mysql_free_result();
ShowPlayerDialog( playerid, 8, DIALOG_STYLE_MSGBOX, "TOP 10", String, "OK", "" );
return 1;
}
Код:
[11:20:12] >> mysql_query( Connection handle: 1 )
[11:20:12] CMySQLHandler::Query(SELECT Name,Kills FROM players ORDER BY Kills DESC LIMIT 10) - Successfully executed.
[11:20:12] >> mysql_store_result( Connection handle: 1 )
[11:20:12] CMySQLHandler::StoreResult() - Result was stored.
[11:20:12] >> mysql_fetch_row_format( Connection handle: 1 )
[11:20:12] CMySQLHandler::FetchRow() - Return: TEST1|50
[11:20:12] >> mysql_fetch_row_format( Connection handle: 1 )
[11:20:12] CMySQLHandler::FetchRow() - Return: TEST2|41
[11:20:12] >> mysql_fetch_row_format( Connection handle: 1 )
[11:20:12] CMySQLHandler::FetchRow() - Return: HOUSE|8
[11:20:12] >> mysql_fetch_row_format( Connection handle: 1 )
[11:20:12] >> mysql_fetch_row_format( Connection handle: 1 )
[11:20:12] >> mysql_free_result( Connection handle: 1 )
[11:20:12] CMySQLHandler::FreeResult() - Result was successfully free'd.
How you see here is all well.

IN MY GUI:

Код:
1. TEST2 - 41 kills
2. HOUSE - 8 kills
Where disappear TEST1?
Reply
#10

very hard to see and help?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)