26.09.2015, 00:56
alguem pode fazer uma base daradmin ? pra eu estudar
new Admin[MAX_PLAYERS];
new cmd[128],
tmp[128],
idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd,"/daradmin", true)==0)
{
if(IsPlayerAdmin(playerid))
{
new plid, skin;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))return SendClientMessage(playerid, 0xFF0000AA, "[x] Digite: \"/daradmin [id] [Level]\"");
plid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))return SendClientMessage(playerid, 0xFF0000AA, "[x] Digite: \"/daradmin[id] [Level]\"");
skin = strval(tmp);
if(skin>=4)return SendClientMessage(playerid, Vermelho, "[x] O level permitido para administrador й 0 а 3");
new string[248];
if(IsPlayerConnected(plid))
{
Admin[plid] = skin;
if(skin == 1)
{
format(string, sizeof(string), "| INFO-SERVER | O Administrador(a) %s (%d) (») Promoveu: %s (%d) para Ajudante (»)", Nome(playerid),playerid,Nome(plid),plid);
SendClientMessageToAll(0x03966AAA, string);
}
if(skin == 2)
{
format(string, sizeof(string), "| INFO-SERVER | O Administrador(a) %s (%d) (») Promoveu: %s (%d) para Moderador(a) (»)", Nome(playerid),playerid,Nome(plid),plid);
SendClientMessageToAll(0x03966AAA, string);
}
if(skin == 3)
{
format(string, sizeof(string), "| INFO-SERVER | O Administrador(a) %s (%d) (») Promoveu: %s (%d) para Administrador(a) (»)", Nome(playerid),playerid,Nome(plid),plid);
SendClientMessageToAll(0x03966AAA, string);
}
if(skin == 0)
{
format(string, sizeof(string), "| INFO-SERVER | O Administrador(a) %s (%d) (») Retirou o Admin do jogador: %s (ID: %d)", Nome(playerid),playerid,Nome(plid),plid);
SendClientMessageToAll(0x03966AAA, string);
}
return 1;
}else{
SendClientMessage(playerid, 0xFF0000AA, "[x] Jogador nгo conectado.");
return 1;
}
}
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
stock Nome(playerid)
{
new name[24];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
if(Admin[playerid] >= 1)
{
}//Coloca isso no comando para verificar se й da administraзгo
if(Admin[playerid] == 3)
{
}//Coloca isso no comando para verificar se й administrador
CMD:daradmin(playerid, params[]) {
if(Admin[playerid] < 5) {
return 1;
}
new targetid, level;
if(sscanf(params, "ud", targetid, level) || targetid == 0xFFFF) {
return 1;
}
if(!IsPlayerConnected(targetid)) {
return 1;
}
if(!(0 <= level <= 5)) {
return 1;
}
Admin[targetid] = level;
return 1;
}
CMD:setadmin(playerid, params[])
{
new Level, idplayer, aname[MAX_PLAYER_NAME], pname[MAX_PLAYER_NAME], file[155];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}[ERROR] {FFFFFF}YOU DONT HAVE ACESS FOR COMMAND");
if(sscanf(params, "dd", idplayer, Level)) return SendClientMessage(playerid, -1, "[ ERRO] {FF0000}use: /setadmin [playerid] [level 0-8]");
if(Level < 0 || Level > 5) return SendClientMessage(playerid, -1, "Escolha um level de 0 a 5");
GetPlayerName(playerid, aname, sizeof(aname));
GetPlayerName(idplayer, pname, sizeof(pname));
format(file, sizeof(file), "Contas/%s.ini", aname);
DOF2_SetInt(file, "Admin", Level);
Player[idplayer][Admin] = Level;
SendClientMessage(idplayer,-1," The Leader the clan [ SHEEP ] has give clan for you!!");
return 1;
}
CMD:ballas(playerid, params[])
{
if(Player[playerid][Admin] < 1) return SendClientMessage(playerid, -1, "[ERROR] VOCК NГO TEM ATURORIZAЗГO PARA USAR ESTE COMANDO");
SetPlayerPos(playerid,2000.1458,-1115.6583,27.1318);
return 1;
}
espero ter ajudado !
COMMAND:daradmin(playerid, params[])
{
// Configs da variavel
new OtherPlayer, Level, Msg[128], Name[24], AdminName[24], OldLevel;
// Mostra quem digitou o comandos "para adms"
SendAdminText(playerid, "/daradm", params);
// Verifica se o player esta logado
if (APlayerData[playerid][LoggedIn] == true)
{
// Verifica se quem digitou o comando й adm
if (APlayerData[playerid][PlayerLevel] >= 5)
{
if (sscanf(params, "ui", OtherPlayer, Level)) SendClientMessage(playerid, 0xFF0000AA, "Digite: \"/daradm <Player> <AdminLevel>\"");
else
{
// Verifica se o player esta on
if (IsPlayerConnected(OtherPlayer))
{
// Obtem o antigo level
OldLevel = APlayerData[OtherPlayer][PlayerLevel];
// Obtem o nome do adm que setou o level
GetPlayerName(playerid, AdminName, sizeof(AdminName));
// Obtem o nome do jogador
GetPlayerName(OtherPlayer, Name, sizeof(Name));
// Guarda o Level do Player
APlayerData[OtherPlayer][PlayerLevel] = Level;
if (OldLevel != Level)
{
// Verifique se o jogador foi promovido ou rebaixado
if (OldLevel < Level)
format(Msg, 128, "{32CD32}%s {FFFFFF}Foi Promovido a {32CD32}%s {FFFFFF}por {32CD32}%s", Name, AdminLevelName[Level], AdminName);
if (OldLevel > Level)
format(Msg, 128, "{CD0000}%s {FFFFFF}Foi Rebaixado a {CD0000}%s {FFFFFF}por {CD0000}%s", Name, AdminLevelName[Level], AdminName);
SendClientMessageToAll(0x00FFFFFF, Msg);
}
else
SendClientMessage(playerid, 0xFF0000FF, "{CD0000}- {FFFFFF}O Level de outro Jogador nao Foi Alterado");
}
else
SendClientMessage(playerid, 0xFF0000FF, "{CD0000}- {FFFFFF}O Player nao esta Online");
}
}
else
return 0;
}
else
return 0;
return 1;
}