Salvar Conta -
Cidiei - 28.05.2013
Olб a todos, eu estou aprendendo um pouco de mysql e estou quebrando a cabeзa na hora de salvar as informaзхes do jogador, aonde eu estou enfrentando o problema na hora de atualizar o usuario na database! Se puderem me ajudar eu agradeзo! Sou noob em mysql ainda!
Cуdigo:
pawn Код:
SalvarBD(playerid){
new consulta[128];
if(!Login[playerid]) return 0;
mysql_format(conexao, consulta,"UPDATE `Usuarios` SET Senha='%s',Admin='%d' WHERE Nome='%s'",DadosUser[playerid][Senha],DadosUser[playerid][Admin]);
return 1;
}
Re: Salvar Conta -
Cidiei - 28.05.2013
Desculpa pelo double! Mas alguйm poderia me ajudar?
Re: Salvar Conta -
AlucardSnow - 28.05.2013
Estб errado pelos acentos.
Coloque assim:
pawn Код:
mysql_format(conexao, consulta,"UPDATE `Usuarios` SET `Senha`='%s', `Admin`='%d' WHERE `Nome`='%s'",DadosUser[playerid][Senha],DadosUser[playerid][Admin]);
Obs: Vocк nгo coloco nada no final para usar a funзгo
`Nome`='%s', sendo assim creio que se um sair salva em todas contas.
Aconselho a ver a video aula do Paulor, й grande mais explica tudo e vocк nгo vai ter mais dъvida.
Re: Salvar Conta -
Cidiei - 28.05.2013
Continua sem salvar ainda
pawn Код:
SalvarBD(playerid){
new consulta[128];
new Nome[MAX_PLAYER_NAME];
if(!Login[playerid]) return 0;
GetPlayerName(playerid,Nome,24);
mysql_format(conexao, consulta,"UPDATE `Usuarios` SET `Senha`='%s', `Admin`='%d' WHERE `Nome`='%s'",DadosUser[playerid][Senha],DadosUser[playerid][Admin],Nome);
return 1;
}
Ai esta o log do mysql
PHP код:
[13:11:18] >> mysql_connect(localhost, root, bcrp, ******) on port 3306
[13:11:18] CMySQLHandler::CMySQLHandler() - constructor called.
[13:11:18] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "bcrp" | Username: "root"
[13:11:18] CMySQLHandler::Connect() - Connection was successful.
[13:11:18] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[13:11:18] >> mysql_ping( Connection handle: 1 )
[13:11:18] CMySQLHandler::Ping() - Connection is still alive.
[13:11:18] >> mysql_query_callback( Connection handle: 1 )
[13:11:18] Passing query CREATE TABLE IF NOT EXISTS `usuarios` (`Nome` VARCHAR(24) NOT NULL,`Senha` VARCHAR(32)) |
[13:11:18] ProcessQueryThread() - Query was successful. (CREATE TABLE IF NOT EXISTS `usuarios` (`Nome` VARCHAR(24) NOT NULL,`Senha` VARCHAR(32)))
[13:11:18] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[13:11:53] >> mysql_format( Connection handle: 1 )
[13:11:53] CMySQLHandler::EscapeString(Matheus_Vieira); - Escaped 14 characters to Matheus_Vieira.
[13:11:53] >> mysql_query_callback( Connection handle: 1 )
[13:11:53] Passing query SELECT * FROM `usuarios` WHERE `Nome` = 'Matheus_Vieira' | i
[13:11:53] ProcessQueryThread(ProcurarUsuario) - Query was successful. (SELECT * FROM `usuarios` WHERE `Nome` = 'Matheus_Vieira')
[13:11:53] ProcessQueryThread(ProcurarUsuario) - Data caching enabled.
[13:11:53] CMySQLHandler::StoreResult() - Result was stored.
[13:11:53] CMySQLHandler::FreeResult() - Result was successfully free'd.
[13:11:53] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[13:11:53] ProcurarUsuario(i) - Threaded function called.
[13:11:53] >> cache_get_data( Connection handle: 1 )
[13:11:53] ProcessTick() - The cache has been cleared.
[13:11:57] >> mysql_format( Connection handle: 1 )
[13:11:57] CMySQLHandler::EscapeString(); - Escaped 0 characters to .
[13:11:57] CMySQLHandler::EscapeString(); - Escaped 0 characters to .
[13:11:57] >> mysql_query_callback( Connection handle: 1 )
[13:11:57] Passing query SELECT * FROM `usuarios` WHERE `Nome` = '%e' AND `Senha` = '%e' | i
[13:11:57] ProcessQueryThread(FazerLogin) - Query was successful. (SELECT * FROM `usuarios` WHERE `Nome` = '%e' AND `Senha` = '%e')
[13:11:57] ProcessQueryThread(FazerLogin) - Data caching enabled.
[13:11:57] CMySQLHandler::StoreResult() - Result was stored.
[13:11:57] CMySQLHandler::FreeResult() - Result was successfully free'd.
[13:11:57] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[13:11:57] FazerLogin(i) - Threaded function called.
[13:11:57] >> cache_get_data( Connection handle: 1 )
[13:11:57] ProcessTick() - The cache has been cleared.
[13:12:04] >> mysql_format( Connection handle: 1 )
[13:12:04] >> mysql_format( Connection handle: 1 )
[13:12:05] >> mysql_format( Connection handle: 1 )
[13:12:06] >> mysql_format( Connection handle: 1 )
Re: Salvar Conta -
AlucardSnow - 28.05.2013
O meu da certo.
pawn Код:
format(Str, 202, "UPDATE `users` SET `level`='%i', `cash`='%i', `skin`='%i', `money`='%i', `X`='%f', `Y`='%f', `Z`='%f' WHERE `name`='%s'"
Mais to percebendo que vocк usa um pouco diferente de min.
Eu salvo de uma forma mais diferente.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new Connect;
new Str[202], Nome[21], Float:X, Float:Y, Float:Z;
GetPlayerName(playerid, Nome, 20);
xPlayerInfo[playerid][xLevel] = GetPlayerScore(playerid);
xPlayerInfo[playerid][xSkin] = GetPlayerSkin(playerid);
xPlayerInfo[playerid][xMoney] = GetPlayerMoney(playerid);
GetPlayerPos(playerid, X, Y, Z);
format(Str, 202, "UPDATE `users` SET `level`='%i', `cash`='%i', `skin`='%i', `money`='%i', `X`='%f', `Y`='%f', `Z`='%f' WHERE `name`='%s'", xPlayerInfo[playerid][xLevel], 500, xPlayerInfo[playerid][xSkin], xPlayerInfo[playerid][xMoney], X, Y, Z, Nome);
mysql_function_query(Connect, Str, false, #, #);
Use como uma possivel base, tambйm sugiro que veja a video aula lб do paulor...
Re: Salvar Conta -
Cidiei - 28.05.2013
Obrigado AlucardSnow consegui resolver este problema, e assistindo uns tutoriais aprendi bastante! +Rep