Sistema de Adminstração Simples.

Olá meus queridos do fórum samp.
Hoje irei postar "Como Criar Sistema de Adminstração Simples.", Bom proveito.

0.0 Início

Primeiramente Baxe Dini Aqui
Depois Abre o Pawno e mão na massa!.

E Obviamente coloque no topo:
pawn Code:
#include <dini> #include <sscanf> #define PASTAPLAYERS "Registro"


0.1 Primeiras Linhas
Crie essas variaveis enumeradas:
pawn Code:
enum gAdmin {     bool:Logado,     Nivel } new AdminInfo[MAX_PLAYERS][gAdmin]; new GivePlayerid; new Nome[24]; new string[200];

Explicação 
bool:Logado  Serve para verificar se o playe está logado ou não.
Nivel  serve para poder ter um nível.


0.2 Começando ...

Crie:
pawn Code:
CMD:registrar(playerid, params[]) {          return 1; }

Info:Não pode conter Números Maiúsculos na parte do comando.

Agora adicione:
pawn Code:
CMD:registrar(playerid, params[]) {          GetPlayerName(playerid, Nome, 24);          format(string, sizeof(string),"%s.txt", Nome);          if(fexist(string)) return cmd_logar(playerid, params[]);            static Senha;          if(sscanf(params,"d", Senha[playerid])) return SendClientMessage(playerid, Cor,"[ERRO]: Correto é:/Registrar [Senha]");          dini_Create(string);          AdminInfo[playerid][Logado] = true;          dini_Set(string, "Nome", Nome);          dini_Set(string, "Senha", Senha);          dini_Set(string, "Nivel", AdminInfo[playerid][Nivel]);          SendClientMessage(playerid, Cor,"[INFO]: Registrado com suscesso!");          return 1; }

Explicando ...

if(sscanf(params,"d", Senha[playerid])) return SendClientMessage(playerid, Vermelho,"[ERRO]: Correto é:/Registrar [Senha]); Serve para verficar se a utilização do código está correcta.

GetPlayerName(playerid, Nome, 24);  Serve para pegar nome do player.

if(fexist(string)) return cmd_logar(playerid, params[]);  Se o Nome do playe estiver registrado ele Rerediciona para login.

AdminInfo[playerid][Logado] = true;  para dizer que está logado.


Agora farei o 'Login' 

Crie também:
pawn Code:
CMD:logar(playerid, params[]) {          GetPlayerName(playerid, Nome, 24);          format(string, sizeof(string),"%s.txt", Nome);          if(!fexist(string)) return cmd_registrar(playerid, params);                  static Senha;          if(sscanf(params,"d", Senha[playerid])) return SendClientMessage(playerid, Cor,"[ERRO]: Correto é:/logar [Senha]");          if(strcmp(dini_Get(string, "Senha"), inputtext, true) != 0)  return SendClientMessage(playerid, Cor,"[ERRO]: Senha Icorreta!");          AdminInfo[playerid][Logado] = true;      dini_Get(string, "Nivel"); AdminInfo[playerid][Nivel] = dini_Int(string,"Nivel");          SendClientMessage(playerid, Cor,"[INFO]: Logado com suscesso!");          return 1; }

Explicando ...

f(!fexist(string)) return cmd_registrar(playerid, params[]);  Verifica se o playe exste, se não existir ele rerediciona para registro.

if(sscanf(params,"d", Senha[playerid]))  Verifica se utilização do comando está correta.

if(strcmp(dini_Get(string, "Senha"), inputtext, true) != 0)  Verifica se a senha está correta.

AdminInfo[playerid][Logado] = true;  Bota como "Logado".

dini_Get(string, "Nivel"); AdminInfo[playerid][Nivel] = dini_Int(string,"Nivel");  Pega o Nivel do Player.

0.3 Sistema de Nível

Crie logo abaixo dos outros comandos:
pawn Code:
CMD:setlevel(playerid, params[]) {            if(!IsPlayerAdmin(playerid))            if(AdminInfo[playerid][Nivel] < 5) return SendClientMessage(playerid, Cor,"[ERRO]: Seu nível é insuficiente para setar como admin ou não está logado na rcon.");            static Level = 0;            if(sscanf(params, "ud", GivePlayerid, Level) return SendClientMessage(playerid, Cor,"[ERRO]: Correto: /SetNivel [ID] [Nivel].");            if(Level > 5 || Level < 0) return SendClientMessage(playerid, Cor,"[ERRO]:Bote Nivel Maior que 1 e menor que 5!.");              if(AdminInfo[GivePlayerid][Nivel] == Level) return SendClientMessage(playerid, Cor,"[ERRO]: Este player já tem este nível.");            AdminInfo[GivePlayerid][Nivel] == Level;            SendClientMessage(GivePlayerid, cor, "[INFO]: Parabéns, você é um adminstrador");            return 1; }

Explicando ...

if(!IsPlayerAdmin(playerid)) if(AdminInfo[playerid][Nivel] < 5) return SendClientMessage(playerid, Cor,"[ERRO]: Seu nível é insuficiente para setar como admin ou não está logado na rcon.");  Verifica se o PLayer que digitou é admin logado na rcon ou admin master.

if(sscanf(params, "ud", GivePlayerid, Level)  Verifica se o comando está sendo utilizado corretamente.

if(Level > 5 || Level < 0)  Verifica se o nível que o Adminstrador deu é incorreto.

if(AdminInfo[GivePlayerid][Nivel] == Level)  Verifica se o Player já tem este nível.

AdminInfo[GivePlayerid][Nivel] == Level;  dá nivel para player.

0.4 Finais 

Crie "Copiosadamente" estes códigos.

pawn Code:
public OnPlayerDisconnect(playerid, reason) {         if(AdminInfo[playerid][Logado] == true)         {                  dini_Set(string, "Nivel", AdminInfo[playerid][Nivel]);         }         return 1; }
Info: os códigos acima serve para salvar o nível quando player logado/registrado sair.


Créditos 
 [iPs]Garfield