19.07.2010, 08:35
pawn Код:
enum pInfo
{
pLogged,
pAdmin,
pClanTag[5],
pMoney,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
CMD:login(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
new file[128];
new password[256];
new message[128];
new spassword[256];
format(file, sizeof(file), "%s.ini", ReturnPlayerName(playerid));
if(sscanf(params, "s", password)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /login [password]");
if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You need to register first, type /register");
if(PlayerInfo[playerid][pLogged]) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You're already logged in");
spassword = dini_Get(file, "hashPW");
if(udb_hash(password) != strval(spassword))
{
format(message, sizeof(message), "SERVER: Invalid password");
SendClientMessage(playerid, COLOR_WHITE, message);
}
else
{
PlayerInfo[playerid][pLogged] = 1;
PlayerInfo[playerid][pAdmin] = dini_Int(file, "admlvl");
PlayerInfo[playerid][pMoney] = dini_Int(file, "money");
strmid(PlayerInfo[playerid][pClanTag], dini_Get(file, "clantag"), 0, strlen(dini_Get(file, "clantag")), 255);
GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
format(message, sizeof(message), "SERVER: Welcome back, %s.", ReturnPlayerName(playerid));
SendClientMessage(playerid, COLOR_WHITE, message);
}
}
return 1;
}