PHP код:
if(strcmp(cmd, "/register", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /register [PASSWORD]");
format(file,sizeof(file),"%s.ini", name);
if(!fexist(file))
{
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(tmp));
dini_IntSet(file, "Money", 2500);
dini_IntSet(file, "Score", 1);
dini_IntSet(file, "Bank", 1000);
dini_IntSet(file, "RobSkill", 1);
dini_IntSet(file, "TerSkill", 1);
dini_IntSet(file, "Admin", 0);
dini_IntSet(file, "Warnings", 0);
dini_IntSet(file, "WantedLevel", 0);
dini_IntSet(file, "Jail", 0);
dini_IntSet(file, "RentalOwner", 0);
dini_IntSet(file, "Drugs", 0);
dini_IntSet(file, "C4", 0);
dini_IntSet(file, "Skin", 0);
SendClientMessage(playerid, GREY, "Thanks for registering!");
SendClientMessage(playerid, GREY, "You may now login.");
SendClientMessage(playerid, GREY, "To do so, type: /login [PASSWORD]");
GameTextForPlayer(playerid, "~r~Registered!", 3000, 1);
}
else SendClientMessage(playerid, ERROR, "This account is already registered in our system. Use: /login [PASSWORD]");
return true;
}
if(strcmp(cmd, "/login", true) == 0)
{
new tmp2[256];
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /login [PASSWORD]");
else
{
if(IsPlayerLogged[playerid] == 1) return SendClientMessage(playerid, ERROR, "You are already logged in.");
else
{
if(fexist(file))
{
tmp2 = dini_Get(file, "Password");
if(udb_hash(tmp) != strval(tmp2)) return SendClientMessage(playerid, ERROR, "Invalid password.");
else
{
IsPlayerLogged[playerid] = 1;
SetPlayerMoney(playerid, dini_Int(file, "Money"));
SetPlayerScore(playerid, dini_Int(file, "Score"));
PlayerSkin[playerid] = dini_Int(file,"Skin");
SetPlayerWantedLevel(playerid, dini_Int(file, "WantedLevel"));
SendClientMessage(playerid, GREEN, "You are now logged in.you have continue your stats has been automatique saved.");
GameTextForPlayer(playerid, "~r~Logged In!", 3000, 1);
}
}
else return SendClientMessage(playerid, ERROR, "This username was not found on our database. Use: /register [PASSWORD]");
}
}
return true;
}