new strArmas[256]; format(strArmas, 256, "SELECT `pWeapon1`, `pAmmo1`, `pWeapon2`, `pAmmo2`, `pWeapon3`, `pAmmo3`, `pWeapon4`, `pAmmo4`, `pWeapon5`, `pAmmo5`, `pWeapon6`, `pAmmo6`, `pWeapon7`, `pAmmo7`, `pWeapon8`, `pAmmo8`, `Weapon9`, `pAmmo9`, `pWeapon10`, `pAmmo10`, `pWeapon11`, `pAmmo11`, `pWeapon1`, `pAmmo12`, `pWeapon13`, `pAmmo13` FROM `accounts` WHERE `ID` = '%d'", PlayerInfo[playerid][pID]); mysql_tquery(mySqlHandle, strArmas, "SetandoArmas", "d", playerid);
forward SetandoArmas(playerid); public SetandoArmas(playerid) { new rows; cache_get_row_count(rows); if(rows) { for(new i; i < rows; i++) { cache_get_value_name_int(i,"pWeapon1", PlayerInfo[playerid][pWeapon1]); cache_get_value_name_int(i,"pAmmo1", PlayerInfo[playerid][pAmmo1]); cache_get_value_name_int(i,"pWeapon2", PlayerInfo[playerid][pWeapon2]); cache_get_value_name_int(i,"pAmmo2", PlayerInfo[playerid][pAmmo2]); cache_get_value_name_int(i,"pWeapon3", PlayerInfo[playerid][pWeapon3]); cache_get_value_name_int(i,"pAmmo3", PlayerInfo[playerid][pAmmo3]); cache_get_value_name_int(i,"pWeapon4", PlayerInfo[playerid][pWeapon4]); cache_get_value_name_int(i,"pAmmo4", PlayerInfo[playerid][pAmmo4]); cache_get_value_name_int(i,"pWeapon5", PlayerInfo[playerid][pWeapon5]); cache_get_value_name_int(i,"pAmmo5", PlayerInfo[playerid][pAmmo5]); cache_get_value_name_int(i,"pWeapon6", PlayerInfo[playerid][pWeapon6]); cache_get_value_name_int(i,"pAmmo6", PlayerInfo[playerid][pAmmo6]); cache_get_value_name_int(i,"pWeapon7", PlayerInfo[playerid][pWeapon7]); cache_get_value_name_int(i,"pAmmo7", PlayerInfo[playerid][pAmmo7]); cache_get_value_name_int(i,"pWeapon8", PlayerInfo[playerid][pWeapon8]); cache_get_value_name_int(i,"pAmmo8", PlayerInfo[playerid][pAmmo8]); cache_get_value_name_int(i,"pWeapon9", PlayerInfo[playerid][pWeapon9]); cache_get_value_name_int(i,"pAmmo9", PlayerInfo[playerid][pAmmo9]); cache_get_value_name_int(i,"pWeapon10", PlayerInfo[playerid][pWeapon10]); cache_get_value_name_int(i,"pAmmo10", PlayerInfo[playerid][pAmmo10]); cache_get_value_name_int(i,"pWeapon11", PlayerInfo[playerid][pWeapon11]); cache_get_value_name_int(i,"pAmmo11", PlayerInfo[playerid][pAmmo11]); cache_get_value_name_int(i,"pWeapon12", PlayerInfo[playerid][pWeapon12]); cache_get_value_name_int(i,"pAmmo12", PlayerInfo[playerid][pAmmo12]); cache_get_value_name_int(i,"pWeapon13", PlayerInfo[playerid][pWeapon13]); cache_get_value_name_int(i,"pAmmo13", PlayerInfo[playerid][pAmmo13]); } GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon1], PlayerInfo[playerid][pAmmo1]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon2], PlayerInfo[playerid][pAmmo2]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon3], PlayerInfo[playerid][pAmmo3]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon4], PlayerInfo[playerid][pAmmo4]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon5], PlayerInfo[playerid][pAmmo5]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon6], PlayerInfo[playerid][pAmmo6]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon7], PlayerInfo[playerid][pAmmo7]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon8], PlayerInfo[playerid][pAmmo8]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon9], PlayerInfo[playerid][pAmmo9]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon10], PlayerInfo[playerid][pAmmo10]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon11], PlayerInfo[playerid][pAmmo11]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon12], PlayerInfo[playerid][pAmmo12]); GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon13], PlayerInfo[playerid][pAmmo13]); } }
EM THREAD_LOAD_ACCOUNTS do OnQueryFinish: for (new i = 0; i < 13; i ++) { cache_get_value_name_int(0, "pWeapon%d", PlayerInfo[playerid][pWeapon][i]); cache_get_value_name_int(0, "pAmmo%d", PlayerInfo[playerid][pAmmo][i]); }
SetarArmas(playerid){ for (new i = 0; i < 13; i ++) if (PlayerInfo[playerid][pWeapon][i] > 0 && PlayerInfo[playerid][pAmmo][i] > 0) { GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon][i], PlayerInfo[playerid][pAmmo][i]); } return 1; }
public SetandoArmas(playerid)
{
new rows;
cache_get_row_count(rows);
if(rows)
{
for(new i = 0; i < 13; i++)//Percorrendo os slots de armas disponнveis
{
new strWeapon[64];//String para formatar o nome do campo
format(strWeapon, 64, "pWeapon%d", i+1);//Formatando a string para acessar o campo pWeapon consultado
PlayerInfo[playerid][pWeapon][i] = cache_get_field_content_int(0, strWeapon);
format(strWeapon, 64, "pAmmo%d", i+1);//Formatando a string para acessar o campo pAmmo consultado
PlayerInfo[playerid][pAmmo][i] = cache_get_field_content_int(0, strWeapon);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon][i], PlayerInfo[playerid][pAmmo][i]);
}
}
}
if(rows)
{
Bom, eu modifiquei esse cуdigo de acordo com o que vocк postou nesta ъltima resposta:
PHP код:
Teste e nos diga se funcionou corretamente. |
Se as linhas consultadas na database existem.
Nem dб pra fazer isso aн mano, eu nгo tenho a versгo R39 do MySQL. Tф com a ъltima versгo e o gamemode tб todo na ъltima versгo. cache_get_field_content_int jб nгo existe mais. |
if(row > 0) {}
Se as linhas consultadas na database existem.
Nem dб pra fazer isso aн mano, eu nгo tenho a versгo R39 do MySQL. Tф com a ъltima versгo e o gamemode tб todo na ъltima versгo. cache_get_field_content_int jб nгo existe mais. |
forward SetandoArmas(playerid);
public SetandoArmas(playerid)
{
new rows;
cache_get_row_count(rows);
if(rows)
{
for(new i = 0; i < 13; i++)
{
new strWeapon[64];
format(strWeapon, 64, "pWeapon%d", i+1);//Formatando a string para acessar o campo pWeapon consultado
cache_get_value_name_int(0, strWeapon, PlayerInfo[playerid][pWeapon][i]);
format(strWeapon, 64, "pAmmo%d", i+1);//Formatando a string para acessar o campo pAmmo consultado
cache_get_value_name_int(0, strWeapon, PlayerInfo[playerid][pAmmo][i]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon][i], PlayerInfo[playerid][pAmmo][i]);
}
}
}
if(var < 0 || var > 0)//Para nъmeros if(var == true)//Para variбveis lуgicas
if(!IsPlayerConnected(playerid))
Bom, eu modifiquei esse cуdigo de acordo com o que vocк postou nesta ъltima resposta:
PHP код:
Teste e nos diga se funcionou corretamente. |
[21:43:07] [DEBUG] mysql_tquery(1, "SELECT `pWeapon0`, `pAmmo0`, `pWeapon1`, `pAmmo1`, `pWeapon2`, `pAmmo2`, `pWeapon3`, `pAmmo3`, `pWeapon4`, `pAmmo4`, `pWeapon5`, `pAmmo5`, `pWeapon6`, `pAmmo6`, `pWeapon7`, `pAmmo7`, `pWeapon8`, `pAmmo8`, `Weapon9`, `pAmmo9`, `pWeapon10`, `pAmmo10`, `pWea", "SetandoArmas", "iii") [21:43:07] [DEBUG] CCallback::Create(amx=0x295f2d8, name='SetandoArmas', format='iii', params=0x9b3fae4, param_offset=5) [21:43:07] [DEBUG] CCallback::Create - callback index for 'SetandoArmas': 477 [21:43:07] [ERROR] mysql_tquery: callback error: parameter count does not match format specifier length
SELECT * FROM accounts WHERE ID='%d'