[Ajuda] CMD Banir
#1

Olб, eu criei esse CMD de banir e salavr um uma pasta e gostria q vocкs me ajudassem, tipo ban uma peessoa e salva certo so q quando bani outra apaga a que ja foi banida e salva o ban novo, ou seja, quem estava banido nгo esta mais.

Gostaria tbn que quando o player logasse pegasse nessa pasta bans.ini e verificasse se ele estava banido.

pawn Код:
CMD:banir(playerid, params[])
{
    new file[40], aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], pIp[25], Motivo[25], str[128], str1[128], id;
    GetPlayerName(playerid,aName, MAX_PLAYER_NAME);
    GetPlayerName(id,pName, MAX_PLAYER_NAME);
    GetPlayerIp(playerid, pIp, sizeof(pIp));
    format(file, 40, PASTA_BANS);
    if(IsPlayerAdmin(playerid) || Admin[playerid] == 1 || Admin[playerid] == 2){
        if(sscanf(params,"us",id,Motivo)) return SendClientMessage(playerid, Vermelho, "| ERRO |{ffffff} Digite: /Banir [id] [motivo]");
        if(DOF2_FileExists(file)){
        format(str1, sizeof(str1), "Nick: %s || IP: %s || Motivo %s || Administrador: %s", pName, pIp, Motivo, aName);
        DOF2_SetString(file, "->", str1);
        DOF2_SaveFile();
        }
        else
        {
        DOF2_CreateFile(file, "Bans.ini");
        format(str1, sizeof(str1), "Nick: %s || IP: %s || Motivo %s || Administrador: %s", pName, pIp, Motivo, aName);
        DOF2_SetString(file, "->", str1);
        DOF2_SaveFile();
        }
        format(str, sizeof(str), "[Admin] O(A) administrador(a) %s baniu %s (Motivo: %s)",aName,pName,Motivo);
        SendClientMessageToAll(azuladm, str);
        print(str);
    }
    else
    {
        SendClientMessage(playerid, Laranja, "| ERRO | Vocк nгo й administrador(a)");
    }

    return 1;
}
Reply
#2

Usando essa funзгo em OnPlayerConnect: DOF2_FileExists(file[])
Nгo sei muito de Dof2 mas acho que funcionarб.
Retornando true = Existe um arquivo com o nick banido.
Retornando false = Nгo existe e nгo estб banido
Reply
#3

Alguem me ajuda please...
Reply
#4

Acho muito melhor vocк criar uma pasta chamada bans e dentro dela salvar um arquivo .ini com o nome do jogador.

pawn Код:
CMD:banir( playerid, params[])
{
    new
        file[ 40 ],
        aName[ MAX_PLAYER_NAME ],
        pName[ MAX_PLAYER_NAME ],
        pIp[ 25 ],
        Motivo[ 25 ],
        str[ 128 ],
        id
    ;

    GetPlayerName( playerid, aName, MAX_PLAYER_NAME );

    if( IsPlayerAdmin( playerid ) || Admin[ playerid ] == 1 || Admin[ playerid ] == 2 )
    {
        if( sscanf( params,"us", id, Motivo )) return SendClientMessage( playerid, Vermelho, "| ERRO |{ffffff} Digite: /Banir [id] [motivo]" );
        GetPlayerName( id, pName, MAX_PLAYER_NAME );
        GetPlayerIp( id, pIp, sizeof( pIp ));
        format( file, 40, "bans/%s.ini", pName );
        if( DOF2_FileExists( file )) return SendClientMessage( playerid, Vermelho, "| ERRO |{ffffff} Este jogador jб estб banido." );
        else
        {
            DOF2_CreateFile( file );
            format( str, sizeof( str ), "%s", pIp );
            DOF2_SetString( file, "IP", str );
            format( str, sizeof( str ), "%s", Motivo );
            DOF2_SetString( file, "Motivo", str );
            format( str, sizeof( str ), "%s", aName );
            DOF2_SetString( file, "Admin", str );
            DOF2_SaveFile();
        }
        format( str, sizeof( str ), "[Admin] O(A) administrador(a) %s baniu %s (Motivo: %s)", aName, pName, Motivo );
        SendClientMessageToAll( azuladm, str );
        print( str );
    }
    else
    {
        SendClientMessage( playerid, Laranja, "| ERRO | Vocк nгo й administrador(a)" );
    }
    return 1;
}
Reply
#5

Eu fiz isso nгo gostei mtt, pois a cada ban criar um arquivo
Reply
#6

Ao meu ver, й melhor assim Arthur, como o Rodney citou. Mas cabe a cada um rsrs. Se eu fosse vocк faria uma pasta chamada Bans com o nome dos players, facilitarб sua vida no futuro
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)