Dobrý deň, nemohol som zistiť prečo mi stále ukazuje jednu chybu v registráci, tak som si povedal, že sa vás opýtam. Takže k veci...
Chyba je taká, že keď prídem na server a nemám vytvorení účet, tak klasicky zadám heslo do dialogu a účet mi vytvorí, hashuje heslo a uloží. Tu ale nastáva problém pri prihlasovaní keď prichádzam na server. Zadám heslo, ktoré som použil pri registrácii a ono mi to vypíše, že nesprávne heslo. Neviem si s tým rady takže celý kód.
#include <YSI\y_ini>
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
enum pInfo
{
pHeslo,
pLevel,
pVip,
pEura,
pZabil,
pZomrel
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""BIELA"Login",""BIELA"Zadaj svoje heslo pre prihlásenie.","Prihlas","Koniec");
}else{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""BIELA"Registracia",""BIELA"Nie si zaregistrovaný. \nZadaj svoje nové heslo pre vytvorenie účtu.","Registrovat","Koniec");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"Informacie");
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"VIP",PlayerInfo[playerid][pVip]);
INI_WriteInt(File,"Eura",GetPlayerMoney(playerid));
INI_WriteInt(File,"Zabil",PlayerInfo[playerid][pZabil]);
INI_WriteInt(File,"Zomrel",PlayerInfo[playerid][pZomrel]);
INI_Close(File);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""BIELA"Registracia",""CERVENA"Zadal si nesprávne heslo!\n"BIELA"Nie si zaregistrovaný. \nZadaj svoje nové heslo pre vytvorenie účtu.","Registrovat","Koniec");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"Informacie");
INI_WriteInt(File,"Heslo",udb_hash(inputtext));
INI_WriteInt(File,"Level",0);
INI_WriteInt(File,"VIP",0);
INI_WriteInt(File,"Eura",0);
INI_WriteInt(File,"Zabil",0);
INI_WriteInt(File,"Zomrel",0);
INI_Close(File);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""BIELA"Registracia",""ZELENA"Výborne! Práve si sa zaregistroval.","Ok","");
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pHeslo])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pEura]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""BIELA"Prihlasenie",""ZELENA"Úspešne si sa prihlásil!","Ok","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""BIELA"Prihlasenie",""CERVENA"Zadal si nesprávne heslo!\n"BIELA"Zadaj svoje heslo pre prihlásenie.","Prihlas","Koniec");
}
return 1;
}
}
}
return 1;}
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Heslo",PlayerInfo[playerid][pHeslo]);
INI_Int("Level",PlayerInfo[playerid][pLevel]);
INI_Int("VIP",PlayerInfo[playerid][pVip]);
INI_Int("Eura",PlayerInfo[playerid][pEura]);
INI_Int("Zabil",PlayerInfo[playerid][pZabil]);
INI_Int("Zomrel",PlayerInfo[playerid][pZomrel]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
Dotaz
Roland 11
Dobrý deň, nemohol som zistiť prečo mi stále ukazuje jednu chybu v registráci, tak som si povedal, že sa vás opýtam. Takže k veci...
Chyba je taká, že keď prídem na server a nemám vytvorení účet, tak klasicky zadám heslo do dialogu a účet mi vytvorí, hashuje heslo a uloží. Tu ale nastáva problém pri prihlasovaní keď prichádzam na server. Zadám heslo, ktoré som použil pri registrácii a ono mi to vypíše, že nesprávne heslo. Neviem si s tým rady takže celý kód.
Link to comment
Share on other sites
3 odpovědí na tuto otázku
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now