How can I open a gate every hour?
#1

Hey,

How can I make a object move when it's 14:00 and 15:00 and 16:00
How can I make it open every hour?

Thanks
Reply
#2

Quote:
Originally Posted by dirkblok
Hey,

How can I make a object move when it's 14:00 and 15:00 and 16:00
How can I make it open every hour?

Thanks
using a timer
https://sampwiki.blast.hk/wiki/SetTimer
Reply
#3

I know about the settimer, but that timer works at the moment it's set, so if you start your gamemode at 15:15 the gate will open at 16:15 and 17:15, I want that it just works at 15:00 16:00 and 17:00 no matter when I start my gamemode?

Do you get me ?

Thanks
Reply
#4

You could have a timer to check the time (https://sampwiki.blast.hk/wiki/Gettime) and if the minutes value is 0 then open the gate.
Reply
#5

Set the time to 00:00 when setting the timer
Reply
#6

pawn Код:
forward GateOpen();
pawn Код:
public OnGameModeInit()
{
     SetWorldTime(0);
     SetTimer("GateOpen",3600000,1); // 1000 miliseconds = 1000 * 60 (seconds) = 60000 * 60 (minutes) = 3600000 miliseconds
     return 1;
}
pawn Код:
public GateOpen()
{
     MoveObject(objectid,x,y,z,speed);
     // There you can set timer for "close gate"
     return 1;
}
Reply
#7

Quote:
Originally Posted by Luka™
pawn Код:
forward GateOpen();
pawn Код:
public OnGameModeInit()
{
     SetWorldTime(0);
     SetTimer("GateOpen",3600000,1); // 1000 miliseconds = 1000 * 60 (seconds) = 60000 * 60 (minutes) = 3600000 miliseconds
     return 1;
}
pawn Код:
public GateOpen()
{
     MoveObject(objectid,x,y,z,speed);
     // There you can set timer for "close gate"
     return 1;
}
This will be the easiest bet .. Use it
Reply
#8

pawn Код:
new hour,minute,second;
gettime(hour,minute,second);
if(minute == 0 && second == 0)
{
//move gate bla bla bla
}
will open the gate every real world hour
Reply
#9

Quote:
Originally Posted by IntrozeN
pawn Код:
new hour,minute,second;
gettime(hour,minute,second);
if(minute == 0 && second == 0)
{
//move gate bla bla bla
}
will open the gate every real world hour
Yeah, and u must put it under timer public, that's no sense.
Reply
#10

Quote:
Originally Posted by Luka™
Quote:
Originally Posted by IntrozeN
pawn Код:
new hour,minute,second;
gettime(hour,minute,second);
if(minute == 0 && second == 0)
{
//move gate bla bla bla
}
will open the gate every real world hour
Yeah, and u must put it under timer public, that's no sense.
I would prefer a timer on 1 sec or something to prevent lag
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)