[Pedido] So entrar no Servidor Se tiver [CP] , [CVR] Ou [PMBA].
#1

Bom , boa noite galera queria saber como faz msm pra so autorizar o player a entrar no servidor se ele tiver com:
PMBA] Ou [PMBA]
CP] Ou [CP]
[CVR] Ou CVR] no nick ... se tiver tipo Seck.LBDS[GM] ele ser kickado Motivo: No seu nick nao foi encontrado [CP]/[CVR] !
Reply
#2

Strfind
Reply
#3

Eu acho que й mais ou menos isso.

pawn Код:
new nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, nome, sizeof(nome));
if(strfind(nome,"[CP]",true) != -1)
{
        SendClientMessage(playerid, -1, "Seu nome tem [CP]");
}
Reply
#4

da uma pesquisada na wiki, na internet, qualquer lugar, antes de vir aqui abrir um tуpico assim, nгo й por mal nгo.
Reply
#5

Axo que nosso abiguinho jб montou um gm inteiro com os cуdigos do forum '-'
Reply
#6

Quote:
Originally Posted by xCR7
Посмотреть сообщение
Eu acho que й mais ou menos isso.

pawn Код:
new nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, nome, sizeof(nome));
if(strfind(nome,"[CP]",true) != -1)
{
    SendClientMessage(playerid, -1, "Seu nome tem [CP]");
}
Nesse caso vai apenas retornar a mensagem ..

pawn Код:
new nome[MAX_PLAYER_NAME];

GetPlayerName(playerid, nome, sizeof(nome));

// public OnPlayerConnect

if(strfind(nome,"CP]",true) != -1)
{
    SendClientMessage(playerid, -1, "Seu nome tem [CP]");
}
else
{
    SendClientMessage(playerid, -1, "Seu nome nгo tem [CP] e por isso foi kickado !");
    Kick(playerid);
    return 1;
}

Muito tempo fora do samp mas a lуgica e Strfind
Reply
#7

pawn Код:
if(strfind(nome,"[CP]",true) != -1 || strfind(nome,"[CVR]",true) != -1 || strfind(nome,"[PMBA]",true) != -1)
Reply
#8

pawn Код:
stock NomePermitido(playerid) {
    new nome[MAX_PLAYER_NAME];
    GetPlayerName(playerid, nome, MAX_PLAYER_NAME);
   
    // Tem PMBA] Ou [PMBA]
    if(strfind(nome,"[PMBA]",true) != -1 || strfind(nome,"PMBA]",true) != -1)
        return 1;
    // Tem CP] ou [CP]
    if(strfind(nome,"[CP]", true) != -1 || strfind(nome, "CP]", true) != 1)
        return 1;
    // Tem [CVR] Ou CVR]
    if(strfind(nome, "[CVR]", true) != 1 || strfind(nome, "CVR]", true) != 1)
        return 1;
    return 0;
}

public OnPlayerConnect(playerid) {
    if(!NomePermitido(playerid)) {
        Kick(playerid);
        return 1;
    }    
    // o nome e permitido
    return 1;
}
Deve ficar alguma coisa assim do gйnero, jб nгo programo PAWN а perto de 2 anos, portanto й capaz que tenha erros e.e
Reply
#9

Quote:
Originally Posted by Kikito
Посмотреть сообщение
pawn Код:
stock NomePermitido(playerid) {
    new nome[MAX_PLAYER_NAME];
    GetPlayerName(playerid, nome, MAX_PLAYER_NAME);
   
    // Tem PMBA] Ou [PMBA]
    if(strfind(nome,"[PMBA]",true) != -1 || strfind(nome,"PMBA]",true) != -1)
        return 1;
    // Tem CP] ou [CP]
    if(strfind(nome,"[CP]", true) != -1 || strfind(nome, "CP]", true) != 1)
        return 1;
    // Tem [CVR] Ou CVR]
    if(strfind(nome, "[CVR]", true) != 1 || strfind(nome, "CVR]", true) != 1)
        return 1;
    return 0;
}

public OnPlayerConnect(playerid) {
    if(!NomePermitido(playerid)) {
        Kick(playerid);
        return 1;
    }    
    // o nome e permitido
    return 1;
}
Deve ficar alguma coisa assim do gйnero, jб nгo programo PAWN а perto de 2 anos, portanto й capaz que tenha erros e.e
Costumo usar array para isso й um pouco mais rapido em alguns testes que fiz quando usava grande quantidade de informaзгo.

Ficaria mais ou menos assim:

pawn Код:
stock NomePermitido(playerid)
{
    new nome[MAX_PLAYER_NAME];
    GetPlayerName(playerid, nome, sizeof(nome));
   
    new Tags[] =
    {
        "[PMBA]", "[CP]", "[CVR]"
    };
   
    for(new i = 0; i < sizeof(Tags); i++)
    {
        if(strfind(nome, Tags[i], false) != 1)
            return 1;
    }
    return 0;
}

public OnPlayerConnect(playerid)
{
    if(!NomePermitido(playerid))
    {
        Kick(playerid);
        return 1;
    }    
    // o nome e permitido
    return 1;
}
nao testei mas creio que funcione.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)