SA-MP Forums Archive
[Ajuda] Problema no registro/Salvamento sqllite - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Problema no registro/Salvamento sqllite (/showthread.php?tid=659287)



Problema no registro/Salvamento sqllite - NTZ - 29.09.2018

então estou com problemas quando o player se registra a penas a senha é salvada o resto fica null na tabela
a tabela cria tudo direitinho mais não está sendo preenchida

REGISTRO e salvamento :::

PHP Code:
BPS::OnPlayerRegister(playeridpassword[])
{
    if(
IsPlayerConnected(playerid))
    {
        if(
AccountExists(PlayerName(playerid)))
        {
              
SendClientMessage(playeridCOR_BRANCO"ERRO, Sua conta ja existe no nosso banco de dados!");
            
Kick(playerid);
            return 
1;
        }
        
hideTelaLogin(playerid);
        new 
string[200];
        
format(stringsizeof(string), "SELECT * FROM `contas` WHERE `Nome` = '%s'"DB_Escape(PlayerName(playerid)));
          
Resultado db_query(Conexao,string);
        if(
db_num_rows(Resultado) == 0)
        {
            
format(stringsizeof(string), "INSERT INTO contas (`Nome`, `Senha`) VALUES('%s', '%s')"DB_Escape(PlayerName(playerid)), DB_Escape(password));
               
db_free_result(db_query(Conexaostring));
            
printf("%s"string);
            
gPlayerAccount[playerid] = 1;
              
OnPlayerSave(playerid);
              
PlayerInfo[playerid][pFome] = 100;
            
PlayerInfo[playerid][pSede] = 100;
            if(
MudarSenhaAceito[playerid] == 1) { MudarSenhaAceito[playerid] = 0; return 1; }
              
SetPlayerPos(playerid2243.7371,-1668.1760,15.4766);
            
SetPlayerCameraPos(playerid2264.1365,-1653.5085,19.6254);
             
SetPlayerCameraLookAt(playerid2243.7371,-1668.1760,15.4766);
              new 
loginstring[255];
            new 
loginname[64];
            
GetPlayerName(playerid,loginname,sizeof(loginname));
            
SendClientMessage(playeridCOR_BALLAS"[BEV]: Conta registrada digite : (/logar[Senha]).");
            
format(loginstring,sizeof(loginstring),"{00F200}Você é Registrado!\n\n{FFFFFF}Olá {07C3F7}%s,\n {FFFFFF}Você já é membro cadastrado do nosso servidor.\n\n{FFFFFF}Digite sua senha correta para logar!\n\nVisite nosso site: {00F200}http://bevrpgrpsamp.com.br/forum/"PlayerName(playerid));
            
ShowPlayerDialog(playerid1DIALOG_STYLE_PASSWORD,"Login Necessário",loginstring,"Logar","Esperar");
            
PlayerPlaySound(playerid10980.00.00.0);
        }
    }
    return 
1;
}
BPS::OnPlayerSave(playerid)
{
    if(
gPlayerLogged[playerid])
    {
        new 
string[900];
        new 
ULTRAString[5000];
        
ULTRAString[0] = EOS;
        
format(stringsizeof(string), Pasta_ContasPlayerName(playerid));
        
format(stringsizeof(string), "UPDATE `contas` SET `AntiBug`='%s',`Senha`='%s',"PlayerInfo[playerid][pAntiBug], PlayerInfo[playerid][pSenha]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`Level`='%d',`AdminLevel`='%d',`Avaliacoes`='%d',`AvaFinal`='%d',`VipLevel`='%d',`SocioLevel`='%d',`HorasJogadas`='%d',`Registrado`='%d',`Sexo`='%d',`Respeito`='%d',`Dinheiro`='%d',`GranaBanco`='%d',`Crimes`='%d',`Kills`='%d',`Deaths`='%d',`AgendaTelefonica`='%d',`LottoNr`='%d',`Emprego`='%d',`Salario`='%d',",
        
PlayerInfo[playerid][pLevel],
        
PlayerInfo[playerid][pAdmin],
        
PlayerInfo[playerid][pAvaliacoes],
        
PlayerInfo[playerid][pAFinal],
        
PlayerInfo[playerid][pVIP],
        
PlayerInfo[playerid][pSocio],
        
PlayerInfo[playerid][pConnectTime],
        
PlayerInfo[playerid][pReg],
        
PlayerInfo[playerid][pSex],
        
PlayerInfo[playerid][pExp],
        
GetPlayerMoneyEx(playerid),
        
PlayerInfo[playerid][pConta],
        
PlayerInfo[playerid][pCrimes],
        
PlayerInfo[playerid][pKills],
        
PlayerInfo[playerid][pDeaths],
        
PlayerInfo[playerid][pAgendaT],
        
PlayerInfo[playerid][pLottoNr],
        
PlayerInfo[playerid][pEmprego],
        
PlayerInfo[playerid][pSalario]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`HeadValue`='%d',`Jailed`='%d',`EventoChuck`='%d',`JailTime`='%d',`BloqueadoChatDuvida`='%d',`Materiais`='%d',`Lider`='%d',`Membro`='%d',`Cargo`='%d',`Skin`='%d',`ContractTime`='%d',`DetSkill`='%d',`LawSkill`='%d',`MechSkill`='%d',`DrogasSkill`='%d',`pSHealth`='%d',`Team`='%d',`Celular`='%d',",
        
PlayerInfo[playerid][pHeadValue],
        
PlayerInfo[playerid][pJailed],
        
PlayerInfo[playerid][pTrazerChuck],
        
PlayerInfo[playerid][pJailTime],
        
PlayerInfo[playerid][pBloqueadoChatDuvida],
        
PlayerInfo[playerid][pMats],
        
PlayerInfo[playerid][pLider],
        
PlayerInfo[playerid][pMembro],
        
PlayerInfo[playerid][pCargo],
        
PlayerInfo[playerid][pSkin],
        
PlayerInfo[playerid][pContractTime],
        
PlayerInfo[playerid][pDetSkill],
        
PlayerInfo[playerid][pLawSkill],
        
PlayerInfo[playerid][pMechSkill],
        
PlayerInfo[playerid][pDrogasSkill],
        
PlayerInfo[playerid][pSHealth],
        
PlayerInfo[playerid][pTeam],
        
PlayerInfo[playerid][pPnumber]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`ChaveCasa`='%d',`ChaveEmpresa`='%d',`ChaveFazenda`='%d',`CarLic`='%d',`MotoLic`='%d',`FlyLic`='%d',`BoatLic`='%d',`CamOniLic`='%d',`GunLic`='%d',`DrugPerk`='%d',`Avisos`='%d',`Married`='%d',`MarriedTo`='%s',`Spawn`='%d',`SafeMaconha`='%d',`SafeCocaina`='%d',`SafeCrack`='%d',`SafeLsd`='%d',`CarroVIP`='%d',`CarroFIXO`='%d',",
        
PlayerInfo[playerid][pPHousekey],
        
PlayerInfo[playerid][pPbiskey],
        
PlayerInfo[playerid][pPFazkey],
        
PlayerInfo[playerid][pCarLic],
        
PlayerInfo[playerid][pMotoLic],
        
PlayerInfo[playerid][pFlyLic],
        
PlayerInfo[playerid][pBoatLic],
        
PlayerInfo[playerid][pCamOniLic],
        
PlayerInfo[playerid][pGunLic],
        
PlayerInfo[playerid][pDrugPerk],
        
PlayerInfo[playerid][pAvisos],
        
PlayerInfo[playerid][pMarried],
        
PlayerInfo[playerid][pMarriedTo],
        
PlayerInfo[playerid][pSpawn],
        
PlayerInfo[playerid][pSafeDrogas],
        
PlayerInfo[playerid][pSafeDrogas2],
        
PlayerInfo[playerid][pSafeDrogas3],
        
PlayerInfo[playerid][pSafeDrogas4],
        
PlayerInfo[playerid][pCarKey],
        
PlayerInfo[playerid][pCarFixo]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`OldCarroVIP`='%d',`OldCarroFixo`='%d',`SafeMateriais`='%d',`CarroCasa`='%d',`Luta`='%d',`Dorgado`='%d',`Dorgado2`='%d',`Doenca`='%d',`Creditos`='%d',`LU`='%s',`Gun1`='%d',`Gun2`='%d',`Gun3`='%d',`Gun4`='%d',`Gun5`='%d',`Gun6`='%d',`Gun7`='%d',`Gun8`='%d',`Gun9`='%d',`Gun10`='%d',`Gun11`='%d',`Gun12`='%d',`Ammo1`='%d',`Ammo2`='%d',`Ammo3`='%d',",
        
PlayerInfo[playerid][pOldCarKey],
        
PlayerInfo[playerid][pOldCarFixo],
        
PlayerInfo[playerid][psMats],
        
PlayerInfo[playerid][pCarroCasa],
        
PlayerInfo[playerid][pLuta],
        
PlayerInfo[playerid][pDorgado],
        
PlayerInfo[playerid][pDorgado2],
        
PlayerInfo[playerid][pDoenca],
        
PlayerInfo[playerid][pCreditos],
        
PlayerInfo[playerid][pLastLogin],
        
PlayerInfo[playerid][pGun1],
        
PlayerInfo[playerid][pGun2],
        
PlayerInfo[playerid][pGun3],
        
PlayerInfo[playerid][pGun4],
        
PlayerInfo[playerid][pGun5],
        
PlayerInfo[playerid][pGun6],
        
PlayerInfo[playerid][pGun7],
        
PlayerInfo[playerid][pGun8],
        
PlayerInfo[playerid][pGun9],
        
PlayerInfo[playerid][pGun10],
        
PlayerInfo[playerid][pGun11],
        
PlayerInfo[playerid][pGun12],
        
PlayerInfo[playerid][pAmmo1],
        
PlayerInfo[playerid][pAmmo2],
        
PlayerInfo[playerid][pAmmo3]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`Ammo4`='%d',`Ammo5`='%d',`Ammo6`='%d',`Ammo7`='%d',`Ammo8`='%d',`Ammo9`='%d',`Ammo10`='%d',`Ammo11`='%d',`Ammo12`='%d',`Caixinha`='%d',`RoubosEvitados`='%d',`Sequestros`='%d',`Multas`='%d',`Televisao`='%d',`Maconheiro`='%d',`Cheirador`='%d',`Cracudo`='%d',`Psicopata`='%d',`Preso`='%d',`Carcereiro`='%d',`Cacador`='%d',`AtiradorElite`='%d',",
        
PlayerInfo[playerid][pAmmo4],
        
PlayerInfo[playerid][pAmmo5],
        
PlayerInfo[playerid][pAmmo6],
        
PlayerInfo[playerid][pAmmo7],
        
PlayerInfo[playerid][pAmmo8],
        
PlayerInfo[playerid][pAmmo9],
        
PlayerInfo[playerid][pAmmo10],
        
PlayerInfo[playerid][pAmmo11],
        
PlayerInfo[playerid][pAmmo12],
        
PlayerInfo[playerid][pCaixinha],
        
PlayerInfo[playerid][pRoubosEvitados],
        
PlayerInfo[playerid][pSequestros],
        
PlayerInfo[playerid][pMultas],
        
PlayerInfo[playerid][pTelevisao],
        
PlayerInfo[playerid][pMaconheiro],
        
PlayerInfo[playerid][pCheirador],
        
PlayerInfo[playerid][pCracudo],
        
PlayerInfo[playerid][pPsicopata],
        
PlayerInfo[playerid][pPreso],
        
PlayerInfo[playerid][pCarcereiro],
        
PlayerInfo[playerid][pCacador],
        
PlayerInfo[playerid][pAtiradorElite]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`Bazucador`='%d',`Assaltante`='%d',`Ladrao`='%d',`Dominador`='%d',`Traficante`='%d',`Matador`='%d',`Incendiario`='%d',`Apagado`='%d',`Alcolatra`='%d',`Winner`='%d',`Deejay`='%d',`Degolador`='%d',",
        
PlayerInfo[playerid][pBazucador],
        
PlayerInfo[playerid][pAssaltante],
        
PlayerInfo[playerid][pLadrao],
        
PlayerInfo[playerid][pDominador],
        
PlayerInfo[playerid][pTraficante],
        
PlayerInfo[playerid][pMatador],
        
PlayerInfo[playerid][pIncendio],
        
PlayerInfo[playerid][pApagado],
        
PlayerInfo[playerid][pAlcolatra],
        
PlayerInfo[playerid][pWinner],
        
PlayerInfo[playerid][pDeejay],
        
PlayerInfo[playerid][pDegolador]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`Titulo`='%s', `Pontos`='%d',`Multa`='%d',`NoteBook`='%d',",
        
PlayerInfo[playerid][pATitulo],
        
PlayerInfo[playerid][pPontos],
        
PlayerInfo[playerid][pMulta],
        
PlayerInfo[playerid][pNotebook]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`Multado`='%d',`ChatVipAtivado`='%d',`ChatJornalAovido`='%d',`ChatSocioAtivado`='%d',`ChatTerritorio`='%d',`ChatDuelo`='%d',`ChatRoubo`='%d',`ValidadeCarro`='%d',`ValidadeMoto`='%d',`ValidadeBarco`='%d',`ValidadeAviao`='%d',`ValidadeOnibus`='%d',`DiaVIP`='%d',`LogouHoje`='%d',",
        
PlayerInfo[playerid][pMultado],
        
PlayerInfo[playerid][pChatVipDesativado],
        
PlayerInfo[playerid][pChatJornalAovido],
        
PlayerInfo[playerid][pChatSocioDesativado],
        
PlayerInfo[playerid][pChatTerritorio],
        
PlayerInfo[playerid][pChatDuelo],
        
PlayerInfo[playerid][pChatRoubo],
        
PlayerInfo[playerid][pValidadeCarro],
        
PlayerInfo[playerid][pValidadeMoto],
        
PlayerInfo[playerid][pValidadeBarco],
        
PlayerInfo[playerid][pValidadeAviao],
        
PlayerInfo[playerid][pValidadeOnibus],
        
PlayerInfo[playerid][pDiaVIP],
        
PlayerInfo[playerid][pLogouHoje]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`Penitenciaria`='%d',`Tiroteio`='%d',`DiaLogin`='%d',`MesLogin`='%d',`AnoLogin`='%d',`Moedas`='%d',`ReceberMoedas`='%d',`DiasBanTemp`='%d',`MesBanTemp`='%d',`AnoBanTemp`='%d',",
        
PlayerInfo[playerid][pPenitenciaria],
        
PlayerInfo[playerid][pTiroteio],
        
PlayerInfo[playerid][pLastDia],
        
PlayerInfo[playerid][pLastMes],
        
PlayerInfo[playerid][pLastAno],
        
PlayerInfo[playerid][pMoedas],
        
PlayerInfo[playerid][pReceberMoedas],
        
PlayerInfo[playerid][pDiaBanTemp],
        
PlayerInfo[playerid][pMesBanTemp],
        
PlayerInfo[playerid][pAnoBanTemp]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`Familia`='%d',`KitAlternado`='%d',`AtividadeAdmin`='%d',`Tutorial`='%d',`MoedasFree`='%d',",
        
PlayerInfo[playerid][pFamilia],
        
PlayerInfo[playerid][pKitAlternado],
        
PlayerInfo[playerid][pAtividadeAdmin],
        
PlayerInfo[playerid][pTutorial],
        
PlayerInfo[playerid][pMoedasFree]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`Sino`='%d',`Desafiador`='%d',`Desafiante`='%d',`SkinAntiga`='%d',`WantedLevel`='%d',`SpawnGuerra`='%d',`DeslogandoMulta`='%d',`DeslogandoSocio`='%d',`DeslogandoEnforcer`='%d',`DeslogouNoTiroteio`='%d',`MudarNick`='%d',",
        
PlayerInfo[playerid][pSino],
        
PlayerInfo[playerid][pDesafiador],
        
PlayerInfo[playerid][pDesafiante],
        
skincop[playerid],
        
WantedLevel[playerid],
        
SpawnGuerra[playerid],
        
DeslogandoMulta[playerid],
        
DeslogandoSocio[playerid],
        
DeslogandoEnforcer[playerid],
        
DeslogouNoTiroteio[playerid],
        
MudarNick[playerid]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`LicencaAdvogado`='%d',`MotoGuincho1`='%d',`MotoGuincho2`='%d',`MotoGuincho3`='%d',`MotoGuincho4`='%d',`MotoGuincho5`='%d',`DeatEvento`='%d',`KillEvento`='%d',`TemSkinPerm`='%d',`TemTituloPersonalizado`='%d',",
        
LicencaAdvogado[playerid],
        
MotoGuincho1[playerid],
        
MotoGuincho2[playerid],
        
MotoGuincho3[playerid],
        
MotoGuincho4[playerid],
        
MotoGuincho5[playerid],
        
DeatEvento[playerid],
        
KillEvento[playerid],
        
TemSkinPermanente[playerid],
        
TemTituloPersonalizado[playerid]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`PayDay`='%d',`LFamilia`='%d',`SubFamilia`='%d',`LogouHojeVIP`='%d',`Missao`='%d',`SocioGratis`='%d',`AnuncioMoedas`='%d',",
        
PlayerInfo[playerid][pPayDay],
        
PlayerInfo[playerid][pLFamilia],
        
PlayerInfo[playerid][pCargoF],
        
PlayerInfo[playerid][pLogouHojeVIP],
        
PlayerInfo[playerid][pMissao],
        
GanhouSocio[playerid],
        
PlayerInfo[playerid][pAnuncioMoedas]);
        
strcat(ULTRAString,string);//
        
format(stringsizeof(string), "`SFome`='%d', `Fome`='%d', `Sede`='%d', `TipoRG`='%d', `UP`='%d', `ChatDuvida`='%d', `DuvidaMensagens`='%d' WHERE `Nome` = '%s'",
        
PlayerInfo[playerid][pSFOME],
        
PlayerInfo[playerid][pFome],
        
PlayerInfo[playerid][pSede],
        
PlayerInfo[playerid][pTipoRG],
        
PlayerInfo[playerid][pUP],
        
PlayerInfo[playerid][pChatDuvida],
        
PlayerInfo[playerid][pDuvidaMensagens],
        
DB_Escape(PlayerName(playerid)));
        
strcat(ULTRAString,string);//
        
Resultado db_query(Conexao,ULTRAString);
        
MySQLLog(ULTRAString);
        
format(ULTRAStringsizeof(ULTRAString), "");
    }
    
printf("Conta Salva: [%s]"PlayerName(playerid));
    return 
1;




Re: Problema no registro/Salvamento sqllite - GSantana - 29.09.2018

irmгo eu estava com este mesmo problema, porйm era com MYSQL, vou te dizer oque me ajudou, vocк sу deve colocar (' ') em string exemplo: senha='%s', agora se a senha й sу nъmero fica assim: senha=%d espero que tenha entendido


Re: Problema no registro/Salvamento sqllite - Ermanhaut - 29.09.2018

Para fazer a formataзгo correta da query, vocк sу deve utilizar aspas ('') em strings.

Code:
format(query, sizeof query, "INSERT INTO tabela (nome, senha, ip, skin, dinheiro) VALUES ('%s', '%s', '%s', %d, %d)", playerName[playerid], playerPassword[playerid], playerIP[playerid], playerSkin[playerid], playerMoney[playerid]);
E aqui vocк formata a variбvel string duas vezes. Nгo funcionarб pois format apaga todo conteъdo da variбvel para inserir um novo.
Code:
format(string, sizeof(string), Pasta_Contas, PlayerName(playerid)); 
format(string, sizeof(string), "UPDATE `contas` SET `AntiBug`='%s',`Senha`='%s',", PlayerInfo[playerid][pAntiBug], PlayerInfo[playerid][pSenha]);