Raised This Month: $ Target: $400
 0% 

Help with time


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PyKw
Junior Member
Join Date: Jan 2012
Old 12-29-2013 , 17:22   Help with time
Reply With Quote #1

Hi, so i want a plugin that when its 20:00 a message is send to all connected players.
I tried this but not working...
Code:
#include <amxmodx>

public plugin_init()
{
	register_plugin("On Time", "1.0", "PyKw")
}

public check_time()
{
	new h, m, s;
	time(h, m, s)
	if(h == 20)
		client_print(0, print_chat, "Its 20:00")
}
Please help!

Last edited by PyKw; 12-29-2013 at 17:23.
PyKw is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 12-29-2013 , 17:34   Re: Help with time
Reply With Quote #2

Try to let the time get checked every 1 second.
Torge is offline
PyKw
Junior Member
Join Date: Jan 2012
Old 12-29-2013 , 17:45   Re: Help with time
Reply With Quote #3

Like this ?

Code:
#include <amxmodx>

public plugin_init()
{
	register_plugin("On Time", "1.0", "PyKw")
        set_task(0.1, "check_time", _, _, _, "b")
}

public check_time()
{
	new h, m, s;
	time(h, m, s)
	if(h == 20)
		client_print(0, print_chat, "Its 20:00")
}

Last edited by PyKw; 12-29-2013 at 17:45.
PyKw is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 12-29-2013 , 17:52   Re: Help with time
Reply With Quote #4

Yeah, did u test it and it worked?
Torge is offline
PyKw
Junior Member
Join Date: Jan 2012
Old 12-29-2013 , 18:13   Re: Help with time
Reply With Quote #5

It is working, but the task is repeating, and i am getting spammed with:
Code:
Its 20:00
Its 20:00
Its 20:00
Its 20:00
Its 20:00
Its 20:00
Its 20:00
Its 20:00
Its 20:00
PyKw is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-29-2013 , 18:39   Re: Help with time
Reply With Quote #6

Quote:
Originally Posted by PyKw View Post
It is working, but the task is repeating, and i am getting spammed with:
Code:
Its 20:00
Its 20:00
Its 20:00
Its 20:00
Its 20:00
Its 20:00
Its 20:00
Its 20:00
Its 20:00
You are executing the function 10 times per second. Also, if you only check "h" it will print every time the function executes during that whole hour.

I think one option would be to execute the function every minute and check both h == 20 and m == 0.
__________________
fysiks is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 12-29-2013 , 18:17   Re: Help with time
Reply With Quote #7

Stop the task and try to re-start it again at another time.
Torge is offline
PyKw
Junior Member
Join Date: Jan 2012
Old 12-29-2013 , 18:20   Re: Help with time
Reply With Quote #8

How i do that?
PyKw is offline
Old 12-29-2013, 18:26
Torge
This message has been deleted by Torge. Reason: nvm
PyKw
Junior Member
Join Date: Jan 2012
Old 12-29-2013 , 18:51   Re: Help with time
Reply With Quote #10

Thanks, i solved. You can close this topic.
PyKw is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode