SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 29/10/2014, 03:00 PM   #1
ipsLuan
High-roller
 
ipsLuan's Avatar
 
Join Date: Feb 2013
Location: Ilhéus, BA
Posts: 4,571
Reputation: 332
Default Login em MySQL

Bom, estou criando um sistema de registro em MySQL, já tentei criptografar a senha em WP_Hash mas ela diz que a senha está errada mesmo estando certa. E então, eu tentei criar pela minha lógica mas dá uns erros...

Código:
pawn Code:
switch(dialogid)
    {
        case dlogin:
        {
            if(!response) Kick(playerid);
            new query[100];
            pInfo[playerid][Password] = cache_get_field_content(0, "Password");
            format(Celulas, sizeof(Celulas), inputtext);
            if(Celulas == pInfo[playerid][Password])
            {
                mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
                mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
            }
            else
            {
                ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Logando...", "A senha digitada está errada, confire-a!", "Logar", "Sair");
            }
        }

Erro: 1.pwn(36 : warning 202: number of arguments does not match definition
1.pwn(370) : error 033: array must be indexed (variable "Celulas")

O que poderia ser?
__________________

Precisando de algum sistema? Chame!

ipsLuan is offline   Reply With Quote
Old 29/10/2014, 03:07 PM   #2
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Europe
Posts: 7,185
Reputation: 803
Default Re: Login em MySQL

deve usar isto para comparar o inputtext com a senha

http://wiki.sa-mp.com/wiki/Strcmp
PT is offline   Reply With Quote
Old 29/10/2014, 03:09 PM   #3
ipsLuan
High-roller
 
ipsLuan's Avatar
 
Join Date: Feb 2013
Location: Ilhéus, BA
Posts: 4,571
Reputation: 332
Default Re: Login em MySQL

Já mudei o código mas continua dando erros...
pawn Code:
case dlogin:
        {
            if(!response) Kick(playerid);
            new query[100];
            cache_get_field_content(0, "Password", pInfo[playerid][Password]);
            format(Celulas, 129, inputtext);
            if(Celulas == pInfo[playerid][Password])
            {
                mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
                mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
            }
            else
            {
                ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Logando...", "A senha digitada está errada, confire-a!", "Logar", "Sair");
            }
        }
__________________

Precisando de algum sistema? Chame!

ipsLuan is offline   Reply With Quote
Old 29/10/2014, 03:14 PM   #4
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Europe
Posts: 7,185
Reputation: 803
Default Re: Login em MySQL

cada vez pior este povo, custa assim tanto estudar um pouco?

pawn Code:
case dlogin:
{
    if(!response) Kick(playerid);
   
    cache_get_field_content(0, "Password", pInfo[playerid][Password]);
    if(strcmp(inputtext, pInfo[playerid][Password]) == 0)
    {
        new query[100];
        mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
        mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);    
    }
    else ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Logando...", "A senha digitada está errada, confire-a!", "Logar", "Sair");          
}
-.-
PT is offline   Reply With Quote
Old 29/10/2014, 03:17 PM   #5
ipsLuan
High-roller
 
ipsLuan's Avatar
 
Join Date: Feb 2013
Location: Ilhéus, BA
Posts: 4,571
Reputation: 332
Default Re: Login em MySQL

Fiz desse mesmo jeito, mas não obtive resultados.
__________________

Precisando de algum sistema? Chame!

ipsLuan is offline   Reply With Quote
Old 29/10/2014, 03:32 PM   #6
ReyMysterio
Gangsta
 
ReyMysterio's Avatar
 
Join Date: Sep 2014
Location: Madeira, Portugal
Posts: 672
Reputation: 55
Default Re: Login em MySQL

o pInfo está definido como string:


pawn Code:
//Exemplo

enum Informacoes
{
    password[64]
}

new pInfo[MAX_PLAYERS][Informacoes];
__________________
ReyMysterio is offline   Reply With Quote
Old 29/10/2014, 03:38 PM   #7
ipsLuan
High-roller
 
ipsLuan's Avatar
 
Join Date: Feb 2013
Location: Ilhéus, BA
Posts: 4,571
Reputation: 332
Default Re: Login em MySQL

Sim, na enum PDATA o Password está como string e a variavél também.

pawn Code:
enum PDATA
{
    ID,
    Password[129],
    Admin,
    VIP,
    Money,
    Float:posX,
    Float:posY,
    Float:posZ

}
new pInfo[MAX_PLAYERS][PDATA];
__________________

Precisando de algum sistema? Chame!

ipsLuan is offline   Reply With Quote
Old 29/10/2014, 03:43 PM   #8
ReyMysterio
Gangsta
 
ReyMysterio's Avatar
 
Join Date: Sep 2014
Location: Madeira, Portugal
Posts: 672
Reputation: 55
Default Re: Login em MySQL

Tenta assim:

pawn Code:
case dlogin:
        {
            if(!response) Kick(playerid);
            new query[100];
            format( query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' AND `Password` = '%s' LIMIT 1", Name[playerid], inputtext);
            mysql_function_query(mysql, query, "OnAccountLoad", "i", playerid);
        }

//Na public da query
       
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields);
    if(rows)
    {
        //Se a senha estiver correta
    }
    else
    {
        //Se a senha estiver incorreta
    }
}
__________________
ReyMysterio is offline   Reply With Quote
Old 29/10/2014, 03:55 PM   #9
ipsLuan
High-roller
 
ipsLuan's Avatar
 
Join Date: Feb 2013
Location: Ilhéus, BA
Posts: 4,571
Reputation: 332
Default Re: Login em MySQL

A mesma coisa, não há um outro modo de fazer não?
__________________

Precisando de algum sistema? Chame!

ipsLuan is offline   Reply With Quote
Old 29/10/2014, 06:04 PM   #10
ReyMysterio
Gangsta
 
ReyMysterio's Avatar
 
Join Date: Sep 2014
Location: Madeira, Portugal
Posts: 672
Reputation: 55
Default Re: Login em MySQL

tenta aumentar o tamanho da variável query para 1024

@EDIT

Se continuar o erro fala o erros que tá dando.
__________________
ReyMysterio is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MYsql login/register won't login KickInTheMick Scripting Help 5 13/12/2013 06:07 PM
MySQL login help. Edvin Scripting Help 0 04/06/2012 09:34 AM
login with MySQL Ribber Help Archive 0 13/09/2010 03:52 PM


All times are GMT. The time now is 04:31 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.