It's not a Tuturial, but i fixed the code from
this one(CLICK)
For explaination just read the Tuturial.
_________________________________________________
Over script:
pawn Code:
enum pInfo
{
Cash
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new IsPlayerLogged[MAX_PLAYERS];
OnPlayerCommandText:
pawn Code:
dcmd(register, 8, cmdtext);
dcmd(login, 5, cmdtext);
Somewhere else:
pawn Code:
dcmd_register(playerid, params[])
{
new file[MAX_PLAYER_NAME+4];
new PName[MAX_PLAYER_NAME];
new Pass[50];
if(sscanf(params, "s", Pass))return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /register [Password] (maximum: 50 cells)");
if(IsPlayerLogged[playerid]==1)return SendClientMessage(playerid, COLOR_SYSTEM, "You're already logged in!");
GetPlayerName(playerid, PName, sizeof(PName));
format(file,sizeof(file),"D-Admin/Players/%s.ini",PName);
if(!fexist(file))
{
dini_Create(file);
dini_IntSet(file,"Password", udb_hash(Pass));
dini_IntSet(file,"Cash", 0);
SendClientMessage(playerid, COLOR_SYSTEM, "[System]: Account Created! Please log in with /login.");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
printf("[Register]%s has created an account!", PName);
}
else
{
SendClientMessage(playerid, COLOR_SYSTEM, "[System]: Account Already Found In Database");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
}
return 1;
}
pawn Code:
dcmd_login(playerid, params[])
{
new file[MAX_PLAYER_NAME+4];
new PlayerName[MAX_PLAYER_NAME];
new LogPass[50];
if(sscanf(params, "s", LogPass))return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /login [password]");
if(IsPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You already are logged in!");
return 1;
}
else
{
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(file,sizeof(file),"D-Admin/Players/%s.ini",PlayerName);
if(fexist(file))
{
new FilePass[256];
FilePass = dini_Get(file, "Password");
if(udb_hash(LogPass) != strval(FilePass))
{
SendClientMessage(playerid, COLOR_RED, "Login Failed!");
printf("%s has failed logging in!", PlayerName);
}
else
{
IsPlayerLogged[playerid] = 1;
SetPlayerMoney(playerid, dini_Int(file, "Cash"));
PlayerInfo[playerid][Cash] = dini_Int(file, "Cash");
SendClientMessage(playerid, COLOR_GREEN, "[System]: You logged in!");
PlayerPlaySound(playerid,1058,0.0,0.0,0.0);
}
}
}
return 1;
}
_________________________________________________
Cheers.