Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
pawn Код:
WP_Hash(buf, sizeof(buf), password);
if(!strcmp(PlayerPass, password) == buf)
?
Re: Y_Ini - Let's do it! -
Zh3r0 - 10.03.2011
Quote:
Originally Posted by Riddick94
pawn Код:
WP_Hash(buf, sizeof(buf), password); if(!strcmp(PlayerPass, password) == buf)
?
|
Your capacity of thinking is null! You are properly incapable of scripting, sorry but it's the raw truth!
The real code should be
pawn Код:
if(!strcmp(PlayerPass, buf))
Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
pawn Код:
stock OnPlayerLogin(playerid, password[])
{
INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword");
new PlayerPass[129], buf[150];
GetPVarString(playerid, "pPass", PlayerPass, 129);
WP_Hash(buf, sizeof(buf), password);
if(strcmp(PlayerPass, buf))
{
new INI:Account;
Account = INI_Open(PlayerFile(playerid));
INI_Close(Account);
PlayerInfo[playerid][pLogged] = true;
TogglePlayerClock(playerid, true);
SendDeathMessage(INVALID_PLAYER_ID, playerid, ICON_CONNECT);
SendFormattedMessageToAll(COLOR_WHITE, "*** %s [{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}] dołączył do serwera.", PlayerName(playerid), playerid);
SendFormattedMessage(playerid, COLOR_LIMON, "{1BE03F}* Zalogowany jako {EDBC6D}%s {FFFFFF}[{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}]{1BE03F}. Witamy spowrotem na Polskim eXtra Serwerze!", PlayerName(playerid), playerid);
}else{
new string[128];
format(string,sizeof(string),"{9EB8E8}Witamy ponownie {F2EE0C}%s{9EB8E8}. Proszę wpisać poniżej swoje hasło, aby zalogować się i grać:", PlayerName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGOWANIE, DIALOG_STYLE_INPUT, "Logowanie", string, "Zaloguj", "Wyjdź");
GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~r~Nieprawidlowe haslo!", SECONDS(3), 3);
}
return true;
}
When i type good password (for sure) it's sending me a GameTextForPlayer. When i type bad password it's sending GameText too. Why?
P.S
I'm learning from the ready code. After that i'll analize Y_Ini fully you got my word. It's my first time when i'm making script with other script than DINI, so.. : )
Re: Y_Ini - Let's do it! -
Zh3r0 - 10.03.2011
Quote:
Originally Posted by Riddick94
pawn Код:
stock OnPlayerLogin(playerid, password[]) { INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword"); new PlayerPass[129], buf[150]; GetPVarString(playerid, "pPass", PlayerPass, 129); WP_Hash(buf, sizeof(buf), password); if(strcmp(PlayerPass, buf)) { new INI:Account; Account = INI_Open(PlayerFile(playerid));
INI_Close(Account);
PlayerInfo[playerid][pLogged] = true; TogglePlayerClock(playerid, true);
SendDeathMessage(INVALID_PLAYER_ID, playerid, ICON_CONNECT); SendFormattedMessageToAll(COLOR_WHITE, "*** %s [{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}] dołączył do serwera.", PlayerName(playerid), playerid); SendFormattedMessage(playerid, COLOR_LIMON, "{1BE03F}* Zalogowany jako {EDBC6D}%s {FFFFFF}[{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}]{1BE03F}. Witamy spowrotem na Polskim eXtra Serwerze!", PlayerName(playerid), playerid); }else{ new string[128]; format(string,sizeof(string),"{9EB8E8}Witamy ponownie {F2EE0C}%s{9EB8E8}. Proszę wpisać poniżej swoje hasło, aby zalogować się i grać:", PlayerName(playerid)); ShowPlayerDialog(playerid, DIALOG_LOGOWANIE, DIALOG_STYLE_INPUT, "Logowanie", string, "Zaloguj", "Wyjdź"); GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~r~Nieprawidlowe haslo!", SECONDS(3), 3); } return true; }
When i type good password (for sure) it's sending me a GameTextForPlayer. When i type bad password it's sending GameText too. Why?
P.S
I'm learning from the ready code. After that i'll analize Y_Ini fully you got my word. It's my first time when i'm making script with other script than DINI, so.. : )
|
I got my mouth shut by Y_Less, damn.
However, this happens because Password string is null.
Also, why are you doing this here? You don't write in file on login, you retrieve it.
pawn Код:
new INI:Account;
Account = INI_Open(PlayerFile(playerid));
INI_Close(Account);
Shouldn't this return 0? I mean it should have a ! in front so it matches!
pawn Код:
if(!strcmp(PlayerPass, buf))
Check first if the password has been retrieved from file successfully.
Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
About that:
pawn Код:
new INI:Account;
Account = INI_Open(PlayerFile(playerid));
INI_Close(Account);
I'll read something and give it player from file. I must do it some other way?
With this '!':
pawn Код:
if(!strcmp(PlayerPass, buf))
It's nothing sending back. When i type bad password it should send me:
pawn Код:
GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~r~Nieprawidlowe haslo!", SECONDS(3), 3);
But logging me in.
Re: Y_Ini - Let's do it! -
Zh3r0 - 10.03.2011
Quote:
Originally Posted by Riddick94
About that:
pawn Код:
new INI:Account; Account = INI_Open(PlayerFile(playerid));
INI_Close(Account);
I'll read something and give it player from file. I must do it some other way?
With this '!':
pawn Код:
if(!strcmp(PlayerPass, buf))
It's nothing sending back. When i type bad password it should send me:
pawn Код:
GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~r~Nieprawidlowe haslo!", SECONDS(3), 3);
But logging me in.
|
Like i said, make a check to see if the password is loading and if i the correct value!
Or wait a second, Y_Less, do you remember, i saw that Y_Ini max string size is 128 and Whirlpoop needs 129? May this cause it? or i got bad informed ?
Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
Quote:
Originally Posted by Zh3r0
Y_Less, do you remember, i saw that Y_Ini max string size is 128 and Whirlpoop needs 129? May this cause it? or i got bad informed ?
|
Damn! i remember when i try to use DJSON with Whirpool. I was need to change String to 295. I'll try to change here to 129 and try, yes? Need to change in include
pawn Код:
#define MAX_INI_ENTRY_TEXT 128
on 129 yes?
Re: Y_Ini - Let's do it! -
Zh3r0 - 10.03.2011
Quote:
Originally Posted by Riddick94
Damn! i remember when i try to use DJSON with Whirpool. I was need to change String to 295. I'll try to change here to 129 and try, yes? Need to change in include
pawn Код:
#define MAX_INI_ENTRY_TEXT 128
on 129 yes?
|
Yes, right there, after you done that, go and test again the login function.
Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
Nothing. When i type bad password it's logging me in. I remember in DJSON i added same define OVER includes.
edit://
With making new define same.. nothing.
Re: Y_Ini - Let's do it! -
Zh3r0 - 10.03.2011
Quote:
Originally Posted by Riddick94
Nothing. When i type bad password it's logging me in. I remember in DJSON i added same define OVER includes.
edit://
With making new define same.. nothing.
|
You can inspire yourself from here:
https://sampforum.blast.hk/showthread.php?tid=210277
Check how i made things, but, i didn't use the Whirlpool, but that can be done easy with just changing a variable to another.
Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
I rather wait for Y_Less : )
P.S
I already have this script in new.pwn and looking in it but your code is too hard to read. I'll wait
Re: Y_Ini - Let's do it! -
Zh3r0 - 10.03.2011
Quote:
Originally Posted by Riddick94
I rather wait for Y_Less : )
P.S
I already have this script in new.pwn and looking in it but your code is too hard to read. I'll wait 
|
It isn't hard, it's just made with dialogs, that's all, but the inputtext can be replaced.
Anything else you want to know until Y_Less responses ?
Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
Can you tell me how to read something from player file and give it them? As you saw.. i was trying to Open player account and do some function (at the momment don't know what because waiting for this register/login system).
In your script is.. "LoadUser" yes? is there more ways to load something?
P.S
I don't like PVars too much. (not because i don't know how to use them but i rather not using them)
Re: Y_Ini - Let's do it! -
Zh3r0 - 10.03.2011
Quote:
Originally Posted by Riddick94
Can you tell me how to read something from player file and give it them? As you saw.. i was trying to Open player account and do some function (at the momment don't know what because waiting for this register/login system).
In your script is.. "LoadUser" yes? is there more ways to load something?
P.S
I don't like PVars too much. (not because i don't know how to use them but i rather not using them)
|
First of all, you need an Encoder to encode special characters a name could have, like, %$#^&, those characters are not supported by the files, so it need to be encoded into a special number then decoded when reading.
you must use INI_ParseFile.
pawn Код:
forward LoadPassword( playerid, name[ ], value[ ] );
new pPass[ MAX_PLAYERS ][ 256 ];
public LoadPassword( playerid, name[ ], value[ ] )
{
if ( !strcmp( name, "Password" ) ) format( pPass[ playerid ], sizeof( pPass[ playerid ] ), "%s", value );
}
//A command to see if it was retrieved, a test command!
if ( strcmp( cmdtext, "/test" ) )
{
INI_ParseFile( "file.ini", "LoadPassword", .bExtra = true, .extra = playerid );
new Str[ 256 ];
format( Str, 256, "PASSWORD: %s", pPass[ playerid ] );
SendClientMessage( playerid, -1, Str );
return 1;
}
Just for testing, create a new file in scriptfiles named file.ini, inside insert this:
Код:
Password = PASS123TESTLOLHEHEOMG
Then try the code above
Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
What is that..
pawn Код:
.bExtra = true, .extra = playerid );
?
Okey so.. when player leave server i'm making this:
pawn Код:
new INI:Account;
Account = INI_Open(PlayerFile(playerid));
INI_WriteInt(Account, "Money", GetPlayerMoneyEx(playerid));
INI_WriteInt(Account, "FightStyle", GetPlayerFightingStyle(playerid));
INI_Close(Account);
To load INI_ParseFile? but..
Like that yes?
pawn Код:
public LoadPassword( playerid, name[ ], value[ ] )
{
// Here loading the money. Yes? but.. how?
}
Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
I was deleted my userfile named Riddick.ini and register again. After that new register i typed /q and type bad password in dialog - response (logged in).
Re: Y_Ini - Let's do it! -
Zh3r0 - 10.03.2011
Quote:
Originally Posted by Riddick94
What is that..
pawn Код:
.bExtra = true, .extra = playerid );
?
Okey so.. when player leave server i'm making this:
pawn Код:
new INI:Account; Account = INI_Open(PlayerFile(playerid)); INI_WriteInt(Account, "Money", GetPlayerMoneyEx(playerid)); INI_WriteInt(Account, "FightStyle", GetPlayerFightingStyle(playerid)); INI_Close(Account);
To load INI_ParseFile? but..
Like that yes?
pawn Код:
public LoadPassword( playerid, name[ ], value[ ] ) { // Here loading the money. Yes? but.. how? }
|
Well you would do another callback, because you don't need to load the password again.
pawn Код:
forward LoadStats( playerid, name[ ], value[ ] );
public LoadStats( playerid, name[ ], value[ ] )
{
if ( ! strcmp( name, "Money" ) ) PlayerMoney[ playerid ] = strval( value );
if ( ! strcmp( name, "FightStyle" ) ) PlayerFightStyle[ playerid ] = strval( value );
}
//USAGE:
INI_ParseFile( "file.ini", "LoadStats", .bExtra = true, .extra = playerid );
The
.bExtra = true, .extra = playerid code adds an extra parameter, example, a playerid.
.bExtra if set true must be folowed by .extra which contains the player id.
Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
BUT! in DJSON i was have buf[145]; - but.. i think it's unnecessary to fix my problem.
Re: Y_Ini - Let's do it! -
Zh3r0 - 10.03.2011
Quote:
Originally Posted by Riddick94
BUT! in DJSON i was have buf[145]; - but.. i think it's unnecessary to fix my problem.
|
Stop comparing Y_Ini with DJSON, Y_Ini it's a lot different. So did you understand what i told you ?
Re: Y_Ini - Let's do it! -
Riddick94 - 10.03.2011
Quote:
Originally Posted by Zh3r0
Well you would do another callback, because you don't need to load the password again.
pawn Код:
forward LoadStats( playerid, name[ ], value[ ] ); public LoadStats( playerid, name[ ], value[ ] ) { if ( ! strcmp( name, "Money" ) ) PlayerMoney[ playerid ] = strval( value ); if ( ! strcmp( name, "FightStyle" ) ) PlayerFightStyle[ playerid ] = strval( value ); }
//USAGE: INI_ParseFile( "file.ini", "LoadStats", .bExtra = true, .extra = playerid );
The .bExtra = true, .extra = playerid code adds an extra parameter, example, a playerid.
.bExtra if set true must be folowed by .extra which contains the player id.
|
pawn Код:
stock LoadStats(playerid, name[], value[])
{
if(!strcmp(name, "Money")) SetPlayerMoneyEx(playerid) = strval(value);
if(!strcmp(name, "FightStyle")) SetPlayerFightingStyle(playerid) = strval(value);
}
pawn Код:
stock OnPlayerLogin(playerid, password[])
{
INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword");
new PlayerPass[129], buf[129];
GetPVarString(playerid, "pPass", PlayerPass, 129);
WP_Hash(buf, sizeof(buf), password);
if(!strcmp(PlayerPass, buf))
{
PlayerInfo[playerid][pLogged] = true;
TogglePlayerClock(playerid, true);
INI_ParseFile(PlayerFile(playerid), "LoadStats", .bExtra = true, .extra = playerid);
SendDeathMessage(INVALID_PLAYER_ID, playerid, ICON_CONNECT);
SendFormattedMessageToAll(COLOR_WHITE, "*** %s [{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}] dołączył do serwera.", PlayerName(playerid), playerid);
SendFormattedMessage(playerid, COLOR_LIMON, "{1BE03F}* Zalogowany jako {EDBC6D}%s {FFFFFF}[{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}]{1BE03F}. Witamy spowrotem na Polskim eXtra Serwerze!", PlayerName(playerid), playerid);
}else{
new string[128];
format(string,sizeof(string),"{9EB8E8}Witamy ponownie {F2EE0C}%s{9EB8E8}. Proszę wpisać poniżej swoje hasło, aby zalogować się i grać:", PlayerName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGOWANIE, DIALOG_STYLE_INPUT, "Logowanie", string, "Zaloguj", "Wyjdź");
GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~r~Nieprawidlowe haslo!", SECONDS(3), 3);
}
return true;
}