[AJUDA] Comandos de Admin
#9

Vocк pode criar um sistema de admin bбsico:

pawn Код:
#include <a_samp>
#include <dini>

new pAdmin[MAX_PLAYERS];
new admin[MAX_PLAYERS]= 0;

public OnPlayerConnect(playerid)
{
    pAdmin[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new aname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
    format(file, sizeof(file), DIRETORIO, aname);
    dini_IntSet(file, "LevelAdm", pAdmin[playerid]);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(pAdmin[playerid]> 0) admin[playerid] = 1;
    dini_IntSet(file, "LevelAdm", pAdmin[playerid]);
    }
    return 1;
}

public OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp(cmd,"/setadmin", true)==0)
{
    new aname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
    if(IsPlayerAdmin(playerid))
    {
        new plid, leveladm;
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, Vermelho, "(INFO) Digite: /setadmin [id] [Level]");
            return 1;
        }
        plid = strval(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, Vermelho, "(INFO) Digite: /setadmin [id] [Level]");
            return 1;
        }
        leveladm = strval(tmp);
        if(leveladm>=7)
        {
            SendClientMessage(playerid, Vermelho, "(INFO) Niveis permitidos: 0 a 6.");
            return 1;
        }
        new pname[MAX_PLAYER_NAME];
        GetPlayerName(plid, pname, MAX_PLAYER_NAME);
        if(IsPlayerConnected(plid))
        {
            if(leveladm>=1)
            {
                pAdmin[plid] = leveladm;
                dini_IntSet(file, "LevelAdm",leveladm);
                format(string, sizeof(string), "(INFO) Vocк foi promovido a Admin Level %d por : %s!", leveladm,aname);
                SendClientMessage(plid,vbadm, string);
                if(leveladm>1)
                {
                }
            }
            if(leveladm == 0)
            {
                pAdmin[plid] = 0;
                dini_IntSet(file, "LevelAdm",0);
                format(string, sizeof(string), "(INFO) %s , retirou seu admin!",aname);
                SendClientMessage(plid,vbadm, string);
                if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
            }
            return 1;
        }
        else {
            SendClientMessage(playerid, Vermelho, "(INFO) Jogador nгo conectado.");
            return 1;
        }
    }
}

if(!strcmp(cmdtext,"/admins", true))
{
    SendClientMessage(playerid,vbadm, "- Adminstradores Conetados -");
    static bool: result;
    for(new i; i < MAX_PLAYERS; ++i)
    {
        new pname[24];
        GetPlayerName(i,pname,24);
        if(IsPlayerConnected(i) && pAdmin[i] > 0)
        {
            if(pAdmin[i] == 1)
            {
                format(string,sizeof(string),"[%s] (%d) ~ [Sub-Moderador]", pname,i);
            }
            if(pAdmin[i] == 2)
            {
                format(string,sizeof(string),"[%s] (%d) ~ [Moderador]", pname,i);
            }
            if(pAdmin[i] == 3)
            {
                format(string,sizeof(string),"[%s] (%d) ~ [Adminstrador]", pname,i);
            }
            if(pAdmin[i] == 4)
            {
                format(string,sizeof(string),"[%s] (%d) ~ [Admin Master]", pname,i);
            }
            if(pAdmin[i] == 5)
            {
                format(string,sizeof(string),"[%s] (%d) ~ [Sub-Dono]", pname,i);
            }
            if(pAdmin[i] == 6)
            {
                format(string,sizeof(string),"[%s] (%d) ~ [Adminstrador Dono]", pname,i);
            }
            SendClientMessage(playerid, COLOR_WHITE, string);
            result = true;
        }
    }
    if(!result)
        return SendClientMessage(playerid, -1,"(x) Nгo tem nenhum administrador online no momento!");
    return true;
}
return 0;
}
Vocк pode adicionar um comando pra admistrador assim:

para os 6 leveis
pawn Код:
if(strcmp(cmd, "/teste",true) == 0)
{
    if(pAdmin[playerid] == 1 || pAdmin[playerid] == 2 || pAdmin[playerid] == 3 || pAdmin[playerid] == 4 || pAdmin[playerid] == 5 || pAdmin[playerid] == 6)
    {
        SendClientMessage(playerid, 0x008000AA, "SUCK MY EGGS '-'");
        return 1;
    }
}
Para 3 leveis

pawn Код:
if(strcmp(cmd, "/teste",true) == 0)
{
    if(pAdmin[playerid] == 1 || pAdmin[playerid] == 2 || pAdmin[playerid] == 3)
    {
        SendClientMessage(playerid, 0x008000AA, "SUCK MY DICK off' '-'");
        return 1;
    }
}
Na Variavel de login vc coloca:
pawn Код:
pAdmin[playerid] = dini_Int(file, "LevelAdm");
Reply


Messages In This Thread
[AJUDA] Comandos de Admin - by FLeEX - 03.02.2012, 09:41
Re: [AJUDA] Comandos de Admin - by humildadeforever - 03.02.2012, 10:19
Re: [AJUDA] Comandos de Admin - by Kuddy - 03.02.2012, 10:28
Re: [AJUDA] Comandos de Admin - by humildadeforever - 03.02.2012, 10:34
Re: [AJUDA] Comandos de Admin - by FLeEX - 03.02.2012, 10:54
Re: [AJUDA] Comandos de Admin - by humildadeforever - 03.02.2012, 11:33
Re: [AJUDA] Comandos de Admin - by FLeEX - 03.02.2012, 13:38
Re: [AJUDA] Comandos de Admin - by [Pawno] - 03.02.2012, 13:40
Re: [AJUDA] Comandos de Admin - by dPlaYer_ - 03.02.2012, 13:54
Re: [AJUDA] Comandos de Admin - by [Pawno] - 03.02.2012, 14:01

Forum Jump:


Users browsing this thread: 2 Guest(s)