public OnPlayerConnect(playerid)
{
new string[MAX_PLAYER_NAME];
GetPlayerName(playerid,string, sizeof(string));
if(fexist(string))
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "This Account Has been located on our Database.");
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Login","Please enter your pass","Login","Quit");
}
else
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "This Account isn't on our Database, Please Register.");
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Please Register an Account","Type your password below","REGISTER","Quit");
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1 && response)
{
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
//Encrypt(tmppass);
OnPlayerLogin(playerid,tmppass);
}
if(dialogid == 2 && response)
{
if(strlen(inputtext))
{
new sendername[MAX_PLAYER_NAME];
new string2[56];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string2, sizeof(string2), "%s.ini", sendername);
new File: hFile = fopen(string2, io_read);
if (hFile)
{
SendClientMessage(playerid, COLOR_YELLOW, "That Username is already taken, please choose a different one.");
fclose(hFile);
Kick(playerid);
return 1;
}
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
//Encrypt(tmppass);
// OnPlayerRegister(playerid,tmppass);
}
}
return 1;
}
public OnPlayerLogin(playerid,password[])
{
// new tmp2[256];
new string2[64];
new playername2[MAX_PLAYER_NAME];
new playernamesplit[3][MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
split(playername2, playernamesplit, '_');
format(string2, sizeof(string2), "users/%s.ini", playername2);
new File: UserFile = fopen(string2, io_read);
if ( UserFile )
{
new PassData[256];
new keytmp[256], valtmp[256];
fread( UserFile , PassData , sizeof( PassData ) );
keytmp = ini_GetKey( PassData );
if( strcmp( keytmp , "Key" , true ) == 0 )
{
valtmp = ini_GetValue( PassData );
strmid(PlayerInfo[playerid][pPass], valtmp, 0, strlen(valtmp)-1, 255);
}
if(strcmp(PlayerInfo[playerid][pPass],password, true ) == 0 )
{
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "Activity" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pActivity] = strval( val ); }
if( strcmp( key , "AdminLevel=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); }
if( strcmp( key , "Money=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pMoney] = strval( val ); }
if( strcmp( key , "Registered=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pRegistered] = strval( val ); }
if( strcmp( key , "GangID=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGang] = strval( val ); }
if( strcmp( key , "GMember" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGangMember] = strval( val ); }
if( strcmp( key , "GLeader" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGangLeader] = strval( val ); }
if( strcmp( key , "Muted" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pMuted] = strval( val ); }
if( strcmp( key , "FactionID" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pFaction] = strval( val ); }
if( strcmp( key , "FMember=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pFactionMember] = strval( val ); }
if( strcmp( key , "FLeader=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pFactionLeader] = strval( val ); }
if( strcmp( key , "GunSkills=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunSkills] = strval( val ); }
if( strcmp( key , "Gun=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGun] = strval( val ); }
if( strcmp( key , "Gun2=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGun2] = strval( val ); }
if( strcmp( key , "Gun3=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGun3] = strval( val ); }
if( strcmp( key , "Gun4=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGun4] = strval( val ); }
if( strcmp( key , "GunAmmo=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunAmmo] = strval( val ); }
if( strcmp( key , "GunAmmo2=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunAmmo2] = strval( val ); }
if( strcmp( key , "GunAmmo3=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunAmmo3] = strval( val ); }
if( strcmp( key , "GunAmmo4=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunAmmo4] = strval( val ); }
if( strcmp( key , "CarLicense=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCarLicense] = strval( val ); }
if( strcmp( key , "FlyingLicense=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pFlyingLicense] = strval( val ); }
}
fclose(UserFile);//close the file after everything has been read in the while
}
else
{
new loginstring[128];
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
format(loginstring,sizeof(loginstring),"WRONG PASSWORD\nPlease enter the correct password:",loginname);
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Login",loginstring,"Login","Exit");
fclose(UserFile);
gPlayerLogTries[playerid] += 1;
if(gPlayerLogTries[playerid] == 3) { Ban(playerid); }
return 1;
}
new string3[56];
SendClientMessage(playerid,COLOR_DBLUE,"|--- Welcome to Gen RP ---|");
format(string3, sizeof(string3), "You have %d Activity Points",PlayerInfo[playerid][pActivity]);
SendClientMessage(playerid,COLOR_LIGHTBLUE, string3);
if(PlayerInfo[playerid][pGang] >= 0)
{
new string1[50];
new string02[67];
format(string1, sizeof(string1)," Gang ID: %d",PlayerInfo[playerid][pGang]);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string1);
format(string02, sizeof(string02),"Money: %d",PlayerInfo[playerid][pMoney]);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string02);
}
return 1;
}
return 1;
}
Originally Posted by ray187
Hire a scripter if you need whole functions build from scratch
|