03.02.2012, 15:01
First of all use enums for this.
Replace these
To
Also, replace
To
And this
To
Last,
In conclusion, if you are using the last version of whirlpool, you should have this at the top
Replace these
pawn Код:
new
Score[MAX_PLAYERS],
Money[MAX_PLAYERS],
Admin[MAX_PLAYERS],
hPass[129];
pawn Код:
enum uData
{
Score,
Money,
Admin,
hPass[ 129 ]
}
new
UserData[ MAX_PLAYERS ][ uData ];
pawn Код:
stock LoadPlayerAccount_data(playerid,name[],value[])
{
INI_String("Password",hPass,129);
INI_Int("Money",Money[playerid]);
INI_Int("Score",Score[playerid]);
INI_Int("Adminlevel",Admin[playerid]);
return 1;
}
pawn Код:
forward LoadPlayerAccount_data( playerid, name[ ], value[ ] );
public LoadPlayerAccount_data( playerid, name[ ], value[ ] )
{
INI_String( "Password", UserData[ playerid ][ hPass ], 129 ) ;
INI_Int( "Money", UserData[ playerid ][ Money ] );
INI_Int( "Score", UserData[ playerid ][ Score ] );
INI_Int( "Adminlevel", UserData[ playerid ][ Admin ] );
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==1) {
if(response==1) {
if(!strlen(inputtext)) {
PlayerPlaySound(playerid,1055,0,0,0);
SendClientMessage(playerid,COLOR_RED,"Invalid password,please try again");
ShowPlayerDialog(playerid,DIALOG_STYLE_INPUT,1,"Register","Please type in a password to register: ","Register","Cancel");
}
else {
new pName[24];
GetPlayerName(playerid,pName,sizeof(pName));
LoadRegisteredAccount(playerid);
SendClientMessage(playerid,COLOR_GREEN,"Succesfully registered!!!");
PlayerPlaySound(playerid,1057,0,0,0);
SendClientMessage(playerid,COLOR_PURPLE,"This is San Fierro RolePlay");
SendClientMessage(playerid,COLOR_YELLOW,"Type /new for more infos about the server");
SendClientMessage(playerid,COLOR_YELLOW,"Type /rules for server rules");
LoadRegisteredAccount(playerid);
new INI:PFile = INI_Open(Accounts(playerid));
INI_SetTag(PFile,"PlayerInfo");
WP_Hash(hPass,129,inputtext);
INI_WriteString(PFile,"Password",hPass);
INI_WriteInt(PFile,"Score",GetPlayerScore(playerid));
INI_WriteInt(PFile,"Money",GetPlayerMoney(playerid));
INI_WriteInt(PFile,"Adminlevel",0);
INI_Close(PFile);
}
}
if(response==0) {
SendClientMessage(playerid,COLOR_GREEN,"I hope you will be back soon");
Kick(playerid);
}
}
// Rest
pawn Код:
public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
{
if( dialogid == 1 ) {
if( response == 1 ) {
if( !strlen( inputtext ) ) {
PlayerPlaySound (playerid, 1055, 0, 0, 0 );
SendClientMessage( playerid, COLOR_RED, "Invalid password,please try again" );
ShowPlayerDialog( playerid, DIALOG_STYLE_INPUT, 1, "Register", "Please type in a password to register: ", "Register", "Cancel" );
}
else {
new
hashed_password[ 129 ], pName[ 24 ];
WP_Hash( hashed_password, sizeof( hashed_password ), inputtext );
GetPlayerName( playerid, pName, sizeof( pName ) );
LoadRegisteredAccount( playerid );
SendClientMessage( playerid, COLOR_GREEN, "Succesfully registered!!!" );
PlayerPlaySound( playerid, 1057, 0, 0, 0 );
SendClientMessage( playerid, COLOR_PURPLE, "This is San Fierro RolePlay" );
SendClientMessage( playerid, COLOR_YELLOW, "Type /new for more infos about the server" );
SendClientMessage( playerid, COLOR_YELLOW, "Type /rules for server rules" );
LoadRegisteredAccount( playerid );
new INI:PFile = INI_Open( Accounts( playerid ) );
INI_SetTag( PFile, "PlayerInfo" );
INI_WriteString( PFile, "Password", hashed_password );
INI_WriteInt( PFile, "Score", GetPlayerScore( playerid ) );
INI_WriteInt( PFile, "Money", GetPlayerMoney( playerid ) );
INI_WriteInt( PFile, "Adminlevel", 0 );
INI_Close( PFile );
}
}
if( response == 0 ) {
SendClientMessage( playerid, COLOR_GREEN, "I hope you will be back soon" );
Kick( playerid );
}
}
// Rest
pawn Код:
// On Login
new
hashed_password[ 129 ];
WP_Hash( hashed_password, sizeof( hashed_password ), inputtext );
if( !strcmp( hashed_password, UserData[ playerid ][ hPass ] ) )
{
INI_ParseFile( Accounts( playerid ), "LoadPlayerAccount_%s", .bExtra = true, .extra = playerid );
// Rest of settings.
else
{
// Kick...
}
pawn Код:
#include < a_samp >
#define MAX_INI_ENTRY_TEXT 130
#include < YSI\y_ini >
// Rest

