13.10.2012, 14:54
But if i want return just score (index 2), kills (index 4) and deaths (index 5)? How return only these fields?
score | kills | deaths |
0 | 1 | 2 |
new temp[12], score, kills, deaths;
cache_get_row(0, 2, temp); score = strval(temp);
cache_get_row(0, 4, temp); kills = strval(temp);
cache_get_row(0, 5, temp); deaths = strval(temp);
printf("The player whose data was just loaded has %d score, %d kills and %d deaths.", score, kills, deaths);
mysql_format(ConnectionHandle, Query, "SELECT `IP`, `Pinigai`, `Banke`, `EXP`, `Level`, `Lytis`, `Skin`, `PosX`, `PosY`, `PosZ`, `PosA`, `Interjeras`, `Health`, `Armor`, `Ispejimai`, `Admin`, `Darbas`, `Gun0`, `Ammo0`, `Gun1`, `Ammo1`, `Gun2`, `Ammo2`, `Gun3`, `Ammo3`, `Gun4`, `Ammo4`, `Gun5`, `Ammo5`, `Gun6`, `Ammo6`, `Gun7`, `Ammo7`, `Gun8`, `Ammo8`, `Gun9`, `Ammo9`, `Gun10`, `Ammo10`, `Gun11`, `Ammo11` FROM `players` WHERE `Vardas` = '%e' AND `Slaptazodis` = '%e'", GetPlayerNameEx(playerid), buffer);
error 075: input line too long (after substitutions)
mysql_format(ConnectionHandle, Query, "SELECT `IP`, `Pinigai`, `Banke`, `EXP`, `Level`, `Lytis`, `Skin`, `PosX`, `PosY`, `PosZ`, `PosA`, `Interjeras`, `Health`, `Armor`, `Ispejimai`, `Admin`, `Darbas`, `Gun0`, `Ammo0`, `Gun1`, `Ammo1`, `Gun2`, `Ammo2`, `Gun3`, `Ammo3`, `Gun4`, `Ammo4`, `Gun5`, `Ammo5`, `Gun6`, `Ammo6`, `Gun7`, `Ammo7`, `Gun8`, `Ammo8`, `Gun9`, `Ammo9`, `Gun10`, `Ammo10`, `Gun11`, `Ammo11` FROM `players` WHERE `Vardas` = '%e' AND `Slaptazodis` = '%e'", GetPlayerNameEx(playerid), buffer);
mysql_format(ConnectionHandle, Query, "SELECT * FROM `players` WHERE `Vardas` = '%e' AND `Slaptazodis` = '%e'", GetPlayerNameEx(playerid), buffer);
Just change
Code:
mysql_format(ConnectionHandle, Query, "SELECT `IP`, `Pinigai`, `Banke`, `EXP`, `Level`, `Lytis`, `Skin`, `PosX`, `PosY`, `PosZ`, `PosA`, `Interjeras`, `Health`, `Armor`, `Ispejimai`, `Admin`, `Darbas`, `Gun0`, `Ammo0`, `Gun1`, `Ammo1`, `Gun2`, `Ammo2`, `Gun3`, `Ammo3`, `Gun4`, `Ammo4`, `Gun5`, `Ammo5`, `Gun6`, `Ammo6`, `Gun7`, `Ammo7`, `Gun8`, `Ammo8`, `Gun9`, `Ammo9`, `Gun10`, `Ammo10`, `Gun11`, `Ammo11` FROM `players` WHERE `Vardas` = '%e' AND `Slaptazodis` = '%e'", GetPlayerNameEx(playerid), buffer); Code:
mysql_format(ConnectionHandle, Query, "SELECT * FROM `players` WHERE `Vardas` = '%e' AND `Slaptazodis` = '%e'", GetPlayerNameEx(playerid), buffer); |
mysql_fetch_field_row does not contain cached data. I don't know why, but retrieving data from the cache is faster than mysql_X functions. Also, if you read the tutorial, results are automatically stored/freed so you don't have to use mysql_store_result or mysql_free_result.
|
TIMESTAMPDIFF(MINUTE, NOW(), DATE_ADD(Timestamp, INTERVAL Time MINUTE))
cache_get_row(0, 0, temp);
printf("Difference in minutes: %d", strval(temp));
stock GetPlayerAttribute(playerid)
{
new ID;
mysql_query("SELECT attribute FROM players_table WHERE name = 'Player'");
mysql_store_result();
if(mysql_num_rows())
{
new temp[12];
mysql_fetch_row(temp);
mysql_free_result();
return strval(temp);
}
mysql_free_result();
return false;
}
// tl;dr - this code is crappy...
i have:
Код:
cache_get_row(0, 4, temp), g_PlayerInfo[playerid][pHealth] = floatstr(temp); and, SetPlayerHealth(playerid, g_PlayerInfo[playerid][pHealth]); for cache_get_row(0, 5, temp), g_PlayerInfo[playerid][pLottoNr] = strval(temp); how make SetPlayer.. ?? |