AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Server time (https://forums.alliedmods.net/showthread.php?t=129527)

SpeeDeeR 06-13-2010 18:08

Server time
 
How can i get server time and check if its for example 24:00.Im asking because i don't know if its xx:xx:xx , xx:xx or something else.

Alucard^ 06-14-2010 12:45

Re: Server time
 
You mean this?

Is just an example ofcourse...

Code:
#include <amxmodx> #define PLUGIN "SchlumPF" #define VERSION "1.0" #define AUTHOR "Uptime" new g_bRoundStarted; new g_iMessageSayText; new g_pAlert; public plugin_init( ) {     register_plugin( PLUGIN, VERSION, AUTHOR );         g_pAlert = register_cvar( "uptime_alert", "1" );         register_clcmd( "say /up", "cmdUptime" );     register_clcmd( "say /uptime", "cmdUptime" );         g_iMessageSayText = get_user_msgid( "SayText" )         register_logevent( "eventRoundStart", 2, "1=Round_Start" );     register_message( get_user_msgid( "RoundTime" ), "msgRoundTime" ); } public cmdUptime( plr ) {     static message[192], gametime;     message[0] = 0x04;     formatex( message[1], 190, "[XJ] " );     message[6] = 0x01;         gametime = floatround( get_gametime( ), floatround_floor );         formatex( message[7], 186, "This server's uptime is %02i:%02i", gametime / 60, gametime % 60 );         message_begin( MSG_ONE_UNRELIABLE, g_iMessageSayText, { 0, 0, 0 }, plr );     write_byte( plr );     write_string( message );     message_end( );         return PLUGIN_HANDLED; } public eventRoundStart( ) {     g_bRoundStarted = true; } public msgRoundTime( ) {     if( g_bRoundStarted )     {         g_bRoundStarted = false;         set_task( 3600.0 , "tskTimerBug" );     } } public tskTimerBug( ) {     if( get_pcvar_num( g_pAlert ) )     {         static message[192];         message[0] = 0x04;         formatex( message[1], 190, "[XJ] " );         message[6] = 0x01;                 formatex( message[7], 186, "Uptime is now 60:00, better restart to avoid timerbugs!" );                 for( new i ; i <= get_maxplayers( ) ; i++ )         {             message_begin( MSG_ONE_UNRELIABLE, g_iMessageSayText, { 0, 0, 0 }, i);             write_byte( i );             write_string( message );             message_end( );         }     } }

SpeeDeeR 06-14-2010 13:52

Re: Server time
 
lol i didnt mean server uptime in any way.What I ment is server time, like when you write 'thetime' it prints server time aka 'the time is now xx:yy:zz'.So i want to get this and check if its 24:00:00.
PS: Think I saw this in a plugin but dont remember where and the search tool didnt help so ...

Alucard^ 06-14-2010 14:05

Re: Server time
 
Oh sry, my english is not rly good... so you mean the REAL TIME...

Just see timeleft.sma

Code:
public sayTheTime(id) {     /*if (get_cvar_num("amx_time_voice"))     {         new mhours[6], mmins[6], whours[32], wmins[32], wpm[6]                 get_time("%H", mhours, 5)         get_time("%M", mmins, 5)                 new mins = str_to_num(mmins)         new hrs = str_to_num(mhours)                 if (mins)             num_to_word(mins, wmins, 31)         else             wmins[0] = 0                 if (hrs < 12)             wpm = "am "         else         {             if (hrs > 12) hrs -= 12             wpm = "pm "         }         if (hrs)             num_to_word(hrs, whours, 31)         else             whours = "twelve "                 client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)     }*/     // here is the important part         new ctime[64]         get_time("%m/%d/%Y - %H:%M:%S", ctime, 63)     client_print(0, print_chat, "%L:   %s", LANG_PLAYER, "THE_TIME", ctime)         return PLUGIN_CONTINUE }

SpeeDeeR 06-14-2010 14:52

Re: Server time
 
ok and how to check if its a specific hour ?

YamiKaitou 06-14-2010 14:53

Re: Server time
 
Get the hour only and them compare it.

Alucard^ 06-14-2010 15:33

Re: Server time
 
if(equal(.....) )

or str_to_num( ) and then compare the var with 24.


All times are GMT -4. The time now is 14:43.

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