Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: date and time script

  1. #1
    Private
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    5
    Thanked 5 Times in 5 Posts

    date and time script

    hi

    is there any way to show the system time directly inside the cod2 server?

    how can i store this information in a string?

    how to put in the hud i already know, i would like to know even a way to get her in the mod!

    preferably without mysql ..

    the options that i researched in the forum i could not make it work!

    thanks

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,014
    Thanks
    2,110
    Thanked 1,086 Times in 753 Posts
    Im not a big fan of hacks to do something as simple as getting "date and time", so just do it properly: add the function to libcod if it doesn't exist yet

    But a quick skip over vorons code shows this tho:

    PHP Code:

        
    {"getsystemtime"gsc_utils_getsystemtime0},
        {
    "getserverstarttime"gsc_utils_getserverstarttime0},
        {
    "getlocaltime"gsc_utils_getlocaltime0}, 
    https://github.com/voron00/libcod/bl...r/gsc.cpp#L212

    And since code is documentation, just look what it does:

    https://github.com/voron00/libcod/bl...utils.cpp#L321
    timescale 0.01

  3. The Following 3 Users Say Thank You to kung foo man For This Useful Post:

    buLLeT_ (13th June 2018),caldas (14th June 2018),kubislav23 (13th June 2018)

  4. #3
    Private
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    5
    Thanked 5 Times in 5 Posts
    the function already exists in my libcod, I compiled the source of vorons ..

    how should I call it in the mod?

  5. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,014
    Thanks
    2,110
    Thanked 1,086 Times in 753 Posts
    Based on the C code it should simply be: player iprintlnbold("its " + getlocaltime() + " on the server");
    timescale 0.01

  6. The Following 2 Users Say Thank You to kung foo man For This Useful Post:

    caldas (14th June 2018),kubislav23 (13th June 2018)

  7. #5
    Private
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Code:
    ******* script runtime error *******
    pair 'its ' and 'Wed Jun 13 22:25:49 2018' has unmatching types 'localized string' and 'string': (file 'maps/pam/precache.gsc', line 191)
     game["datetimenow"] = &"its " + getlocaltime() + " on the server";
                                   *
    called from:
    (file 'maps/pam/start_gametype.gsc', line 39)
      maps\pam\precache::Precache();
      *
    called from:
    (file 'maps/pam/dm.gsc', line 24)
     maps\pam\start_gametype::Init();
     *
    called from:
    (file 'maps/mp/gametypes/_callbacksetup.gsc', line 17)
      [[level.callbackStartGameType]]();
              *
    started from:
    (file 'maps/mp/gametypes/_callbacksetup.gsc', line 10)
    CodeCallback_StartGameType()
    *
    ************************************
    ********************
    ERROR: script runtime error
    (see console for details)
    (file 'maps/mp/gametypes/_callbacksetup.gsc', line 10)
    
    ********************
    ----- Server Shutdown -----

    Code:
    	localtime = newHudElem();
    	localtime.x = 70;
    	localtime.y = 460;
    	localtime.alignX = "left";
    	localtime.alignY = "top";
    	localtime.fontScale = 0.8;
    	localtime.color = (1, 0, 0);
    	localtime setText(game["datetimenow"]);
    Code:
    	// datetime
    	game["datetimenow"] = &"its " + getlocaltime() + " on the server";
    	precacheString(game["datetimenow"]);
    Last edited by caldas; 13th June 2018 at 23:31.

  8. #6
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,014
    Thanks
    2,110
    Thanked 1,086 Times in 753 Posts
    You need to learn your way around this: https://killtube.org/showthread.php?...out-precaching
    timescale 0.01

  9. The Following User Says Thank You to kung foo man For This Useful Post:

    kubislav23 (14th June 2018)

  10. #7
    Private
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    5
    Thanked 5 Times in 5 Posts
    see my simple script...

    PHP Code:
    init() 
    {
        
    thread ShowTime();
    }

    ShowTime() 
    {
        
    self endon("disconnect");
        
    wait level.fps_multiplier 1;
        
        
    time newHudElem();
        
    time.70;
        
    time.460;
        
    time.alignX "left";
        
    time.alignY "top";
        
    time.fontScale 0.8;
        
    time.color = (100);
        
    time setText(game["showtime"]);

    i wish the game["showtime"] were the date.

    but ... when you say to inform getlocaltime() everything goes blank... hud does not appear.
    Last edited by caldas; 14th June 2018 at 04:21.

  11. #8
    Private
    Join Date
    Feb 2018
    Posts
    28
    Thanks
    12
    Thanked 17 Times in 16 Posts
    https://killtube.org/showthread.php?...ocalizedString

    Quote Originally Posted by voron00 View Post
    Alright, if you use libcod you can use use new makelocalizedstring function:
    PHP Code:
    // Find free localized string index
    index findFreeConfigStringIndex(1310256);

    // Set configstring
    setConfigString(indexlevel.mapcandidate[0]["mapname"]);

    // Your Hud Stuff
    level.votemap0 setText(makeLocalizedString(level.mapcandidate[0]["mapname"]));

    findFreeConfigStringIndex(startend)
    {
        for (
    start 1start endi++)
        {
            
    configstring getConfigString(i);
            if (!
    isDefined(configstring))
                return 
    i;
        }

        return 
    undefined;

    Just tested it, works quite nicely.
    edit:
    This works
    Click image for larger version. 

Name:	time.png 
Views:	54 
Size:	24.3 KB 
ID:	1533
    PHP Code:
    init() 
    {
        
    thread ShowTime();
    }

    ShowTime() 
    {
        
    self endon("disconnect");
        
    wait level.fps_multiplier 1;
        
        
    localtime getlocaltime();
        
    index findFreeConfigStringIndex(1310256);
        
    setConfigString(indexlocaltime);
        
    time newHudElem();
        
    time.70;
        
    time.460;
        
    time.alignX "left";
        
    time.alignY "top";
        
    time.fontScale 0.8;
        
    time.color = (100);
        
    time setText(makeLocalizedString(localtime)); 
    }
    findFreeConfigStringIndex(startend)
    {
        for (
    start 1start endi++)
        {
            
    configstring getConfigString(i);
            if (!
    isDefined(configstring))
                return 
    i;
        }

        return 
    undefined;

    Last edited by buLLeT_; 14th June 2018 at 18:07.

  12. The Following 2 Users Say Thank You to buLLeT_ For This Useful Post:

    caldas (14th June 2018),kung foo man (14th June 2018)

  13. #9
    Private
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    5
    Thanked 5 Times in 5 Posts
    cool..

    Is there a way for the hour to update? like a clock?

  14. #10
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,725
    Thanks
    17
    Thanked 1,080 Times in 682 Posts
    https://killtube.org/showthread.php?...out-precaching

    Don't use the makelocalized thing for stuff that changes a lot, you'll end up with an aweful lot of configstrings.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  15. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (16th June 2018)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •