10.03.2011, 14:44
pawn Код:
WP_Hash(buf, sizeof(buf), password);
if(!strcmp(PlayerPass, password) == buf)
WP_Hash(buf, sizeof(buf), password);
if(!strcmp(PlayerPass, password) == buf)
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;
}
pawn Код:
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.. : ) |
new INI:Account;
Account = INI_Open(PlayerFile(playerid));
INI_Close(Account);
if(!strcmp(PlayerPass, buf))
new INI:Account;
Account = INI_Open(PlayerFile(playerid));
INI_Close(Account);
if(!strcmp(PlayerPass, buf))
GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~r~Nieprawidlowe haslo!", SECONDS(3), 3);
About that:
pawn Код:
With this '!': pawn Код:
pawn Код:
|
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 ?
|
#define MAX_INI_ENTRY_TEXT 128
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. |
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 |
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) |
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;
}
Password = PASS123TESTLOLHEHEOMG
.bExtra = true, .extra = playerid );
new INI:Account;
Account = INI_Open(PlayerFile(playerid));
INI_WriteInt(Account, "Money", GetPlayerMoneyEx(playerid));
INI_WriteInt(Account, "FightStyle", GetPlayerFightingStyle(playerid));
INI_Close(Account);
public LoadPassword( playerid, name[ ], value[ ] )
{
// Here loading the money. Yes? but.. how?
}
What is that..
pawn Код:
Okey so.. when player leave server i'm making this: pawn Код:
Like that yes? 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 );
Well you would do another callback, because you don't need to load the password again.
pawn Код:
.bExtra if set true must be folowed by .extra which contains the player id. |
stock LoadStats(playerid, name[], value[])
{
if(!strcmp(name, "Money")) SetPlayerMoneyEx(playerid) = strval(value);
if(!strcmp(name, "FightStyle")) SetPlayerFightingStyle(playerid) = strval(value);
}
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;
}