[MYSQL]їA dуnde voy mal?
#1

Yo estoy tratando de hacer funcionar un sistema de MySQL, mirando a la wiki y algunos cуdigos bбsicos, estб compilando, pero tengo un problema:
Cuando registro en el servidor, la cuenta no se guarda en la base de datos !! Hay algo mal aquн?

DB:
http://i.imgur.com/GII8c57.png
http://i.imgur.com/lTC3ev5.png

Cuando utilizo las funciones:

public OnPlayerDisconnect(playerid, reason)
pawn Код:
if(Logado[playerid] == 1) {
        SaveStats(playerid);
    }
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
pawn Код:
if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            if(!strlen(inputtext) || strlen(inputtext) > 128)
            {
                new string1[128];
                SendClientMessage(playerid, COLOR_RED, "[ERROR]: You must insert a password between 1-128 characters!");
                format(string1, sizeof(string1), "Welcome %s\nPlease register to contiune.",PlayerName(playerid));
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", string1, "Register", "Quit");
            }
            else if(strlen(inputtext) > 0 && strlen(inputtext) < 128)
            {
                new escpass[100];
                mysql_escape_string(inputtext, escpass);
                MySQL_Register(playerid, escpass);
            }
        }
        if(!response)
        {
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_MSGBOX, "Kicked - Notice", "You must register to play", "Close", "");
            Kick(playerid);
        }
    }

    if(dialogid == DIALOG_LOGIN)
    {
        if(!response)
        {
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_MSGBOX, "Kicked - Notice", "You must login to play", "Close", "");
            Kick(playerid);
        }
        if(response)
        {
            new query[200], rows, fields;
            mysql_format(ConnectSQL, query, sizeof(query), "SELECT `Username` FROM players WHERE Username = '%s' AND Password = SHA1('%e')", PlayerName(playerid), inputtext);
            mysql_query(ConnectSQL, query);
            cache_get_data(rows, fields);

            if(rows) MySQL_Login(playerid);

            if(!rows)
            {
                InvalidLogins[playerid]++;
                if(InvalidLogins[playerid]==4)
                {
                    Kick(playerid);
                }
                else
                {
                    new str1[256];
                    format(str1,sizeof(str1),"{FFFF00}Wrong password Attempt\n\n{00CC00}Dear %s, Enter Your Password:\n{FFFF00}Login chance: (%d/4)",PlayerName(playerid),4-InvalidLogins[playerid]);
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login Panel",str1,"Login","Quit");
                }
            }

        }
    }
pawn Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new Query[512], IP[16];
    GetPlayerIp(playerid, IP, sizeof(IP));
    strcat(Query,"INSERT INTO `players`(`Username`,`Senha`)");
    strcat(Query,"VALUES ('%s', SHA1('%s'),0,0,0,0,0,0,0,0,0,0,'%d/%d/%d')");
    mysql_format(ConnectSQL,Query,sizeof(Query),Query,PlayerName(playerid),passwordstring);
    mysql_query(ConnectSQL,Query,false);
    Logado[playerid] = 1;
    GivePlayerMoney(playerid, 5000);
    return 1;
}

stock MySQL_Login(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        new Query[512], savestr[50], rows, fields;
        mysql_format(ConnectSQL,Query, sizeof(Query), "SELECT * FROM `players` WHERE `Username` = '%s'", PlayerName(playerid));
        mysql_query(ConnectSQL,Query);
        cache_get_data(rows, fields);
        if(rows)
        {
            cache_get_field_content(0, "money", savestr);           money[playerid] = strval(savestr);
            cache_get_field_content(0, "admin", savestr);           admin[playerid] = strval(savestr);
            cache_get_field_content(0, "VIP", savestr);             VIP[playerid] = strval(savestr);
            cache_get_field_content(0, "deaths", savestr);          deaths[playerid] = strval(savestr);
            Logado[playerid] = 1;
        }
        Logado[playerid] = 1;
    }
    return 1;
}
Esa parte Cogн base, no lo entiendo, me parece detener encryptaзгo
puede estar aquн porque yo no entiendo esta parte
pawn Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new Query[512], IP[16];
    GetPlayerIp(playerid, IP, sizeof(IP));
    strcat(Query,"INSERT INTO `players`(`Username`,`Senha`)");
    strcat(Query,"VALUES ('%s', SHA1('%s'),0,0,0,0,0,0,0,0,0,0,'%d/%d/%d')");
    mysql_format(ConnectSQL,Query,sizeof(Query),Query,PlayerName(playerid),passwordstring);
    mysql_query(ConnectSQL,Query,false);
Reply
#2

Prueba asн:

Quote:

stock MySQL_Register(playerid, passwordstring[])
{
new Query[512], IP[16];
GetPlayerIp(playerid, IP, sizeof(IP));
format(Query,"INSERT INTO `players`(`Username`,`Senha`) VALUES ('%s', SHA1('%s'))");
mysql_format(ConnectSQL,Query,sizeof(Query),Query, PlayerName(playerid),passwordstring);
mysql_query(ConnectSQL,Query,false);
Logado[playerid] = 1;
GivePlayerMoney(playerid, 5000);
return 1;
}

no se que mysql usas pero tenнas la consulta mal, te recomiendo usar mysql r7.
Reply
#3

LOl Muy mal el sistema pawno te recomiendo usar

format(query, 200, "UPDATE SET `

Update Mas Set, ya que solo tienes funcion Insert y no update puedo ayudarte por skype.
Reply
#4

Asн:
Quote:

stock MySQL_Register(playerid, passwordstring[])
{
new Query[512], IP[16];
GetPlayerIp(playerid, IP, sizeof(IP));
format(Query,sizeof(Query),"INSERT INTO `players`(`Username`,`Senha`) VALUES ('%s', SHA1('%s'))", PlayerName(playerid), passwordstring);
mysql_query(ConnectSQL,Query,false);
Logado[playerid] = 1;
GivePlayerMoney(playerid, 5000);
return 1;
}

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)