Gettime
#1

Why not go?It should go only between 20 and 22 hours. Excuse my bad english.

PHP код:
   new hour,minute,second;
       
gettime(hour,minute,second);
                    
       if(
hour 20 && hour 22)
       {
       return 
1;
           } 
Reply
#2

You are now checking if the hour is below 20 and above 22 at the same time.
Reply
#3

Well I want to go just that command between that range (20-22) (to go at 20, 21, 22 not in other hours) Srry my english
Reply
#4

In that case you would have to use if (hour >=20 && hour <=22)
Reply
#5

FIX

if(hour != 20 || hour != 21 || hour != 22)
{
return 1;
}
Reply
#6

I assumed you wanted to perform the actions within the check I provided.

Otherwise you only had to change && to || from your first code.
Reply
#7

You could make a switch:
pawn Код:
select hour
{
    case 20, 21, 22:
    {
        // Your code here
    }
}
If you plan to change the times later on, or add some extra hour-values, you can easily add them to that list.
Otherwise you need to extends and possibly rewrite the entire if-statement.

Perhaps you want to run that code at hour 6 and 15 later on as well, you could easily do:
pawn Код:
select hour
{
    case 6, 15, 20, 21, 22:
    {
        // Your code here
    }
}
Using "if" would make it pretty long and more complex:
pawn Код:
if (((hour >=20 && hour <=22))  || (hour == 6) || (hour == 15))
Reply
#8

PHP код:
if(hour == 20 || hour == 21){
 
//20:00:00 - 21:59:59

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)