CMD:top(playerid)
{
mysql_query(connection, "SELECT * `RESPECT` FROM `players` WHERE `RESPECT` > 0 ORDER BY `RESPECT` DESC LIMIT 0, 10", true);
new gString[256], name[MAX_PLAYER_NAME];
new rows = cache_num_rows();
if (rows)
{
for (new i = 0; i < rows; i ++)
{
cache_get_value(i, "USERNAME", pInfo[playerid][Name], MAX_PLAYER_NAME);
cache_get_value_int(i, "RESPECT", pInfo[playerid][Respect]);
format(gString, sizeof(gString), "%s%s %d Respect\n", gString, name, pInfo[playerid][Respect]);
}
ShowPlayerDialog(playerid, DIALOG_TOP, DIALOG_STYLE_LIST, "Top Respect", gString, "Ok", "");
}
return 1;
}
C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(3927) : error 017: undefined symbol "connection"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
mysql_query(connection, "SELECT * `RESPECT` FROM `players` WHERE `RESPECT` > 0 ORDER BY `RESPECT` DESC LIMIT 0, 10", true);
CMD:top(playerid)
{
new query[256];
mysql_format(Database, query, sizeof(query), "SELECT * `RESPECT` FROM `players` WHERE `RESPECT` > 0 ORDER BY `RESPECT` DESC LIMIT 0, 10", true);
mysql_tquery(Database, query);
new gString[256], name[MAX_PLAYER_NAME];
new rows = cache_num_rows();
if (rows)
{
for (new i = 0; i < rows; i ++)
{
cache_get_value(i, "USERNAME", pInfo[playerid][Name], MAX_PLAYER_NAME);
cache_get_value_int(i, "RESPECT", pInfo[playerid][Respect]);
format(gString, sizeof(gString), "%s%s %d Respect\n", gString, name, pInfo[playerid][Respect]);
}
ShowPlayerDialog(playerid, DIALOG_TOP, DIALOG_STYLE_LIST, "Top Respect", gString, "Ok", "");
}
return 1;
}
new MySQLOpt: option_id = mysql_init_options(); mysql_set_option(option_id, AUTO_RECONNECT, true); // it automatically reconnects when loosing connection to mysql server SQL = mysql_connect(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DB, option_id); // AUTO_RECONNECT is enabled for this connection handle only
mysql_format(query, sizeof(query), "SELECT * `RESPECT` FROM `players` WHERE `RESPECT` > 0 ORDER BY `RESPECT` DESC LIMIT 0, 10", true);
C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(3928) : error 035: argument type mismatch (argument 1)
C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(3928) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Errors.
Try this if you're using MYSQL R41+
PHP код:
|
#define DIALOG_TOP ( 19 )
CMD:top10(playerid, params[])
{
new query[256];
mysql_format(Database, query, sizeof(query), "SELECT * `RESPECT` FROM `players` WHERE `RESPECT` > 0 ORDER BY `RESPECT` DESC LIMIT 0, 10", true);
mysql_tquery(Database, query);
new gString[256];
new rows = cache_num_rows();
if (rows)
{
for (new i = 0; i < rows; i ++)
{
cache_get_value(i, "USERNAME", pInfo[playerid][Name], MAX_PLAYER_NAME);
cache_get_value_int(i, "RESPECT", pInfo[playerid][Respect]);
format(gString, sizeof(gString), "%s%i %i Respect\n", gString, pInfo[playerid][Name], pInfo[playerid][Respect]);
}
ShowPlayerDialog(playerid, DIALOG_TOP, DIALOG_STYLE_LIST, "Top Respect", gString, "Ok", "");
}
return 1;
}
SELECT * `RESPECT` FROM `players` WHERE `RESPECT` > 0 ORDER BY `RESPECT` DESC LIMIT 0, 10
SELECT * `RESPECT` FROM `players` WHERE `RESPECT` > 0 ORDER BY `RESPECT` DESC LIMIT 0, 10
SELECT `RESPECT` FROM `players` WHERE `RESPECT` > 0 ORDER BY `RESPECT` DESC LIMIT 0, 10
CMD:top10(playerid, params[])
{
new query[256];
mysql_format(Database, query, sizeof(query), "SELECT * FROM `players` WHERE `RESPECT` > 0 ORDER BY `RESPECT` DESC LIMIT 10", true);
mysql_tquery(Database, query);
new gString[256];
new rows = cache_num_rows();
if (rows)
{
for (new i = 0; i < rows; i ++)
{
cache_get_value(i, "USERNAME", pInfo[playerid][Name], MAX_PLAYER_NAME);
cache_get_value_int(i, "RESPECT", pInfo[playerid][Respect]);
format(gString, sizeof(gString), "%s%i %i Respect\n", gString, pInfo[playerid][Name], pInfo[playerid][Respect]);
}
ShowPlayerDialog(playerid, DIALOG_TOP, DIALOG_STYLE_LIST, "Top Respect", gString, "Ok", "");
}
else
{
SendClientMessage(playerid, -1, "No top players were found at this time, retrieve in some hours later");
}
return 1;
}
SELECT * FROM `players` WHERE `RESPECT` > 0 ORDER BY `RESPECT` DESC LIMIT 10