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
Nivel
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]);
GetPlayerName(playerid, Nome, 24);
if(fexist(string)) return cmd_logar(playerid, params[]);
AdminInfo[playerid][Logado] = true;
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[]);
if(sscanf(params,"d", Senha[playerid]))
if(strcmp(dini_Get(string, "Senha"), inputtext, true) != 0)
AdminInfo[playerid][Logado] = true;
dini_Get(string, "Nivel"); AdminInfo[playerid][Nivel] = dini_Int(string,"Nivel");
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.");
if(sscanf(params, "ud", GivePlayerid, Level)
if(Level > 5 || Level < 0)
if(AdminInfo[GivePlayerid][Nivel] == Level)
AdminInfo[GivePlayerid][Nivel] == Level;
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; }
Créditos