[Ayuda] problema al cargar..
#1

Hola buenas. Estoy tratando de hacer una funciуn que cargue las variables de una base de datos... O sea, mi servidor es todo por .ini pero quiero probar a ver si puedo cargar una sola variable asн hago unos sistemas que tengo en mente. El tema es que intento de todas las maneras y no puedo.. Alguien me podrнa decir como es?

Este es mi codigo

Код:
new PruebaGenero[MAX_PLAYERS];

PruebaGenero[playerid] = 0;

forward CheckPlayer(playerid);
public CheckPlayer(playerid)
{
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
new Query[365];
format(Query, sizeof(Query), "SELECT * FROM `usuarios` WHERE `Username` = '%s'", sendername);
mysql_function_query(CMySQL2, Query, true, "OnQueryFinished", "ii", 1, playerid);
return 1;
}

CMD:prueba2(playerid, params[])
{
CheckPlayer(playerid);
return 1;
}

CMD:prueba(playerid, params[])
{
new string[256];
format(string, sizeof(string), "PruebaGenero[MAX_PLAYERS] = %d", PruebaGenero[playerid]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}

forward OnQueryFinished(resultid, extraid, ConnectionHandle);
public OnQueryFinished(resultid, extraid, ConnectionHandle)
{
    new Rows, Field;
    if(resultid != 0)
    {
        cache_get_data(Rows, Field);
    }
    switch(resultid)
    {
        case 1:
        {
            if(Rows == 1)
            {
            cache_get_field_content(0, "Genero", PruebaGenero[extraid]);
            }
            else if(!Rows)            
{

               //
            }
        }
    }
    return 1;
}
Eso serнa el codigo.. Lo que hago yo es primero poner /prueba asн por default me sale el "PruebaGenero" en 0 y despuйs pongo /prueba2 y pongo /prueba a ver si se cambiу... (El genero en la db estб en 1)

Si quieren la conexiуn del MySQL (CMySQL2) es esta:

Код:
static CMySQL2;
#define MySQL_HOST2 "localhost"
#define MySQL_USER2 "root" 
#define MySQL_PASSWORD2 "" 
#define MySQL_DATABASE2 "test"

function ConectarMySQL2()
{
CMySQL2 = mysql_connect(MySQL_HOST2, MySQL_USER2, MySQL_DATABASE2, MySQL_PASSWORD2);
print("[MYSQL] Conectando test...");


if(mysql_ping(CMySQL2) == -1) print("[MYSQL] Desconectado.");
if(mysql_ping(CMySQL2) != -1) print("[MYSQL] Conectado.");
}

ConectarMySQL2();
Reply
#2

Aviso, uso MySQL R7.
Reply
#3

Ayuda..
Reply
#4

Arriba
Reply
#5

PHP код:
forward OnQueryFinished(resultidextraidConnectionHandle);
public 
OnQueryFinished(resultidextraidConnectionHandle)
{
    new 
RowsField;
    if(
resultid != 0)
    {
        
cache_get_data(RowsField);
    }
    switch(
resultid)
    {
        case 
1:
        {
            if(
Rows == 1)
            {
                new 
tmp[10];
                
cache_get_field_content(0"Genero"tmp);
                
PruebaGenero[extraid] = strval(tmp);
            }
            else if(!
Rows)
            {
               
//
            
}
        }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)