Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   getTimeStamp() (https://forums.graalonline.com/forums/showthread.php?t=82675)

Tigairius 11-06-2008 07:08 PM

getTimeStamp()
 
I think it would be nice if there were some way to get a timestamp. Instead of calculating it all out with timevar2, it would be handy to return the same timestamp as it would appear on logs. This would enable scripters to create logs in different directories as well as numerous other uses.

Maybe I'm wrong and there's already a function like this?

napo_p2p 11-06-2008 08:33 PM

You could script some kind of class for getting a timestamp. However, I agree that it would be handy to have a function like this built-in. Maybe even something similar to PHP's date() function.

xXziroXx 11-06-2008 10:32 PM

I use HR's time system for this, works like a charm. :)

LoneAngelIbesu 11-06-2008 11:20 PM

If somebody were to script this, couldn't Skyld just add it in with the shared functions pack? shared.date(PHP date() format), would be optimal, but something like shared.timestamp() with a single format (MM/DD/YYYY HH:MM:SS or something) would work just fine.

cbk1994 11-06-2008 11:52 PM

Quote:

Originally Posted by napo_p2p (Post 1439805)
Maybe even something similar to PHP's date() function.

I think this would work well.

Tigairius 11-07-2008 12:02 AM

Quote:

Originally Posted by LoneAngelIbesu (Post 1439856)
If somebody were to script this, couldn't Skyld just add it in with the shared functions pack? shared.date(PHP date() format), would be optimal, but something like shared.timestamp() with a single format (MM/DD/YYYY HH:MM:SS or something) would work just fine.

Yes, but the most useful use for this function would be serverside.

LoneAngelIbesu 11-07-2008 12:50 AM

Quote:

Originally Posted by Tigairius (Post 1439884)
Yes, but the most useful use for this function would be serverside.

I wasn't aware that shared functions were limited to clientside use...

EDIT: Could you explain the reason why a shared functions pack can't be serverside?

Chompy 11-07-2008 02:15 AM

Quote:

Originally Posted by LoneAngelIbesu (Post 1439898)
I wasn't aware that shared functions were limited to clientside use...

EDIT: Could you explain the reason why a shared functions pack can't be serverside?

It can, it's like a class joined to the player. All you need is some functions serverside, and I guess Skyld have to do that.

Tigairius 11-07-2008 02:22 AM

Quote:

Originally Posted by Chompy (Post 1439925)
It can, it's like a class joined to the player. All you need is some functions serverside, and I guess Skyld have to do that.

The problem is player would have to be in scope.

LoneAngelIbesu 11-07-2008 03:00 AM

Quote:

Originally Posted by Tigairius (Post 1439927)
The problem is player would have to be in scope.

What do you mean by that? On Valikorlia, we add classes to players on the serverside using a simple onActionPlayerOnline().

cbk1994 11-07-2008 03:38 AM

Quote:

Originally Posted by LoneAngelIbesu (Post 1439947)
What do you mean by that? On Valikorlia, we add classes to players on the serverside using a simple onActionPlayerOnline().

Maybe you're not dealing with a player. Maybe you've got a database NPC running every hour or so logging something.

Inverness 11-07-2008 05:02 AM

Quote:

Originally Posted by Chompy (Post 1439925)
It can, it's like a class joined to the player. All you need is some functions serverside, and I guess Skyld have to do that.

Quote:

Originally Posted by LoneAngelIbesu (Post 1439947)
What do you mean by that? On Valikorlia, we add classes to players on the serverside using a simple onActionPlayerOnline().

I expected better from you guys. :noob:

xXziroXx 11-07-2008 05:46 AM

Quote:

Originally Posted by Inverness (Post 1439976)
I expected better from you guys. :noob:

Seconded. :whatever:

TSAdmin 11-07-2008 06:04 AM

Quote:

Originally Posted by DrakilorP2P (Post 1439988)
I'm too lazy to write my own niche scripts, please do it for me Stefan.

That's not what is being said. Obviously he's already done his own, and found that it isn't what he considers to be very efficient to be scripted, so he is asking that it be made a built-in feature.

xXziroXx 11-07-2008 06:27 AM

Quote:

Originally Posted by TSAdmin (Post 1439989)
That's not what is being said. Obviously he's already done his own, and found that it isn't what he considers to be very efficient to be scripted, so he is asking that it be made a built-in feature.

Hell Raven's time system does what's being asked in this thread perfectly.

Skyld 11-07-2008 02:00 PM

Quote:

Originally Posted by LoneAngelIbesu (Post 1439898)
I wasn't aware that shared functions were limited to clientside use...

EDIT: Could you explain the reason why a shared functions pack can't be serverside?

The shared functions are in a privileged weapon on the login server, which is added to the player when they connect to the login server but is not removed upon changing server. This allows the functions to work clientside on all servers, all the time. The reason that it can't work serverside is because that would require each server to also maintain a copy of the shared functions pack that's always up-to-date, and the client can't carry it's own serverside script because usually, the client is sent byte-coded clientside scripting and doesn't know anything of the serverside portion.

For it to be able to transport serverside code in the same way, the server and client would need to be modified to accept serverside code from the client, and that would be awfully insecure, but I don't know whether some way of automatically copying the shared functions script from the login server to other servers periodically would work.

Chompy 11-07-2008 02:18 PM

Quote:

Originally Posted by Inverness (Post 1439976)
I expected better from you guys. :noob:

Uhm..? :oo:

LoneAngelIbesu 11-07-2008 04:37 PM

Quote:

Originally Posted by xXziroXx (Post 1439999)
Hell Raven's time system does what's being asked in this thread perfectly.

Hell Raven's time system is also the most confusing piece of code I've ever seen on Graal. Granted the time I tried to use it, I was just beginning to script. But, the last time I checked, HR's time system doesn't provide a single function for displaying a timestamp.

xXziroXx 11-07-2008 05:53 PM

Quote:

Originally Posted by LoneAngelIbesu (Post 1440065)
Hell Raven's time system is also the most confusing piece of code I've ever seen on Graal. Granted the time I tried to use it, I was just beginning to script. But, the last time I checked, HR's time system doesn't provide a single function for displaying a timestamp.

It's not rocket science to make a function for it yourself using HR's code as source.

Chompy 11-07-2008 05:56 PM

Quote:

Originally Posted by LoneAngelIbesu (Post 1440065)
Hell Raven's time system is also the most confusing piece of code I've ever seen on Graal. Granted the time I tried to use it, I was just beginning to script. But, the last time I checked, HR's time system doesn't provide a single function for displaying a timestamp.

Uhm? In the first example HR used in that thread it shows you how to get a date/timestamp :o

LoneAngelIbesu 11-07-2008 06:21 PM

Quote:

Originally Posted by Chompy (Post 1440086)
Uhm? In the first example HR used in that thread it shows you how to get a date/timestamp :o

Not using a single function, it doesn't.
Quote:

Originally Posted by xXziroXx (Post 1440083)
It's not rocket science to make a function for it yourself using HR's code as source.

PHP Code:

function hellRavenFormalTime() {
  
temp.ctime adjustTimeZone(timevar2,-5); // to EST
  
temp.date getDate(temp.ctime);
  
temp.clock = {getHour(temp.ctime),getMinutes(temp.ctime),getSeconds(temp.ctime)};
  return 
getFormalDayEnglish(getWeekday(temp.ctime)) @ ", " @
         
getFormalMonthEnglish(temp.date[1]) SPC getFormalNumber(temp.date[2]) @ ", " temp.date[0] @ " @ " @
         
to12Hour(temp.clock[0]) @ ":" doubleDigit(temp.clock[1]) @ ":" doubleDigit(temp.clock[2]) SPC getAMPM(temp.clock[0]) SPC "EST";


PHP Code:

function timestamp() {
  return 
shared.date("l, F jS, @ g:i:s a T");


Which one do you think somebody new to GS2 would be able to use more easily? You guys seem to think that every scripter on Graal is an expert.

Chompy 11-07-2008 06:56 PM

Quote:

Originally Posted by LoneAngelIbesu (Post 1440096)
Not using a single function, it doesn't.

PHP Code:

function hellRavenFormalTime() {
  
temp.ctime adjustTimeZone(timevar2,-5); // to EST
  
temp.date getDate(temp.ctime);
  
temp.clock = {getHour(temp.ctime),getMinutes(temp.ctime),getSeconds(temp.ctime)};
  return 
getFormalDayEnglish(getWeekday(temp.ctime)) @ ", " @
         
getFormalMonthEnglish(temp.date[1]) SPC getFormalNumber(temp.date[2]) @ ", " temp.date[0] @ " @ " @
         
to12Hour(temp.clock[0]) @ ":" doubleDigit(temp.clock[1]) @ ":" doubleDigit(temp.clock[2]) SPC getAMPM(temp.clock[0]) SPC "EST";


PHP Code:

function timestamp() {
  return 
shared.date("l, F jS, @ g:i:s a T");


Which one do you think somebody new to GS2 would be able to use more easily? You guys seem to think that every scripter on Graal is an expert.


PHP Code:

public function getTimeStamp(timezone) {
  
temp.ctime adjustTimeZone(timevar2timezone);
  
temp.date getDate(temp.ctime);
  
temp.clock = {getHour(temp.ctime),getMinutes(temp.ctime),getSeconds(temp.ctime)};
  return 
getFormalDayEnglish(getWeekday(temp.ctime)) @ ", " @
         
getFormalMonthEnglish(temp.date[1]) SPC getFormalNumber(temp.date[2]) @ ", " temp.date[0] @ " @ " @
         
to12Hour(temp.clock[0]) @ ":" doubleDigit(temp.clock[1]) @ ":" doubleDigit(temp.clock[2]) SPC getAMPM(temp.clock[0]) SPC "EST";


and then you could do

PHP Code:

this.join("functions_time"// or whatever you named the class where the function is
function onCreated() {
  
sendtorc(getTimeStamp(1));
  
sendtorc(getTimeStamp(-5));

  
// getTimeStamp(timezone)


I don't see any problem using HR's.. All you would have to do is make it so the function returns the proper timezone.. which shouldn't be a problem at all..

Inverness 11-07-2008 10:17 PM

Quote:

Originally Posted by LoneAngelIbesu (Post 1440096)
Not using a single function, it doesn't.

PHP Code:

function hellRavenFormalTime() {
  
temp.ctime adjustTimeZone(timevar2,-5); // to EST
  
temp.date getDate(temp.ctime);
  
temp.clock = {getHour(temp.ctime),getMinutes(temp.ctime),getSeconds(temp.ctime)};
  return 
getFormalDayEnglish(getWeekday(temp.ctime)) @ ", " @
         
getFormalMonthEnglish(temp.date[1]) SPC getFormalNumber(temp.date[2]) @ ", " temp.date[0] @ " @ " @
         
to12Hour(temp.clock[0]) @ ":" doubleDigit(temp.clock[1]) @ ":" doubleDigit(temp.clock[2]) SPC getAMPM(temp.clock[0]) SPC "EST";


PHP Code:

function timestamp() {
  return 
shared.date("l, F jS, @ g:i:s a T");


Which one do you think somebody new to GS2 would be able to use more easily? You guys seem to think that every scripter on Graal is an expert.

Don't insult other people's intelligence. :p

Date functions like that are rather language independent and if a proper explanation is provided it could easily be figured out by someone knew to scripting, provided they understand the basics. Obviously there would also be one or two default timestamp formats also.

LoneAngelIbesu 11-07-2008 11:23 PM

You guys don't understand what I'm saying at all. I know that it can be done with HR's script. What I'm telling you is that HR's script isn't beginner-friendly. Look at how many functions you have to do just to get a single format: 12. How many lines of code would you need to recreate the amount of combinations PHP's date() function has? It'd be much simpler to just provide a single function that can support myriad formats.

I guess I have a new side-project.

xXziroXx 11-07-2008 11:59 PM

Dylan, or whatever you name is, your code is unnecessary and not very flexible. You might want to get some more programming experience before saying how inefficient a code is.

The modifications I made to HR's system provide easy timestamp access for all client- and serverside scripts. I simply have the script setting all local variables as serverr strings, then have a getTimeStamp() function in a class (identical ones both on client- and serverside, script replication is evil :( ) that any script can use by simply reading the time from the serverr variables.

LoneAngelIbesu 11-08-2008 12:06 AM

Quote:

Originally Posted by xXziroXx (Post 1440214)
Dylan, or whatever you name is, your code is unnecessary and not very flexible. You might want to get some more programming experience before saying how inefficient a code is.

Half the things scripted on Graal are unnecessary, but that never stops anybody. But, please explain to me how a date function that mimics PHP's date() function wouldn't be flexible? :oo:

Inverness 11-08-2008 12:31 AM

Quote:

Originally Posted by LoneAngelIbesu (Post 1440217)
But, please explain to me how a date function that mimics PHP's date() function wouldn't be flexible? :oo:

Dylan, I believe he is referring to your function hellRavenFormalTime().

And yes, Ziro, his name is Dylan.

LoneAngelIbesu 11-08-2008 01:06 AM

Quote:

Originally Posted by Inverness (Post 1440218)
Dylan, I believe he is referring to your function hellRavenFormalTime().

And yes, Ziro, his name is Dylan.

Oh, well, in that case... that's the example given for creating a timestamp with HR's script. I agree that it's inflexible.

Crow 11-08-2008 09:09 AM

Why don't you use HR's functions to mimic date()? It's not like PHP's date() is some fancy 2 line code which magically returns whatever you want, goddamnit.

DustyPorViva 11-08-2008 09:15 AM

Thing is, I think this should have been something done way before HellRavens function pack for it was made. It's pretty common and important for keeping track of the time for various things.

I'm not saying this should be done, but I don't know why it wasn't done before. It seems like it would have had many practical uses.

Inverness 11-08-2008 11:20 AM

When I try using HR's functions on the clientside with the proper timevar2 from the server it doesn't work correctly, I think it has something to do with how the calculation is being done.

xXziroXx 11-08-2008 03:34 PM

Quote:

Originally Posted by Inverness (Post 1440354)
When I try using HR's functions on the clientside with the proper timevar2 from the server it doesn't work correctly, I think it has something to do with how the calculation is being done.

Just read them from serverr variables? :oo:

LoneAngelIbesu 11-08-2008 08:58 PM

Quote:

Originally Posted by Crow (Post 1440339)
Why don't you use HR's functions to mimic date()? It's not like PHP's date() is some fancy 2 line code which magically returns whatever you want, goddamnit.

Um.. in case you didn't read between the lines, that's pretty much the plan. Use his functions as a base to create a more flexible, easier-to-use, single function for timestamps. ^^


All times are GMT +2. The time now is 01:13 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.