SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/12/2019, 09:09 PM   #1
ApolloScripter
Big Clucker
 
ApolloScripter's Avatar
 
Join Date: Sep 2018
Posts: 197
Reputation: 2
Default [SQLite] Don't read the data

Hello, I have a problem that I can not identify, my system saves the data all right when the player disconnects, but when he logs in, for some reason returns everything 0, and everything is right in the database too (I checked with SQLite Browser).

My Statement var:
PHP Code:
new DBStatement:carregarConta
The value definition:
PHP Code:
carregarConta db_prepare(gAccounts"SELECT * FROM "TABELA_TOPSYSTEM" WHERE "CAMPO_NOME"=? COLLATE NOCASE"); 
My function that reads the DB to save in player variables:
PHP Code:
stock ReadDBVar(playerid)
{
    new 
existe;
    
stmt_bind_value(checarConta0DB::TYPE_STRINGpName(playerid), MAX_PLAYER_NAME);
    
stmt_bind_result_field(checarConta0DB::TYPE_INTEGERexiste);

    if(!
stmt_execute(checarConta))
    {
        
log("[ TOPSYSTEM ERRO ] ERRO ao executar o STMT checarConta.");
        return 
1;
    }

    if(!
stmt_fetch_row(checarConta))
    {
        
log("[ TOPSYSTEM ERRO ] ERRO ao executar o fetch row checarConta.");
        return -
1;
    }

    if(
existe == 0)
    {
        
stmt_bind_value(registerInsert0DB::TYPE_STRINGpName(playerid), MAX_PLAYER_NAME);
        
stmt_bind_value(registerInsert1DB::TYPE_INTGetPlayerScore(playerid));
        
stmt_bind_value(registerInsert2DB::TYPE_INTGetPlayerTempoVivo(playerid));
        
stmt_bind_value(registerInsert3DB::TYPE_INTGetPlayerKillSemMorrer(playerid));
        
stmt_bind_value(registerInsert4DB::TYPE_INTGetPlayerTempoJogo(playerid));
        
stmt_bind_value(registerInsert5DB::TYPE_INTGetPlayerMaisMorreu(playerid));
        
log("[ TOPSYSTEM ] Inserindo DADOS no BANCO DE DADOS.");

        if(!
stmt_execute(registerInsert))
        {
            
log("[ TOPSYSTEM ERRO ] ERRO ao inserir DADOS no BANCO DE DADOS.");
        }

        return 
1;
    }

    
stmt_bind_result_field(carregarConta0DB::TYPE_STRINGtsPlayerName[playerid], MAX_PLAYER_NAME);
    
stmt_bind_result_field(carregarConta1DB::TYPE_INTtsPlayerScore[playerid]);
    
stmt_bind_result_field(carregarConta2DB::TYPE_INTtsPlayerTempoVivo[playerid]);
    
stmt_bind_result_field(carregarConta3DB::TYPE_INTtsPlayerKillSemMorrer[playerid]);
    
stmt_bind_result_field(carregarConta4DB::TYPE_INTtsPlayerTempoJogo[playerid]);
    
stmt_bind_result_field(carregarConta5DB::TYPE_INTtsPlayerMaisMorreu[playerid]);
    
stmt_bind_value(carregarConta0DB::TYPE_STRINGpName(playerid), MAX_PLAYER_NAME);
    
log("[ TOPSYSTEM ] Lendo DADOS do BANCO DE DADOS.");

    if(!
stmt_execute(carregarConta))
    {
        
log("[ TOPSYSTEM ERRO ] ERRO ao ler DADOS do BANCO DE DADOS.");
    }

    
logf("%i"tsPlayerScore[playerid]);
    
logf("%i"tsPlayerTempoJogo[playerid]);
    
logf("%i"tsPlayerKillSemMorrer[playerid]);
    
logf("%i"tsPlayerTempoJogo[playerid]);
    
logf("%i"tsPlayerMaisMorreu[playerid]);

    return 
1;

I debugged all parts of the code, and the Statements run perfectly, but when I print the values ​​at the prompt, everything returns 0.
__________________
ApolloScripter is online now   Reply With Quote
Old 11/12/2019, 09:20 PM   #2
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,899
Reputation: 1321
Default Re: [SQLite] Don't read the data

You are missing a step.

https://github.com/Pottus/Texture-St...dio/tsmain.pwn

Line 396.
Pottus is offline   Reply With Quote
Old 13/12/2019, 12:16 AM   #3
ApolloScripter
Big Clucker
 
ApolloScripter's Avatar
 
Join Date: Sep 2018
Posts: 197
Reputation: 2
Default Re: [SQLite] Don't read the data

Quote:
Originally Posted by Pottus View Post
Thanks, that literally worked, so I was doing some more details, and now in another Statement, which has the same function of loading the data, it just does not run, falling in else condition and sending me an error log that I put to debug, I don't know where I may have been wrong.

Definition and Value:
PHP Code:
new DBStatement:stmt_carregarClan;
stmt_carregarClan db_prepare(gAccounts"SELECT * FROM "TABELA_SERVERCLAN" WHERE "CAMPO_NOMECLAN"=? COLLATE NOCASE"); 
Code:
PHP Code:
CMD:meuclan(playeridparams[])
{
    if(!
PlayerTemClan(playerid))
        return 
SendClientMessage(playeridRED"[ > ] ERRO Você não possui um clan.");

    
//new clanString[1000];
    
new clanArrayData[15][30];

    
stmt_bind_result_field(stmt_carregarClan0DB::TYPE_STRINGclanArrayData[0], 30);
    
stmt_bind_result_field(stmt_carregarClan1DB::TYPE_STRINGclanArrayData[1], 30);
    
stmt_bind_result_field(stmt_carregarClan2DB::TYPE_STRINGclanArrayData[2], 30);
    
stmt_bind_result_field(stmt_carregarClan3DB::TYPE_STRINGclanArrayData[3], 30);
    
stmt_bind_result_field(stmt_carregarClan4DB::TYPE_STRINGclanArrayData[4], 30);
    
stmt_bind_result_field(stmt_carregarClan5DB::TYPE_STRINGclanArrayData[5], 30);
    
stmt_bind_result_field(stmt_carregarClan6DB::TYPE_STRINGclanArrayData[6], 30);
    
stmt_bind_result_field(stmt_carregarClan7DB::TYPE_STRINGclanArrayData[7], 30);
    
stmt_bind_result_field(stmt_carregarClan8DB::TYPE_STRINGclanArrayData[8], 30);
    
stmt_bind_result_field(stmt_carregarClan9DB::TYPE_STRINGclanArrayData[9], 30);
    
stmt_bind_result_field(stmt_carregarClan10DB::TYPE_STRINGclanArrayData[10], 30);
    
stmt_bind_result_field(stmt_carregarClan11DB::TYPE_STRINGclanArrayData[11], 30);
    
stmt_bind_result_field(stmt_carregarClan12DB::TYPE_STRINGclanArrayData[12], 30);
    
stmt_bind_value(stmt_carregarClan0DB::TYPE_STRINGGetPClan(playerid), 30);

    
log("[ CLAN SYSTEM ] Iniciando STMT carregarClan.");

    if(
stmt_execute(stmt_carregarClan))
    {
        
log("[ CLAN SYSTEM ] STMT Executado");

        while(
stmt_fetch_row(stmt_carregarClan))
        {
            
log("[ CLAN SYSTEM ] Comando lido com sucesso /meuclan.");
            for(new 
015i++)
            {
                
logf("%s"clanArrayData[i]);
            }
        }
    }
    else
    {
        
log("[ CLAN SYSTEM ] ERRO STMT carregarClan não executado.");
    }

    return 
1;

__________________
ApolloScripter is online now   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
SQLite for Simple Data SecretB Scripting Help 3 22/09/2019 09:53 AM
SQLite data leak KaliDobrev Scripting Help 6 06/03/2019 04:46 AM
Read data from php iDark Scripting Help 1 01/06/2017 03:13 PM
Problem to get data from sqlite Cerealguy Scripting Help 3 15/12/2013 08:41 PM
SQLite Updating data. Snip3d Scripting Help 0 06/07/2012 08:27 PM


All times are GMT. The time now is 01:32 AM.


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