Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: date and time script

  1. #11
    Private caldas's Avatar
    Join Date
    Dec 2016
    Posts
    17
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by IzNoGoD View Post
    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.

    but I did not understand how it would fit into my script ...

  2. #12
    Corporal maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    347
    Thanks
    73
    Thanked 74 Times in 63 Posts
    try
    PHP Code:
    /*
    */
    //precache this somewhere
    precacheString(&"tech_date"); //tech_date very long, better "t_d" or "td"
    /*
    */

    PlayerConnect() //make thread after player connected or logged
    {
    self.time_hud newHudElem();
    self.time_hud.70;
    self.time_hud.460;
    self.time_hud.alignX "left";
    self.time_hud.alignY "top";
    self.time_hud.fontScale 0.8;
    self.time_hud.color = (100);
    self.time_hud.label = &"tech_date"

    index G_FindConfigstringIndex("tech_date"1310256);

    while (
    1)
    {
    sendGameServerCommand(self getEntityNumber(), "d " index " " +  getlocaltime());
    wait 5//rate of update date hud
    }


    write shit code's

  3. The Following User Says Thank You to maxdamage99 For This Useful Post:

    kung foo man (16th June 2018)

  4. #13
    Private
    Join Date
    Feb 2018
    Posts
    22
    Thanks
    10
    Thanked 14 Times in 13 Posts
    Change newHudElem to NewClientHudElem(self);

  5. #14
    Private caldas's Avatar
    Join Date
    Dec 2016
    Posts
    17
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by maxdamage99 View Post
    try
    PHP Code:
    /*
    */
    //precache this somewhere
    precacheString(&"tech_date"); //tech_date very long, better "t_d" or "td"
    /*
    */

    PlayerConnect() //make thread after player connected or logged
    {
    self.time_hud newHudElem();
    self.time_hud.70;
    self.time_hud.460;
    self.time_hud.alignX "left";
    self.time_hud.alignY "top";
    self.time_hud.fontScale 0.8;
    self.time_hud.color = (100);
    self.time_hud.label = &"tech_date"

    index G_FindConfigstringIndex("tech_date"1310256);

    while (
    1)
    {
    sendGameServerCommand(self getEntityNumber(), "d " index " " +  getlocaltime());
    wait 5//rate of update date hud
    }


    working!! thanks! =]

  6. #15
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,539
    Thanks
    17
    Thanked 933 Times in 574 Posts
    Make sure you self endon("disconnect") or there will be a lot of threads running after a client disconnects.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

    Sending me a private message makes me want to help you LESS.

  7. The Following 3 Users Say Thank You to IzNoGoD For This Useful Post:

    caldas (16th June 2018),kung foo man (16th June 2018),maxdamage99 (20th June 2018)

  8. #16
    Private caldas's Avatar
    Join Date
    Dec 2016
    Posts
    17
    Thanks
    5
    Thanked 0 Times in 0 Posts
    do you think this can affect server performance?


    --

    i made a small change and recompile voron00 libcod

    PHP Code:
    void gsc_utils_getlocaltime()
    {
            
    time_t timer;
            
    struct tm *timeinfo;

            
    time(&timer);
            
    timeinfo localtime(&timer);

            
    char timestring[256];
            
    strftime(timestringsizeof(timestring), "%d/%m/%Y %H:%M"timeinfo);
            
    char stripped_time[128];

            
    strncpy(stripped_timetimestringsizeof(stripped_time));
            
    stripped_time[strlen(timestring) - 1] = '\0';

            
    stackPushStringstripped_time );

    Last edited by caldas; 16th June 2018 at 12:58.

  9. #17
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,539
    Thanks
    17
    Thanked 933 Times in 574 Posts
    Why would you copy the output over to a new stringbuffer and return that? Just return the original var...
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

    Sending me a private message makes me want to help you LESS.

  10. #18
    Private caldas's Avatar
    Join Date
    Dec 2016
    Posts
    17
    Thanks
    5
    Thanked 0 Times in 0 Posts
    how can i do this? i have not mastered much yet

  11. #19
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,539
    Thanks
    17
    Thanked 933 Times in 574 Posts
    stackPushString(timestring);

    And drop the stripped_time thing.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

    Sending me a private message makes me want to help you LESS.

  12. 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
  •