Код:
if (strcmp(cmd, "/register", true) == 0)
{
if (logged[playerid] != 1 && !udb_Exists(PlayerName(playerid)))
{
new dir[256];
dir = strtok(cmdtext, idx);
if (strlen(dir))
{
new fname[MAX_STRING];
format(fname,sizeof(fname),"users/%s.ini",udb_encode(PlayerName(playerid)));
dini_Create(fname);
dUserSet(PlayerName(playerid)).("password", dir);
dUserSet(PlayerName(playerid)).("admin", "0");
dUserSet(PlayerName(playerid)).("banned", "0");
dUserSet(PlayerName(playerid)).("owngoals", "0");
dUserSet(PlayerName(playerid)).("goalsscored", "0");
dUserSet(PlayerName(playerid)).("gamesplayed", "0");
SendClientMessage(playerid, COLOR_RED, "Registrado, porfavor logeate con /login");
}
}
else SendClientMessage(playerid, COLOR_RED, "Error al registrarse!");
return 1;
}
if (logged[playerid] == 0) {
SendClientMessage(playerid, COLOR_YELLOW, "[SERVER] Tienes que estar logeado para usar estos comandos!");
return 1;
}
Код:
if (strcmp(cmd, "/login", true) == 0)
{
if (dUserINT(PlayerName(playerid)).("banned") == 1)
{
new pName[MAX_PLAYER_NAME];
new string1[128];
GetPlayerName(playerid, pName, sizeof(pName));
format(string1, sizeof(string1), "%s a sido kickeado del servidor, Rasуn: CUENTA BANEADA.", pName);
SendClientMessageToAll(COLOR_RED, string1);
Kick(playerid);
}
else if (logged[playerid] != 1 && udb_Exists(PlayerName(playerid)))
{
new dir[256];
dir = strtok(cmdtext, idx);
if (strlen(dir) && strcmp(dir, dUser(PlayerName(playerid)).("password"), true) == 0)
{
logged[playerid] = 1;
new score = dUserINT(PlayerName(playerid)).("goalsscored");
SetPlayerScore(playerid,score);
SendClientMessage(playerid, COLOR_RED, "Logeado con excito!");
}
}
else SendClientMessage(playerid, COLOR_RED, "Error al logearse!");
return 1;
}