[Ajuda] Problemas no MySQL
#6

Para registro e login:

PHP Code:
if(playertextid == Textdraw16){
        
ocultartdlogin(playerid);
        
ShowPlayerDialog(playeridDialogSenhaDIALOG_STYLE_PASSWORD"Coloque sua senha""Sua senha deve conter no mнnimo 5 digitos\ne no maximo 20 digitos!""Ok""");
    }
    if(
playertextid == Textdraw13){
        if(
VariavelPlayer[playerid][SenhaV] == 1){
            if(
VariavelPlayer[playerid][temAcc]) {SendClientMessage(playerid, -1"Esta conta jб existe!");}else{
                new 
Query[200];
                
mysql_format(IDConexaoQuerysizeof(Query), "INSERT INTO `users`(`Nome`, `Senha`) VALUES ('%s', '%s')"Name(playerid), senhaplayer[playerid]);
                
mysql_tquery(IDConexaoQuery"DadosRegistrados""i"playerid);
                
                
PlayerLogin[playerid][Skin] = 115;
                
PlayerLogin[playerid][Admin] = 0;
                
PlayerLogin[playerid][horav] = 0;
                
PlayerLogin[playerid][mimv] = 0;
                
PlayerLogin[playerid][segv] = 0;
                
PlayerLogin[playerid][matout] = 0;
                
PlayerLogin[playerid][morreut] = 0;
                
PlayerLogin[playerid][matou] = 0;
                
PlayerLogin[playerid][matoubandidos] = 0;
                
PlayerLogin[playerid][matouz] = 0;
                
PlayerLogin[playerid][vida] = 12000;
                
PlayerLogin[playerid][temperatura] = 37.0;
                
PlayerLogin[playerid][fome] = 0;
                
PlayerLogin[playerid][sede] = 0;
                
                
                
PlayerLogin[playerid][spawnx] = px[0];
                
PlayerLogin[playerid][spawny] = px[1];
                
PlayerLogin[playerid][spawnz] = px[2];
                
SendClientMessage(playerid, -1"{00FF00}[SERVER]>> Sua Conta foi Criada! Clique em Logar!");
                
VariavelPlayer[playerid][temAcc] = 1;
            }
        }else{
SendClientMessage(playerid, -1"[SERVER]>> Senha Invбlida!");}
    }
    if(
playertextid == Textdraw14){
        if(
VariavelPlayer[playerid][SenhaV] == 1){
            if( 
VariavelPlayer[playerid][temAcc] ){
                if( 
strcmpsenhaplayer[playerid], PlayerLogin[playerid][Senha], false) == ){
                    new 
Query[70];
                    
mysql_format(IDConexaoQuerysizeof(Query), "SELECT * FROM `users` WHERE Nome='%s'"Name(playerid));
                    
mysql_tquery(IDConexaoQuery"CarregarContas""d"playerid);
                    
SendClientMessage(playerid, -1"{00FF00}[SERVER]>> Logado com sucesso!");
                    
SetSpawnInfo(playerid0PlayerLogin[playerid][Skin], 1110000000);
                    
SpawnPlayer(playerid);
                    
VariavelPlayer[playerid][SenhaV] = 0;
                }else{
SendClientMessage(playerid, -1"{FF0000}[SERVER]>> Senha Incorreta!");}
            }else{
SendClientMessage(playerid, -1"{FF0000}[SERVER]>> Esta conta nгo estб registrada!");}
        }else{
SendClientMessage(playerid, -1"[SERVER]>> Senha Invбlida!");}
    } 
Outras funзхes:

PHP Code:
public CarregarContas(playerid)
{
    
cache_get_value_int(0"ID"PlayerLogin[playerid][ID]);
    
cache_get_value_int(0"Skin"PlayerLogin[playerid][Skin]);
    
cache_get_value_int(0"Admin"PlayerLogin[playerid][Admin]);
    
cache_get_value_int(0"horav"PlayerLogin[playerid][horav]);
    
cache_get_value_int(0"mimv"PlayerLogin[playerid][mimv]);
    
cache_get_value_int(0"segv"PlayerLogin[playerid][segv]);
    
cache_get_value_int(0"matout"PlayerLogin[playerid][matout]);
    
cache_get_value_int(0"morreut"PlayerLogin[playerid][morreut]);
    
cache_get_value_int(0"matou"PlayerLogin[playerid][matou]);
    
cache_get_value_int(0"matoubandidos"PlayerLogin[playerid][matoubandidos]);
    
cache_get_value_int(0"matouz"PlayerLogin[playerid][matouz]);
    
cache_get_value_int(0"vida"PlayerLogin[playerid][vida]);
    
cache_get_value_float(0"temperatura"PlayerLogin[playerid][temperatura]);
    
cache_get_value_int(0"fome"PlayerLogin[playerid][fome]);
    
cache_get_value_int(0"sede"PlayerLogin[playerid][sede]);
    
cache_get_value_float(0"spawnx"PlayerLogin[playerid][spawnx]);
    
cache_get_value_float(0"spawny"PlayerLogin[playerid][spawny]);
    
cache_get_value_float(0"spawnz"PlayerLogin[playerid][spawnz]);
    return 
1;
}
stock SalvarDados(playerid)
{
    new 
Query[600];
    
mysql_format(IDConexaoQuerysizeof(Query), "UPDATE `users` SET `Skin`=%d, `Admin`=%d, `horav`=%d, `mimv`=%d, `segv`=%d, `matout`=%d, `morreut`=%d, `matou`=%d, `matobandidos`=%d, `matouz`=%d, `vida`=%d, `temperatura`=%f, `fome`=%d, `sede`=%d, `spawnx`=%f, `spawny`=%f, `spawnz`=%f WHERE `Nome`=%s",
    
PlayerLogin[playerid][Skin],
    
PlayerLogin[playerid][Admin],
    
PlayerLogin[playerid][horav],
    
PlayerLogin[playerid][mimv],
    
PlayerLogin[playerid][segv],
    
PlayerLogin[playerid][matout],
    
PlayerLogin[playerid][morreut],
    
PlayerLogin[playerid][matou],
    
PlayerLogin[playerid][matoubandidos],
    
PlayerLogin[playerid][matouz],
    
PlayerLogin[playerid][vida],
    
PlayerLogin[playerid][temperatura],
    
PlayerLogin[playerid][fome],
    
PlayerLogin[playerid][sede],
    
PlayerLogin[playerid][spawnx],
    
PlayerLogin[playerid][spawny],
    
PlayerLogin[playerid][spawnz],
    
Name(playerid));
    return 
1;
}
forward DadosRegistrados(playerid);
public 
DadosRegistrados(playerid)
{
    
PlayerLogin[playerid][ID] = cache_insert_id();
    
printf("-> Nova conta registrada ID: %d"PlayerLogin[playerid][ID]);
    return 
1;

Criaзгo do banco:

PHP Code:
public MySQL_Start(){
    
IDConexao mysql_connect(HOST,USUARIO,SENHA,DATABASE);
    if(!
IDConexao)
        return print(
"Nгo foi possivel conectar a database, verifique as definiзхes novamente.");
    else {
        
mysql_query(IDConexao,"CREATE TABLE IF NOT EXISTS `users`(\
        `ID`int AUTO_INCREMENT PRIMARY KEY,\
         `Nome`varchar(24) NOT NULL,\
         `Senha` varchar(22) NOT NULL,\
         `Skin` int(20) NOT NULL,\
         `Admin` int(10) NOT NULL,\
         `horav` int(10) NOT NULL,\
         `mimv` int(10) NOT NULL,\
         `spawnx` int(10) NOT NULL,\
         `spawny` int(10) NOT NULL,\
         `spawnz` int(10) NOT NULL,\
         `matout` int(10) NOT NULL,\
         `morreut` int(10) NOT NULL,\
         `matou` int(10) NOT NULL,\
         `matouz` int(10) NOT NULL,\
         `vida` int(10) NOT NULL,\
         `temperatura` int(10) NOT NULL,\
         `fome` int(10) NOT NULL,\
         `sede` int(10) NOT NULL)"
,false);
        
printf("Tabelas iniciadas com sucesso!");
    }
    return 
1;

Dialog response:

PHP Code:
if(dialogid == 2){
        if(
response){
            if(
strlen(inputtext) > && strlen(inputtext) < 21){
                
mostrartdlogin(playerid);
                
VariavelPlayer[playerid][SenhaV] = 1;
                
format(senhaplayer[playerid], sizeof(senhaplayer), inputtext);
                
PlayerTextDrawSetString(playeridTextdraw16"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
            }else{
                
ShowPlayerDialog(playeridDialogSenhaDIALOG_STYLE_PASSWORD"Coloque sua senha""Sua senha deve conter no mнnimo 5 digitos\ne no maximo 20 digitos!""Ok""");
                
SendClientMessage(playerid, -1"{FF0000}[SERVER]>> Senha Invбlida! (Nota: A senha tem que ficar entre 6 e 19 caracteres)");
            }
        }
    } 
Reply


Messages In This Thread
Problemas no MySQL - by Scorpion659 - 07.03.2019, 12:49
Re: Problemas no MySQL - by Felipealves - 07.03.2019, 13:59
Re: Problemas no MySQL - by ipsLuan - 07.03.2019, 15:33
Re: Problemas no MySQL - by Scorpion659 - 08.03.2019, 01:25
Re: Problemas no MySQL - by Felipealves - 08.03.2019, 01:52
Re: Problemas no MySQL - by Scorpion659 - 08.03.2019, 12:21
Re: Problemas no MySQL - by Felipealves - 08.03.2019, 12:49
Re: Problemas no MySQL - by Scorpion659 - 08.03.2019, 17:59
Re: Problemas no MySQL - by Felipealves - 08.03.2019, 20:04
Re: Problemas no MySQL - by Scorpion659 - 08.03.2019, 20:28
Re: Problemas no MySQL - by Felipealves - 08.03.2019, 23:04
Re: Problemas no MySQL - by DanielMatrix - 09.03.2019, 00:19
Re: Problemas no MySQL - by Scorpion659 - 09.03.2019, 01:28
Re: Problemas no MySQL - by Scorpion659 - 09.03.2019, 12:27

Forum Jump:


Users browsing this thread: 1 Guest(s)