07.12.2013, 16:39
Hola!
Me surgio otro problema con MySQL, estaba editando un poco la tabla de usuarios (Agregando mas campos) pero ahora al registrar una cuenta nueva no crea la fila del usuario en la tabla, nose si es porque agregue Whirlpool al GameMode pero ya no funciona el sistema de registro :C
Les dejo el code
OnPlayerConnect
OnDialogResponse
stocks
Saludos!
Me surgio otro problema con MySQL, estaba editando un poco la tabla de usuarios (Agregando mas campos) pero ahora al registrar una cuenta nueva no crea la fila del usuario en la tabla, nose si es porque agregue Whirlpool al GameMode pero ya no funciona el sistema de registro :C
Les dejo el code
OnPlayerConnect
pawn Код:
new Query[80],pName[24],tstring[164];
GetPlayerName(playerid,pName,24);
format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = '%s' LIMIT 1;",pName);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
format(tstring,sizeof(tstring),"Hey, %s! \nYour account is registered. \nPlease enter your password to login!",pName);
ShowPlayerDialog(playerid,Logindialog,DIALOG_STYLE_INPUT,"Re gister",tstring,"Register","");
}
else
{
format(tstring,sizeof(tstring),"Hey, %s! \nYour account is NOT registered.\nPlease type a password to register!",pName);
ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_INPUT,"Lo g in",tstring,"Login","");
}
mysql_free_result();
pawn Код:
if(dialogid == Regdialog)
{
if(strlen(inputtext) == 0)
{
ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password for it! \n","Register!","");
}
else
{
new escpass[100];
mysql_real_escape_string(inputtext, escpass);
RegisterPlayer(playerid, escpass);
}
}
if(dialogid == Logindialog)
{
if(strlen(inputtext) == 0)
{
ShowPlayerDialog(playerid,Logindialog,DIALOG_STYLE_INPUT,"Login","Please enter your passsword to continue!","Login","");
}
else
{
LoginPlayer(playerid,inputtext);
}
}
pawn Код:
stock RegisterPlayer(playerid, passwordstring[])
{
new query[235], buf[129];
WP_Hash(buf,129,passwordstring);
format(query, sizeof(query), "INSERT INTO `users` (`UserName`,`Password`,`Score`,`Money`,`WantedLevel`,`AdminLevel`,`VipLevel`,`ArmyRights`,`SwatRights`,`SGRights`,`MedicLevel`,`RapistLevel`,`MechanicLevel`,`RobSkill`) VALUES('%s','%s',0,100,0,0,0,0,0,0,0,0,0,0)", GetName(playerid), buf);
mysql_query(query);
SendClientMessage(playerid, -1,"You have been succesfuly registered on this server!");
printf("Hashed pass: %s",buf);
return 1;
}
stock LoginPlayer(playerid,const password[])
{
new EscapedText[60];
new EscapedPass[129];
new Query[140];
new buf[129];
mysql_real_escape_string(password, EscapedText);
WP_Hash(buf,129,EscapedText);
mysql_real_escape_string(buf, EscapedPass);
format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `Username` = '%s' AND `Password` = '%s'",GetName(playerid), EscapedPass);
mysql_query(Query);
new rows = mysql_store_result();
if(rows == 1)
{
SendClientMessage(playerid,-1,"You have been logged in!");
LoadStats(playerid);
}
if(!rows)
{
new tstring[164];
SendClientMessage(playerid,-1,"Wrong password!");
MaxLoginAttempts[playerid]++;
format(tstring,sizeof(tstring),"Hey, %s! \nYour account is registered. \nPlease enter your password to login!",GetName(playerid));
ShowPlayerDialog(playerid,Logindialog,DIALOG_STYLE_INPUT,"Re gister",tstring,"Register","");
if(MaxLoginAttempts[playerid] == 3)
{
Kick(playerid);
}
}
mysql_free_result();
return 1;
}
Saludos!