[Ajuda] Logica errada
#1

Em si ele funciona corretamente , porem ele nгo breca 'break'

PHP код:
stock GetarDias(day)
{
      new 
dia,mes,ano;
      new 
resultado 0;
      
      
getdate(anomesdia);
      for(new 
ii<=1i++)
      {
           if(
day == dia){break;}
           if(
dia == 1)
           {
               
resultado --;
               
dia 30;
               
printf("mm 2  ====   %d"resultado);
               
               if(
dia == day){break;}
           }
           else 
           {
               
dia --;
               
resultado ++;
               
printf("mm 3 ==== %d"resultado);
               
               if(
dia == day){break;}
           }
      }
      return 
resultado;

Bom no serve log sai assim
PHP код:
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53mm 3 ==== 1
[11:03:53mm 3 ==== 2
[11:03:53Carregamento do server... 
Esta correto o 2




Agradeзo desde ja
Reply
#2

@edit: mals passei info errada, @tofumado.

@OnTopic: Vocк procura fazer esta funзгo para que tipo de sistema, qual й a funзгo do sistema?
Creio que й para Login/Registro
Reply
#3

Quote:
Originally Posted by Schocc
Посмотреть сообщение
@edit: mals passei info errada, @tofumado.

@OnTopic: Vocк procura fazer esta funзгo para que tipo de sistema, qual й a funзгo do sistema?
Creio que й para Login/Registro


verificar quanto dias o jogador esta Ausente .
Reply
#4

tira as chaves do break...
Reply
#5

pawn Код:
stock GetarDias(day)
{
    new dia,mes,ano, resultado = 0;
    getdate(ano, mes, dia);

    for(new i; i<=1; i++)
    {
        if(day == dia)
        {
            print("parou 1");
            break;
        }
        switch(day)
        {
            case 1:
            {
                if(dia == day)
                    break;
                resultado --;
                dia = 30;
                printf("mm 2  ====   %d", resultado);
            }
            default:
            {
                if(dia == day)
                   break;
                dia --;
                resultado ++;
                printf("mm 3 ==== %d", resultado);
           }
        }
    }
    return resultado;
}
aqui parou tenta ai.
Reply
#6

Tambйm quero fazer um sistema como este, qual й a conta que preciso fazer??
Estou querendo testar somente dias por enquanto.

pawn Код:
// Quando Conectar

GetTimeAway(playerid, year, month, day) {
    new
        strd[128],
        destfile[128];

    format( destfile, sizeof( destfile ),"%s.ini", P_DATA[playerid][pName] );
   
    new tempDay = DOF2::GetInt( destfile, "Dia");

    if(day > tempDay ) {
        format(strd, 128, "Hoje й dia: -%d e Vocк esta ausente por: %d dias!", day, day-tempDay ),
        SendClientMessage(playerid,-1,strd);
    }

    SendClientMessage(playerid,-1,"---------------------------------------------");

    return 1;
}

// Quando desconectar
SetTimeAway(playerid, year, month, day) {
    new
        destfile[128];
       
    P_DATA[playerid][YEAR_T]    = year;
    P_DATA[playerid][MONTH_T]   = month;
    P_DATA[playerid][DAY_T]     = day;
       
       
    format( destfile, sizeof( destfile ),"%s.ini", P_DATA[playerid][pName] ),
    DOF2::SetInt( destfile, "Ano",  P_DATA[playerid][YEAR_T] ),
    DOF2::SetInt( destfile, "Mes",  P_DATA[playerid][MONTH_T] ),
    DOF2::SetInt( destfile, "Dia",  P_DATA[playerid][DAY_T] ),
   
    DOF2::SaveFile();
   
    return 1;
}
Reply
#7

Quote:
Originally Posted by n0minal
Посмотреть сообщение
tira as chaves do break...
Ok ...

Quote:
Originally Posted by Schocc
Посмотреть сообщение
Tambйm quero fazer um sistema como este, qual й a conta que preciso fazer??
Estou querendo testar somente dias por enquanto.

pawn Код:
// Quando Conectar

GetTimeAway(playerid, year, month, day) {
    new
        strd[128],
        destfile[128];

    format( destfile, sizeof( destfile ),"%s.ini", P_DATA[playerid][pName] );
   
    new tempDay = DOF2::GetInt( destfile, "Dia");

    if(day > tempDay ) {
        format(strd, 128, "Hoje й dia: %d e Vocк esta ausente por:%d dias!", day, tempDay-day ),
        SendClientMessage(playerid,-1,strd);
    }

    SendClientMessage(playerid,-1,"---------------------------------------------");

    return 1;
}

// Quando desconectar
SetTimeAway(playerid, year, month, day) {
    new
        destfile[128];
       
    P_DATA[playerid][YEAR_T]    = year;
    P_DATA[playerid][MONTH_T]   = month;
    P_DATA[playerid][DAY_T]     = day;
       
       
    format( destfile, sizeof( destfile ),"%s.ini", P_DATA[playerid][pName] ),
    DOF2::SetInt( destfile, "Ano",  P_DATA[playerid][YEAR_T] ),
    DOF2::SetInt( destfile, "Mes",  P_DATA[playerid][MONTH_T] ),
    DOF2::SetInt( destfile, "Dia",  P_DATA[playerid][DAY_T] ),
   
    DOF2::SaveFile();
   
    return 1;
}
Isso ai nгo vai dar certo . 31 - 1 = 30

Quote:
Originally Posted by PT
Посмотреть сообщение
pawn Код:
stock GetarDias(day)
{
    new dia,mes,ano, resultado = 0;
    getdate(ano, mes, dia);

    for(new i; i<=1; i++)
    {
        if(day == dia)
        {
            print("parou 1");
            break;
        }
        switch(day)
        {
            case 1:
            {
                if(dia == day)
                    break;
                resultado --;
                dia = 30;
                printf("mm 2  ====   %d", resultado);
            }
            default:
            {
                if(dia == day)
                   break;
                dia --;
                resultado ++;
                printf("mm 3 ==== %d", resultado);
           }
        }
    }
    return resultado;
}
aqui parou tenta ai.
Default nuss






#EDIT

Ja descobri pq o flood
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)