Raised This Month: $51 Target: $400
 12% 

How do I get current year, month, day + time?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lt Llama
Senior Member
Join Date: Aug 2004
Old 02-03-2006 , 14:51   How do I get current year, month, day + time?
Reply With Quote #1

Can someone show me how to get server
time
year
month
day

into cvars?

Thx
Lt Llama is offline
DaSoul
Senior Member
Join Date: Jan 2006
Old 02-03-2006 , 14:57  
Reply With Quote #2

date ( [ &year, &month, &day ] )

time ( [ &hour, &minute, &second ] )
DaSoul is offline
Des12
Senior Member
Join Date: Jan 2005
Old 02-03-2006 , 15:07  
Reply With Quote #3

Code:
new currtime = get_systime()
__________________
-Dest Romano

www.JustRP.com
A TSRP Server

Quote:
Originally Posted by Brad
Don't you go be bringing reality into this.
Des12 is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 02-03-2006 , 15:13  
Reply With Quote #4

Quote:
Originally Posted by DaSoul
date ( [ &year, &month, &day ] )
time ( [ &hour, &minute, &second ] )
Thx and +karma for trying to help.

Im just to stupid to understand what this means
Quote:
Each parameter, passed by reference, will have the corresponding piece of time stored inside.
There is no plugin using either "time" or "date" as far as I can see in the default package, so I cant look there.

Can someone show me an example?

p.s. YESS! I managed to get the map name out of a cvar when using "date"
Lt Llama is offline
Des12
Senior Member
Join Date: Jan 2005
Old 02-03-2006 , 15:43  
Reply With Quote #5

Passing by reference is basically sending a variable to another function, and if that function changes it, the variable is also changed in the origional function....for example

Code:
public mainFunc() {      new var = 0      client_print(0,print_chat,"[AMXX] Var is %i",var) //should be 0      changeIt(var)      client_print(0,print_chat,"[AMXX] Changed Var is %i",var) //should be 5      return PLUGIN_HANDLED } public changeIt( &var) {      var = var + 5 }

The '&' next to var means that it is passed by reference. If you did not have the '&', it would NOT change in the original function.
__________________
-Dest Romano

www.JustRP.com
A TSRP Server

Quote:
Originally Posted by Brad
Don't you go be bringing reality into this.
Des12 is offline
DaSoul
Senior Member
Join Date: Jan 2006
Old 02-03-2006 , 16:33  
Reply With Quote #6

Quote:
Originally Posted by Lt Llama
Quote:
Originally Posted by DaSoul
date ( [ &year, &month, &day ] )
time ( [ &hour, &minute, &second ] )
Thx and +karma for trying to help.

Im just to stupid to understand what this means
Quote:
Each parameter, passed by reference, will have the corresponding piece of time stored inside.
There is no plugin using either "time" or "date" as far as I can see in the default package, so I cant look there.

Can someone show me an example?

p.s. YESS! I managed to get the map name out of a cvar when using "date"
Bascially what it means is you pass in the variables you want to contain the date/time vaules after you call the function. When it is done... those values have the information you need.
DaSoul is offline
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 02-03-2006 , 18:39  
Reply With Quote #7

Exectly, this is the equivalent without reference.

Code:
public mainFunc() {      new var = 0      client_print(0,print_chat,"[AMXX] Var is %i",var) //should be 0      var = changeIt(var)      client_print(0,print_chat,"[AMXX] Changed Var is %i",var) //should be 5      return PLUGIN_HANDLED } public changeIt(var) {      var = var + 5      return var; }

It is much easier if you pass by reference, because you can pass more than one variable ;)
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 02-04-2006 , 03:24  
Reply With Quote #8

Thx all!

This was what I wanted:

Code:
new currentTime[9] get_time("%H:%M:%S",currentTime,8) new currentDate[11] get_time("%Y/%m/%d",currentDate,10) client_print(0,3,"Current time is: %s. Current date: %s",currentTime,currentDate)

I wasnt shure about the %H, %M, %S, %Y, %m and %d.
Lt Llama 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 22:37.


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