29.01.2015, 16:11
Estou criando um gamemode do '0' seguindo os tutoriais sobre MySQL do JoaoPedro, eu me registro tudo certinho... Atй aн tudo bem, mas quando eu vou logar a senha estб errada. Alguйm pode me ajudar por favor?
Код:
// // Medieval Roleplay // Gamemode from scratch by Lucas Santos // #include <a_samp> #include <zcmd> #include <sscanf2> #include <a_mysql> // Defines de dialogs #define DIALOG01 1 #define DIALOG02 2 #define DIALOG03 3 // Variavйis globais new mysql; // Configuraзхes MySQL #define SQL_HOST "127.0.0.1" #define SQL_USER "root" #define SQL_PASS "vertrigo" #define SQL_DB "medieval" main() { print("\n----------------------------------"); print(" Medieval Roleplay."); print("----------------------------------\n"); } public OnGameModeInit() { mysql = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS); SetGameModeText("Medieval Roleplay"); return 1; } public OnGameModeExit() { return 1; } public OnPlayerRequestClass(playerid, classid) { return 0; } public OnPlayerConnect(playerid) { new name[MAX_PLAYER_NAME], query[1024]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); format(query, sizeof(query), "SELECT * FROM `contas` WHERE `usuario` = '%s'", name); mysql_function_query(mysql, query, true, "q_loginRequest", "d", playerid); return 1; } forward q_loginRequest(playerid); public q_loginRequest(playerid) { new rows, fields; cache_get_data(rows, fields); if(rows > 0) { // Usuбrio existe ShowPlayerDialog(playerid, DIALOG01, DIALOG_STYLE_PASSWORD, "Login", "Bem vindo novamente, digite a sua senha para logar-se.", "Logar", ""); } else { // Usuбrio nгo existe ShowPlayerDialog(playerid, DIALOG02, DIALOG_STYLE_PASSWORD, "Registro", "Bem vindo, digite a sua senha para registrar-se.", "Registrar", ""); } } public OnPlayerDisconnect(playerid, reason) { return 1; } public OnPlayerSpawn(playerid) { return 1; } public OnPlayerDeath(playerid, killerid, reason) { return 1; } public OnVehicleSpawn(vehicleid) { return 1; } public OnVehicleDeath(vehicleid, killerid) { return 1; } public OnPlayerText(playerid, text[]) { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { return 0; } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { return 1; } public OnPlayerEnterCheckpoint(playerid) { return 1; } public OnPlayerLeaveCheckpoint(playerid) { return 1; } public OnPlayerEnterRaceCheckpoint(playerid) { return 1; } public OnPlayerLeaveRaceCheckpoint(playerid) { return 1; } public OnRconCommand(cmd[]) { return 1; } public OnPlayerRequestSpawn(playerid) { return 0; } public OnObjectMoved(objectid) { return 1; } public OnPlayerObjectMoved(playerid, objectid) { return 1; } public OnPlayerPickUpPickup(playerid, pickupid) { return 1; } public OnVehicleMod(playerid, vehicleid, componentid) { return 1; } public OnVehiclePaintjob(playerid, vehicleid, paintjobid) { return 1; } public OnVehicleRespray(playerid, vehicleid, color1, color2) { return 1; } public OnPlayerSelectedMenuRow(playerid, row) { return 1; } public OnPlayerExitedMenu(playerid) { return 1; } public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) { return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { return 1; } public OnRconLoginAttempt(ip[], password[], success) { return 1; } public OnPlayerUpdate(playerid) { return 1; } public OnPlayerStreamIn(playerid, forplayerid) { return 1; } public OnPlayerStreamOut(playerid, forplayerid) { return 1; } public OnVehicleStreamIn(vehicleid, forplayerid) { return 1; } public OnVehicleStreamOut(vehicleid, forplayerid) { return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { case DIALOG01: { new query[1024], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); format(query, sizeof(query), "SELECT * FROM `contas` WHERE `usuario` = '%s' AND 'senha' = '%s'", name, inputtext); mysql_function_query(mysql, query, true, "q_verifyPassword", "d", playerid); return 1; } // Usuбrio nгo existe. case DIALOG02: { if(strlen(inputtext) < 2) { ShowPlayerDialog(playerid, DIALOG02, DIALOG_STYLE_PASSWORD, "Registro", "Bem vindo, digite a sua senha para registrar-se.\n\n{ff0000}Informe uma senha vбlida.", "Registrar", ""); return 1; } else { new query[1024], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); format(query, sizeof(query), "INSERT INTO `contas` (usuario, senha) VALUES ('%s', '%s')", name, inputtext); mysql_function_query(mysql, query, false, "", ""); //-5325.8876953,-1853.9648438,0.6268279 // Spawn. SetSpawnInfo(playerid, 0, 0, 1958.3783, 1343.1572, 15.3746, 0, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); return 1; } } } return 1; } forward q_verifyPassword(playerid); public q_verifyPassword(playerid) { new rows, fields; cache_get_data(rows, fields); if(rows) { // Senha correta SetSpawnInfo(playerid, 0, 0, 1958.3783, 1343.1572, 15.3746, 0, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); return 1; } else { // Senha incorreta ShowPlayerDialog(playerid, DIALOG01, DIALOG_STYLE_PASSWORD, "Login", "Bem vindo novamente, digite a sua senha para logar-se.\n\n{ff0000}Senha de acesso invбlida!", "Logar", ""); return 1; } } public OnPlayerClickPlayer(playerid, clickedplayerid, source) { return 1; }