Problems Making a 'time loop"
#1

Hey guys. I am trying to make constant night time on my server.
I know it's possible by disabling the player clock and setting an hour, but I need that clock running, because the weather changes more smoothly while it's activated. Otherwise I get an instant weather change, and that's not very nice. Here's what I've tried:

I've set a timer:
Код:
forward timechange();
public OnFilterScriptInit()
{
	SetTimer("timechange", 240000, true); //4 minutes in real life, so 4 hours gametime
}
And then I made this function here using foreach from ******:
Код:
public timechange()
{
    foreach (new i : Player)
	{
    	SetPlayerTime(i,0,0);
	}
}
So after 4 minutes in game, the time should have changed back to 00:00 and start over, but it didn't. Can someone explain why?
I used the normal loop already with the same result.
Reply
#2

The timers aren't accurate, use the fixes plugin or use y_timers.
Reply
#3

accurate or not, the timer should work somehow. This thing didn't work at all...
Reply
#4

Thx for the reply ******, I was just trying your timer library. Here's what I did:
Код:
#define FILTERSCRIPT

#include <a_samp>
#include <foreach>
#include <YSI\y_timers>
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	task RepeatingTimer[60000]()
	{
    	foreach (new i : Player)
		{
		TogglePlayerClock(i, 1);
 		SetPlayerTime(i,0,0);
		}
	return 1;
	}
}

public OnFilterScriptExit()
{
    foreach (new i : Player)
	{
		TogglePlayerClock(i, 0);
	}
	return 1;
}

#else

main()

#endif
When I compile, I get this:
Код:
C:\Users\HeLiOn\Desktop\night24.pwn(12) : error 017: undefined symbol "RepeatingTimer@yT_"
C:\Users\HeLiOn\Desktop\night24.pwn(12) : error 029: invalid expression, assumed zero
C:\Users\HeLiOn\Desktop\night24.pwn(12) : error 017: undefined symbol "RepeatingTimer@yT_"
C:\Users\HeLiOn\Desktop\night24.pwn(12) : fatal error 107: too many error messages on one line
What am I doing wrong here?
Reply
#5

Then how do I make the timer start counting at the script launch?
Reply
#6

Bump...
Reply
#7

Put it under OnGameModeInIt.
Reply
#8

This is what ****** stated above.
Quote:
Originally Posted by ******
Посмотреть сообщение
"task" is a function type like "public", so it goes outside other functions.
Reply
#9

I thought you're using a normal timer, anyways try using a normal timer if you still don't understand y timers.
Reply
#10

it didn't work with a normal timer.
I figured out most of the y_timer. I just need to know this last thing...
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)