08.11.2017, 13:38
hello guys, i'm trying to load some data from two tables, but only load 1 table... this is my code
please help me i can't load the health, armour, posx y or z from the user's table... i don't know so much of mysql but really i need help
Код:
/////on query
forward OnQueryFinish(resultid, extraid, ConnectionHandle);
public OnQueryFinish(resultid, extraid, ConnectionHandle)
{
new Rows, Field, string[256];
if(resultid != 0)
{
cache_get_data(Rows, Field);
}
switch(resultid)
{
case 1:
{
if(Rows == 1)
{
new content[20],Query[256];
//////////////////Accounts
//format(Query, sizeof(Query), "SELECT `password` = MD5(`%s`) FROM `accounts` WHERE name='%s'", gacinfo[extraid][gpassword],pName);
cache_get_field_content(0, "id_account", content); gacinfo[extraid][id] = strval(content);
///PlayerInfo[extraid][id] = gacinfo[extraid][id];
cache_get_field_content(0, "password", gacinfo[extraid][gpassword]);
cache_get_field_content(0, "email", gacinfo[extraid][email]);
cache_get_field_content(0, "taxi", content); Checktaxi[extraid] = strval(content);
cache_get_field_content(0, "health", content); PlayerInfo[extraid][health] = floatstr(content);
L
/////////////////Users
//format(Query, sizeof(Query), "SELECT `score` = '%d', `skin` = '%d' FROM `users` WHERE account_id='%d'", PlayerInfo[extraid][score],PlayerInfo[extraid][skin],gacinfo[extraid][id]);
//mysql_function_query(Conecction, Query, true, "OnQueryFinish", "ii", 0, extraid);
//format(Query, sizeof(Query), "SELECT `health` = '%f', `armour` = '%f', `posx` = '%f', `posy` = '%f', `posz` = '%f', `rot` = '%f' FROM `users` WHERE account_id='%d'", PlayerInfo[extraid][health],PlayerInfo[extraid][armour],PlayerInfo[extraid][posx],PlayerInfo[extraid][posy],PlayerInfo[extraid][posz],PlayerInfo[extraid][rot],gacinfo[extraid][id]);
mysql_function_query(Conecction, Query, true, "OnQueryFinish", "ii", 0, extraid);
///////////////Jobs
cache_get_field_content(0, "id_jobs", content); PlayerInfo[extraid][id] = strval(content);
///////////////Cars
cache_get_field_content(0, "id_cars", content); PlayerInfo[extraid][id] = strval(content);
new gstring[128];
format(gstring, sizeof(gstring), "{D0FF00}[TNW] {FFFFFF}Tu vida es %f y tu pass es %d", extraid, PlayerInfo[extraid][health], gacinfo[extraid][id]);
SendClientMessage(extraid, -1, gstring);
SetSpawnInfo(extraid,0,PlayerInfo[extraid][skin], PlayerInfo[extraid][posx],PlayerInfo[extraid][posy],PlayerInfo[extraid][posz],PlayerInfo[extraid][rot],27,90000,0,0,0,0);
SetPlayerScore(extraid, PlayerInfo[extraid][score]);
SetPlayerArmour(extraid, PlayerInfo[extraid][armour]);
SetPlayerHealth(extraid, 100);
SpawnPlayer(extraid);
}
else if(!Rows)
{
Kick(extraid);
}
}
case 2:
{
if(Rows == 1)
{
new pName[24]; GetPlayerName(extraid, pName, 24);
cache_get_field_content(0, "email", gacinfo[extraid][email]);
format(string, sizeof(string), "[TNW] Esta cuenta esta registrada:", pName);
ShowPlayerDialog(extraid, LOGIN, DIALOG_STYLE_INPUT,"Ingresa tu mail:",string,"Siguiente","Salir");
}
else if(!Rows)
{
new pName[24]; GetPlayerName(extraid, pName, 24);
format(string, sizeof(string), "[TNW] Esta cuenta no esta registrada.", pName);
ShowPlayerDialog(extraid, REGISTRO2, DIALOG_STYLE_INPUT,"Ingresa tu mail:",string,"Siguiente","Salir");
}
}
}
return 1;
}
///DIALOG RESPONSE
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new string[256];
new pName[24], Query[256]; GetPlayerName(playerid, pName, 24);
switch(dialogid)
{
case LOGIN:
{
if(!response)
{
Kick(playerid);
}
if(IsNull(inputtext))
{
SendClientMessage(playerid, -1, "[TNW] Escribe tъ email");
format(string, sizeof(string), "[TNW] Error completa el espacio.");
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "email:",string,"Siguiente", "salir");
}
else
{
if(strcmp(gacinfo[playerid][email], inputtext, true, 129) == 0)
{
format(string, sizeof(string), "[TNW] Ingresa tъ contraseсa");
ShowPlayerDialog(playerid, LOGIN2, DIALOG_STYLE_PASSWORD,"contraseсa:",string,"Siguiente","Salir");
}
else
{
SendClientMessage(playerid, -1, "[TNW] Error email incorrecto.");
format(string, sizeof(string), "[TNW] Error email Invalido.");
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "email:",string,"Siguiente", "salir");
}
}
}
case LOGIN2:
{
if(!response)
{
Kick(playerid);
}
if(IsNull(inputtext))
{
SendClientMessage(playerid, -1, "[TNW] Escribe tъ contraseсa");
format(string, sizeof(string), "[TNW] Error completa el espacio.");
ShowPlayerDialog(playerid, LOGIN2, DIALOG_STYLE_INPUT, "email:",string,"Siguiente", "salir");
}
else
{
if(strcmp(gacinfo[playerid][gpassword], inputtext, true, 128) == 0)
{
format(Query, sizeof(Query), "SELECT * FROM `accounts` WHERE `name` = '%s'", pName);
mysql_function_query(Conecction, Query, true, "OnQueryFinish", "ii", 1, playerid);
}
else
{
SendClientMessage(playerid, -1, "[TNW] Error contraseсa incorrecta.");
format(string, sizeof(string), "[TNW] Error contraseсa Invalida.");
ShowPlayerDialog(playerid, LOGIN2, DIALOG_STYLE_PASSWORD, "contraseсa:",string,"Entrar", "salir");
}
}
}
case REGISTRO:
{
if(!response)
{
SendClientMessage(playerid, -1, "Kicked");
Kick(playerid);
}
if(response)
{
if(!strlen(inputtext))
{
Kick(playerid);
}
new string2[129];
NewRegister(playerid);
format(string2, sizeof(string2), "%s", inputtext); gacinfo[playerid][gpassword] = string2;
format(Query, sizeof(Query), "INSERT INTO `accounts` (name, password, email) VALUES ('%s', '%s', '%s')",pName, gacinfo[playerid][gpassword],gacinfo[playerid][email]);
mysql_function_query(Conecction, Query, true, "OnAccountRegister", "ii", 0, playerid);
}
}
case REGISTRO2:
{
if(!response)
{
SendClientMessage(playerid, -1, "Kicked");
Kick(playerid);
}
if(response)
{
if(!strlen(inputtext))
{
Kick(playerid);
}
new string2[129];
format(string2, sizeof(string2), "%s", inputtext); gacinfo[playerid][email] = string2;
format(string, sizeof(string), "[TNW] Seleeciona tu genero");
ShowPlayerDialog(playerid, REGISTRO3, DIALOG_STYLE_LIST,"Genero:","Hombre\nMujer","Entrar","Salir");
}
}
case REGISTRO3:
{
if(!response)
{
SendClientMessage(playerid, -1, "Kicked");
Kick(playerid);
}
if(response)
{
switch(listitem)
{
case 0: gacinfo[playerid][gender] = 1;
case 1: gacinfo[playerid][gender] = 2;
}
format(string, sizeof(string), "[TNW] Ingresa una contraseсa");
ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_PASSWORD,"Contraseсa:",string,"Siguiente","Salir");
}
}
}
return 1;
}
/////ACOUNT REGISTER
forward OnAccountRegister(playerid);
public OnAccountRegister(playerid)
{
gacinfo[playerid][id] = mysql_insert_id();
printf("[Registro] Se ha creado una nueva cuenta, ID de la base de datos: [%d]", gacinfo[playerid][id]);
new Query[256];
format(Query, sizeof(Query), "INSERT INTO `users` (account_id) VALUES ('%d')",gacinfo[playerid][id]);
mysql_function_query(Conecction, Query, true, "OnQueryFinish", "ii", 0, playerid);
}





