How can I open a gate every hour? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How can I open a gate every hour? (
/showthread.php?tid=106093)
How can I open a gate every hour? -
dirkblok - 01.11.2009
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
Re: How can I open a gate every hour? -
Virtual1ty - 01.11.2009
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
Re: How can I open a gate every hour? -
dirkblok - 01.11.2009
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
Re: How can I open a gate every hour? -
radhakr - 01.11.2009
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.
Re: How can I open a gate every hour? -
dice7 - 01.11.2009
Set the time to 00:00 when setting the timer
Re: How can I open a gate every hour? -
Luka P. - 01.11.2009
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;
}
Re: How can I open a gate every hour? -
Peter_Corneile - 01.11.2009
Quote:
Originally Posted by Luka™
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
Re: How can I open a gate every hour? -
introzen - 01.11.2009
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
Re: How can I open a gate every hour? -
Luka P. - 01.11.2009
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.
Re: How can I open a gate every hour? -
introzen - 01.11.2009
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