Comandos Bбsicos de Administradores
#1

Estou aqui apenas para postar os comandos bбsicos de um Admin em um servidor, independente de seu gкnero, vamos lб.

Primeiramente uma dica, coloque isto no GameMode para nao precisar ficar dando GetPlayerName em si mesmo toda hora.

pawn Код:
stock pNome(playerid)
{
    new nome[MAX_PLAYER_NAME];
    GetPlayerName(playerid,nome,sizeof(nome));
    return nome;
}
Vamos definir as cores que eu usei.
pawn Код:
#define BRANCO 0xFFFFFFAA
#define AMARELO 0xF6F600AA
#define VERMELHO 0xE31919AA
Agora vamos aos comandos

pawn Код:
public OnPlayerCommandText(playerid, cmdtext)
{
    new tmp[256];
    new idx;
    if(strcmp(cmd,"/dararma",true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /DarArma [ID][ID da Arma][Muniзгo]");
            return 1;
        }
        new armado = strval(tmp);
        new armadoname[MAX_PLAYER_NAME];
        GetPlayerName(armado,armadoname,sizeof(armadoname));
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /DarArma [ID][ID da Arma][Muniзгo]");
            return 1;
        }
        new arma = strval(tmp);
        if(arma < 1 || arma > 46)
        {
            SendClientMessage(playerid,BRANCO,"ID Mнnimo 1 - Mбximo 46");
            return 1;
        }
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /DarArma [ID][ID da Arma][Muniзгo]");
            return 1;
        }
        new municao = strval(tmp);
        if(municao < 1 || municao > 9999)
        {
            SendClientMessage(playerid,BRANCO,"Muniзгo Mнnima 1 - Mбxima 9999");
            return 1;
        }
        format(string,sizeof(string),"O Admin %s deu a Arma %d com %d Balas Para %s",pNome(playerid),arma,municao,armadoname);
        SendClientMessageToAll(0xF6F600AA,string);
        format(string,sizeof(string),"Vocк recebeu a arma %d com %d balas do admin %s",arma,municao,pNome(playerid));
        SendClientMessage(playerid,AMARELO,string);
        GivePlayerWeapon(armado,arma,municao);
        return 1;
    }
    if(strcmp(cmd,"/darvida",true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /DarVida [ID][Vida]");
            return 1;
        }
        new vidado = strval(tmp);
        new vidadoname[MAX_PLAYER_NAME];
        GetPlayerName(vidado,vidadoname,sizeof(vidadoname));
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /DarVida [ID][Vida]");
            return 1;
        }
        new vida = strval(tmp);
        if(vida < 0 || vida > 100)
        {
            SendClientMessage(playerid,BRANCO,"Vida Mнnima 0 - Mбxima 100");
            return 1;
        }
        format(string,sizeof(string),"O Admin %s Setou a Vida de %s para %d",pNome(playerid),vidadoname,vida);
        SendClientMessageToAll(0xF6F600AA,string);
        format(string,sizeof(string),"O Admin %s Setou sua Vida para %d",pNome(playerid),vida);
        SendClientMessage(vidado,AMARELO,string);
        SetPlayerHealth(vidado,vida);
        return 1;
    }
    if(strcmp(cmd,"/darcolete",true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /DarVida [ID][Vida]");
            return 1;
        }
        new coletado = strval(tmp);
        new coletadoname[MAX_PLAYER_NAME];
        GetPlayerName(coletado,coletadoname,sizeof(coletadoname));
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /DarColete [ID][Colete]");
            return 1;
        }
        new colete = strval(tmp);
        if(colete < 0 || colete > 100)
        {
            SendClientMessage(playerid,BRANCO,"Colete Mнnimo 0 - Mбximo 100");
            return 1;
        }
        format(string,sizeof(string),"O Admin %s Setou o Colete de %s para %d",pNome(playerid),coletadoname,colete);
        SendClientMessageToAll(0xF6F600AA,string);
        format(string,sizeof(string),"O Admin %s Setou seu Colete para %d",pNome(playerid),colete);
        SendClientMessage(coletado,AMARELO,string);
        SetPlayerArmour(coletado,colete);
        return 1;
    }
    if(strcmp(cmd,"/dargrana",true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /DarGrana [ID/Nome][Grana]");
            return 1;
        }
        new granado = strval(tmp);
        new granadoname[MAX_PLAYER_NAME];
        GetPlayerName(granado,granadoname,sizeof(granadoname));
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /DarGrana [ID/Nome][Grana]");
            return 1;
        }
        new grana = strval(tmp);
        if(grana < 1 || grana > 99999999)
        {
            SendClientMessage(playerid,BRANCO,"Grana Mнnima R$1 - Mбxima R$99999999");
            return 1;
        }
        format(string,sizeof(string),"O Admin %s Deu R$ %d Para %s",pNome(playerid),grana,granadoname);
        SendClientMessageToAll(0xF6F600AA,string);
        format(string,sizeof(string),"Vocк Ganhou R% %d do Admin %s",grana,pNome(playerid));
        SendClientMessage(playerid,AMARELO,string);
        GivePlayerMoney(granado, grana);
        return 1;
    }
    if(strcmp(cmd,"/ir",true) == 0)//testar
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /Ir [ID]");
            return 1;
        }
        new ido = strval(tmp);
        new idoname[MAX_PLAYER_NAME];
        GetPlayerName(ido,idoname,sizeof(idoname));
        new Float:x,Float:y,Float:z,Float:angle;
        GetPlayerPos(ido,x,y,z);
        new playerint = GetPlayerInterior(ido);
        GetPlayerFacingAngle(ido,angle);
        SetPlayerPos(playerid,x,y+0.5,z);
        SetPlayerFacingAngle(playerid,angle);
        SetPlayerInterior(playerid,playerint);
        format(string,sizeof(string),"O Admin %s Foi Atй %s.",pNome(playerid),idoname);
        SendClientMessageToAll(0xF6F600AA,string);
        format(string,sizeof(string),"O Admin %s Veio Atй Vocк.",pNome(playerid));
        SendClientMessage(ido,BRANCO,string);
        return 1;
    }
    if(strcmp(cmd,"/trazer",true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /Trazer [ID]");
            return 1;
        }
        new trago = strval(tmp);
        new tragoname[MAX_PLAYER_NAME];
        GetPlayerName(trago,tragoname,sizeof(tragoname));
        new Float:x,Float:y,Float:z,Float:angle;
        new interioradmin = GetPlayerInterior(playerid);
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid,angle);
        SetPlayerPos(trago,x,y,z);
        SetPlayerFacingAngle(trago,angle);
        SetPlayerInterior(trago,interioradmin);
        format(string,sizeof(string),"O Admin %s Trouxe %s Atй Ele.",pNome(playerid),tragoname);
        SendClientMessageToAll(0xF6F600AA,string);
        format(string,sizeof(string),"O Admin %s Trouxe Vocк Atй Ele.",pNome(playerid));
        SendClientMessage(trago,BRANCO,string);
        return 1;
    }
    if(strcmp(cmdtext,"/kick",true) == 0)
    //Aqui podes colocar um if(IsPlayerAdmin(playerid)) ou o que for
    {
        tmp = strtok(cmdtext, idx);
        new kickado = strval(tmp);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /Kick [ID][Motivo]");
            return 1;
        }
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[256];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        if(!strlen(result))
        {
            SendClientMessage(playerid,BRANCO,"Use /Kick [ID][Motivo]");
            return 1;
        }
        if(strcmp(pNome(kickado),"Pedro_Miranda",true) == 0)//anti-kick
        {
            new kick[MAX_PLAYER_NAME];
            GetPlayerName(kickado,kick,sizeof(kick));
            format(string,sizeof(string),"[OWNED]: %s Foi Kickado Por Tentar Kickar %s",pNome(playerid),kick);
            SendClientMessageToAll(COR_ADMCMD,string);
            Kick(playerid);
            return 1;
        }
        new Nome[MAX_PLAYER_NAME];
        GetPlayerName(kickado,Nome,sizeof(Nome));
        format(string,sizeof(string),"[ADM CMD]: %s Foi Kickado Pelo Admin %s, Motivo: %s",Nome,pNome(playerid),(result));
        SendClientMessageToAll(COR_ADMCMD,string);
        Kick(kickado);
        return 1;
    }

    if(strcmp(cmd,"/ip",true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /IP [ID/Nome]");
            return 1;
        }
        new ipado = strval(tmp);
        new ipadoname[MAX_PLAYER_NAME];
        GetPlayerName(ipado,ipadoname,sizeof(ipadoname));
        new ipadoip[256];
        GetPlayerIp(ipado,ipadoip,sizeof(ipadoip));
        format(string,sizeof(string),"IP de %s: %s",ipadoname,ipadoip);
        SendClientMessage(playerid,VERMELHO,string);
        return 1;
    }

    if(strcmp(cmd,"/cv",true) == 0)//criar veiculo
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"[ERRO]: Use /CV [ID do Veнculo][Cor 1][Cor 2]");
            return 1;
        }
        new modelo = strval(tmp);
        if(modelo < 400 || modelo > 611)
        {
            SendClientMessage(playerid,BRANCO,"[ERRO]: ID Mнnimo 400 - Mбximo 611!");
            return 1;
        }
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"[ERRO]: Use /CV [ID do Veнculo][Cor 1][Cor 2]");
            return 1;
        }
        new cor1 = strval(tmp);
        if(cor1 < 0 || cor1 > 250)
        {
            SendClientMessage(playerid,BRANCO,"[ERRO]: Cor Mнnima 0 - Mбxima 250");
            return 1;
        }
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"[ERRO]: Use /CV [ID do Veнculo][Cor 1][Cor 2]");
            return 1;
        }
        new cor2 = strval(tmp);
        if(cor2 < 0 || cor2 > 250)
        {
            SendClientMessage(playerid,BRANCO,"[ERRO]: Cor Mнnima 0 - Mбxima 250");
            return 1;
        }
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        format(string,sizeof(string),"Veнculo Criado com Sucesso!");
        SendClientMessage(playerid,BRANCO,string);
        AddStaticVehicleEx(modelo,x,y+2,z,0.0,cor1,cor2,-1);
        return 1;
    }

    if(strcmp(cmd,"/ban",true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        new banido = strval(tmp);
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[256];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        if(!strlen(result))
        {
            SendClientMessage(playerid,BRANCO,"Use /Ban [ID][Motivo]");
            return 1;
        }
        if(strcmp(pNome(banido),"Pedro_Miranda",true) == 0)// Anti Ban
        {
            new ban[MAX_PLAYER_NAME];
            GetPlayerName(banido,ban,sizeof(ban));
            format(string,sizeof(string),"[OWNED]: %s Foi Banido Por Tentar Banir %s",pNome(playerid),ban);
            SendClientMessageToAll(COR_ADMCMD,string);
            Ban(playerid);
            return 1;
        }
        new Nome[MAX_PLAYER_NAME];
        GetPlayerName(banido,Nome,sizeof(Nome));
        SendClientMessage(banido,VERMELHO,"Banido do Servidor!Para Revisгo de Ban Visite o Fуrum!");
        format(string,sizeof(string),"[ADM CMD]: %s Foi Banido Pelo Admin %s, Motivo: %s",Nome,pNome(playerid),result);
        SendClientMessageToAll(COR_ADMCMD,string);
        Ban(banido);
        return 1;
    }

    if(strcmp(cmd,"/explodir",true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /Explodir [ID]");
            return 1;
        }
        new explodido = strval(tmp);
        new explodidoname[MAX_PLAYER_NAME];
        GetPlayerName(explodido,explodidoname,sizeof(explodidoname));
        new Float:x,Float:y,Float:z;
        GetPlayerPos(explodido,x,y,z);
        format(string,sizeof(string),"[ADM CMD]: %s Foi Explodido Pelo Admin %s.",explodidoname,pNome(playerid));
        SendClientMessageToAll(COR_ADMCMD,string);
        CreateExplosion(x,y,z,7,100);
        return 1;
    }

    if(strcmp(cmd,"/congelar",true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /Congelar [ID]");
            return 1;
        }
        new congelado = strval(tmp);
        new name[MAX_PLAYER_NAME];
        GetPlayerName(congelado,name,sizeof(name));
        TogglePlayerControllable(congelado,0);
        format(string,sizeof(string),"[ADM CMD]: %s Foi Congelado Pelo Admin %s",name,pNome(playerid));
        SendClientMessageToAll(VERMELHO,string);
        return 1;
    }
    if(strcmp(cmd,"/descongelar",true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /Descongelar [ID]");
            return 1;
        }
        new descongelado = strval(tmp);
        new name[MAX_PLAYER_NAME];
        GetPlayerName(descongelado,name,sizeof(name));
        TogglePlayerControllable(descongelado,1);
        format(string,sizeof(string),"[ADM CMD]: %s Foi Descongelado Pelo Admin %s",name,pNome(playerid));
        SendClientMessageToAll(VERMELHO,string);
        return 1;
    }


    if(strcmp(cmd,"/tapa",true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,BRANCO,"Use /Tapa [ID]");
            return 1;
        }
        new tapado = strval(tmp);
        new tapadoname[MAX_PLAYER_NAME];
        GetPlayerName(tapado,tapadoname,sizeof(tapadoname));
        new Float:x,Float:y,Float:z;
        GetPlayerPos(tapado,x,y,z);
        SetPlayerPos(tapado,x,y,z+10);
        format(string,sizeof(string),"[ADM CMD]: %s Levou um Tapa de %s.",tapadoname,pNome(playerid));
        return 1;
    }
    return 0;
}
E Lembrem-se de colocar isto no fim do game mode:

pawn Код:
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;
}
Desculpem pelo exagero no limite das cйlulas "[256]", й uma coisa que ainda estou a estudar para nгo colocar lag no game mode.

Espero que sirva de ajuda para alguйm.
Reply
#2

pawn Код:
if(strcmp(cmdtext,"/kick",true) == 0)
    //Aqui podes colocar um if(IsPlayerAdmin(playerid)) ou o que for
    {
que isso man? voce so pode por os If's depois da chave

pawn Код:
if(strcmp(cmdtext,"/kick",true) == 0)
    {
//Aqui podes colocar um if(IsPlayerAdmin(playerid)) ou o que for
Reply
#3

em meu game mode coloco como mostrei e funciona perfeitamente.
Reply
#4

Hum... massa legal cara, vou usar alguns comandos ai... se funcionar claro!

Sabe o que seria melhor ainda?

Vocк ensinar a montar um sistema de Admin em Strtok.
Reply
#5

poem um prefix..
Reply
#6

Com toda sinceridade de mundo e sei que outros tambйm querem dizer porйm nгo diz mais esse tуpico estб uma merda sem utilidade alguma, mal feito!, inъtil isso!
Reply
#7

Nossa que merda.
Reply
#8

Isso й o que?
FilterScript - nao
Tutorial - nao
Codigo util - talvez
Reply
#9

Jason voce pode fazer assim

pawn Код:
stock pNome(playerid)
{
    new nome[MAX_PLAYER_NAME];
    GetPlayerName(playerid,nome,sizeof(nome));
    return nome;
}
enum Info
{
    pAdmin
}
new PlayerInfo[MAX_PLAYERS][Info];
public OnPlayerCommandText(playerid,cmdtext)
{
    new tmp[256];
    new idx;
    if(strcmp(cmd,"/daradmin",true) == 0)
    if(strcmp(pNome(playerid),"Jason_King",true) == 0)//pra voce poder usar sem ser admin
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,0xFFFFFFAA,"Use /DarAdmin [ID/Nome][AdminLevel]");
        new admin = strval(tmp);
        new adminame[MAX_PLAYER_NAME];
        GetPlayerName(admin,adminname,sizeof(adminame));
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,0xFFFFFFAA,"Use /DarAdmin [ID/Nome][AdminLevel]");
        new adminlevel = strval(tmp);
        if(adminlevel < 0 || adminlevel > 1342) return SendClientMessage(playerid,0xFFFFFFAA,"Admin Mбximo 1342, Mнnimo 0");
        PlayerInfo[admin][pAdmin] = adminlevel;
        new string[256];
        format(string,sizeof(string),"Vocк promoveu %s para o nнvel %d de Admin",adminname,adminlevel);
        SendClientMessage(playerid,0xFFFFFFAA,string);
        format(string,sizeof(string),"Vocк foi promovido a nнvel %d de Admin por %s",adminlevel,pNome(playerid))
        SendClientMessage(admin,0xFFFFFFAA,string);
        return 1;
    }
    return 0;
}
Lembre-se de no fim do GM colocar

pawn Код:
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;
}
Ai pra ter o salvamento do Admin voce adiciona a linha Admin no seu sistema de registro com salvamento de contas e poe pra salvar o PlayerInfo[playerid][pAdmin].

Espero que te sirva
Reply
#10

Quote:
Originally Posted by Pedro_Miranda
Посмотреть сообщение
Jason voce pode fazer assim

pawn Код:
stock pNome(playerid)
{
    new nome[MAX_PLAYER_NAME];
    GetPlayerName(playerid,nome,sizeof(nome));
    return nome;
}
enum Info
{
    pAdmin
}
new PlayerInfo[MAX_PLAYERS][Info];
public OnPlayerCommandText(playerid,cmdtext)
{
    new tmp[256];
    new idx;
    if(strcmp(cmd,"/daradmin",true) == 0)
    if(strcmp(pNome(playerid),"Jason_King",true) == 0)//pra voce poder usar sem ser admin
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,0xFFFFFFAA,"Use /DarAdmin [ID/Nome][AdminLevel]");
        new admin = strval(tmp);
        new adminame[MAX_PLAYER_NAME];
        GetPlayerName(admin,adminname,sizeof(adminame));
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,0xFFFFFFAA,"Use /DarAdmin [ID/Nome][AdminLevel]");
        new adminlevel = strval(tmp);
        if(adminlevel < 0 || adminlevel > 1342) return SendClientMessage(playerid,0xFFFFFFAA,"Admin Mбximo 1342, Mнnimo 0");
        PlayerInfo[admin][pAdmin] = adminlevel;
        new string[256];
        format(string,sizeof(string),"Vocк promoveu %s para o nнvel %d de Admin",adminname,adminlevel);
        SendClientMessage(playerid,0xFFFFFFAA,string);
        format(string,sizeof(string),"Vocк foi promovido a nнvel %d de Admin por %s",adminlevel,pNome(playerid))
        SendClientMessage(admin,0xFFFFFFAA,string);
        return 1;
    }
    return 0;
}
Lembre-se de no fim do GM colocar

pawn Код:
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;
}
Ai pra ter o salvamento do Admin voce adiciona a linha Admin no seu sistema de registro com salvamento de contas e poe pra salvar o PlayerInfo[playerid][pAdmin].

Espero que te sirva
Ok, depois eu testo.

Valeu!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)