[Ajuda] Usar chat somente se estiver logado...
#5

Funciona perfeitamente, apenas coloque no lugar certo.

Vou demonstrar:

--Supondo que o jogador logue ao dar spawn, como o colega acima fez:
Код:
new bool:Logado[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    if(Logado[playerid] == false) Logado[playerid] = true;

    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(Logado[playerid] == true) Logado[playerid] = false;
    
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(Logado[playerid] == false) 
    {
        SendClientMessage(playerid, -1, "[x] Vocк tem que estar logado para usar o chat!");
        return 0;
    }

    if(text[0] == '.')
    {
             format(pFile, sizeof(pFile), "clas/%s.ini", PlayerName(playerid));
             if(dini_Exists(pFile))
             {
             if(strcmp(dini_Get(pFile, "cla"), "Nenhum", false))
            {
                new
                    tmp[128]
                ;
                strmid(tmp, text, 1, strlen(text));
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COR_BRANCO, "[ > ] Uso correto: . [texto]");
                    return 0;
                }
                else
                {
                    for(new c = 0; c < MAX_PLAYERS; c++)
                    {
                        if(IsPlayerConnected©)
                        {
                            format(gFile, sizeof(gFile), "clas/%s.ini", PlayerName©);
                            if(strcmp(dini_Get(gFile, "cla"), "Nenhum", false))
                            {
                                if(strcmp(dini_Get(gFile, "cla"), dini_Get(pFile, "cla"), true) == 0)
                                {
                                    format(gstring, sizeof(gstring), "( C/C ) %s: %s", PlayerName(playerid), tmp);
                                    SendClientMessage(c, 0x00FF00AA, gstring);
                                }
                              }
                        }
                    }
                    return 0;
                }
               }
        }
    }
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)