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

[REQUEST][Half-Life] HUD for timeleft, system clock w/ auto timezone


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tiltedShrimp
Member
Join Date: Feb 2024
Old 03-05-2024 , 14:08   [REQUEST][Half-Life] HUD for timeleft, system clock w/ auto timezone
Reply With Quote #1

Hey !
Im interested in a HUD which would display the time that's left until map change and system clock. After a bit of research on the forums I've managed to find a plugin which displays system time only, maybe it would be possible to edit it? I'll attach the said plugin.

Would it be possible to edit the following:
#1 add timeleft until map change just below the system clock
#2 make the HUD enabled by default upon entering the server
#3 if its a possibility, make the whole HUD/font a bit smaller so that its less intrusive

Thank you !
Attached Files
File Type: sma Get Plugin or Get Source (clock.sma - 45 views - 1.2 KB)

Last edited by tiltedShrimp; 03-07-2024 at 15:09.
tiltedShrimp is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 03-05-2024 , 16:15   Re: [REQUEST][HL] timeleft, system clock HUD
Reply With Quote #2

timeleft code by xpaw
timezones from ai
PHP Code:
#include <amxmodx>
#include <engine>
#include <nvault>

#define UPDATE_TIME    1.0
#define ENTITY_CLASS    "env_host_timeleft"

new g_szHostname64 ];
new 
g_pointerTimelimit;

const 
SERVER_TIMEZONE //GMT+1

enum TIMETABLE HOUR_DIFFTIMEZONE[38] }
new 
UTC_TimeDifferences[][TIMETABLE] =
{
    { -
12"Baker Island, Howland Island" },
    { -
11"Niue, American Samoa" },
    { -
10"Hawaii, French Polynesia" },
    { -
9"Alaska" },
    { -
8"Pacific Time Zone" },
    { -
7"Mountain Time Zone" },
    { -
6"Central Time Zone" },
    { -
5"Eastern Time Zone" },
    { -
4"Atlantic Time Zone" },
    { -
3"Argentina, Brazil" },
    { -
2"Fernando de Noronha, South Georgia" },
    { -
1"Cape Verde, Azores" },
    { 
0"Greenwich Mean Time" },
    { 
1"Central European Time" },
    { 
2"Eastern European Time" },
    { 
3"Moscow Time" },
    { 
4"Armenia, Azerbaijan" },
    { 
5"Pakistan, Maldives" },
    { 
6"Bangladesh, Bhutan" },
    { 
7"Indochina Time" },
    { 
8"China, Philippines" },
    { 
9"Japan, South Korea" },
    { 
10"Australia Eastern Time" },
    { 
11"Vanuatu, New Caledonia" },
    { 
12"New Zealand, Fiji" }
}


new 
vaultplayer_local_time[MAX_PLAYERS 1], bool:show_clock[MAX_PLAYERS 1]

public 
plugin_init()
{
    
register_plugin"Hostname Timeleft""1.0""xPaw" );

    
g_pointerTimelimit    get_cvar_pointer"mp_timelimit" );

    
// Give delay to load configs...
    
set_task2.5"checkTimeleft" );

    
register_clcmd("say timezone""clcmd_timezone")
    
register_clcmd("say clock""clcmd_clock")

    
vault nvault_open("timezone")
}

public 
plugin_end()
    
nvault_close(vault)

public 
checkTimeleft( ) {
    
register_thinkENTITY_CLASS"fwdThink_Updater" );
    
    
// initialize thinking entity...
    
new iEntityTimer create_entity"info_target" );
    
entity_set_stringiEntityTimerEV_SZ_classnameENTITY_CLASS );
    
entity_set_floatiEntityTimerEV_FL_nextthinkget_gametime() + UPDATE_TIME );
}

public 
fwdThink_UpdateriEntity ) {
    if( 
get_pcvar_floatg_pointerTimelimit ) ) {
        static 
iHoursiMinutesiSeconds;
        
        
iSeconds    get_timeleft( );
        
iMinutes    iSeconds 60;
        
iHours        iMinutes 60;
        
iSeconds    iSeconds iMinutes 60;
        
iMinutes    iMinutes iHours 60;
        
        
        if( 
iHours )
            
formatexg_szHostname63"^n(Timeleft %d:%02d:%02d)"iHoursiMinutesiSeconds );
        else 
formatexg_szHostname63"^n(Timeleft %d:%02d)"iMinutesiSeconds )
    } 
    else 
formatexg_szHostname63"^n(No time limit)");
    
entity_set_floatiEntityEV_FL_nextthinkget_gametime() + UPDATE_TIME );
}

public 
client_authorized(id, const authid[])
{
    
player_local_time[id] = nvault_get(vaultauthid)
    
set_task(1.0"update_time"id, .flags="b")
}

public 
client_putinserver(id)
    
show_clock[id] = true

public client_disconnected(id)
{
    new 
authid[32]
    
get_user_authid(idauthidcharsmax(authid))
    
nvault_set(vaultauthidfmt("%d"player_local_time[id]))
    
show_clock[id] = false
    remove_task
(id)
}

public 
clcmd_timezone(id)
{
    new 
menu menu_create("Select Timezone""menu_handler")
    for (new 
0sizeof(UTC_TimeDifferences); i++)
        
menu_additem(menufmt("%s%s \d%d"player_local_time[id] == UTC_TimeDifferences[i][HOUR_DIFF] ? "\y" "\w"UTC_TimeDifferences[i][TIMEZONE], UTC_TimeDifferences[i][HOUR_DIFF]))
    
menu_display(idmenu)
}

public 
menu_handler(idmenuitem)
{
    
menu_destroy(menu)
    
player_local_time[id] = UTC_TimeDifferences[item][HOUR_DIFF]
}

public 
clcmd_clock(id)
    
show_clock[id] = !show_clock[id]

public 
update_time(id)
{
    if (
show_clock[id])
    {
        static 
time_text[16], systime
        systime 
get_systime(id) + floatround((player_local_time[id] - SERVER_TIMEZONE) * 3600.0)
        
format_time(time_textcharsmax(time_text), "%I:%M:%S %p"systime)
        
set_hudmessage(.red=251, .green=126, .blue=20, .x=0.015, .y=0.175, .holdtime=1.0, .channel=2)
        
show_hudmessage(id"%s%s"time_textg_szHostname)
    }

__________________
bigdaddy424 is offline
tiltedShrimp
Member
Join Date: Feb 2024
Old 03-05-2024 , 16:23   Re: [REQUEST][HL] timeleft, system clock HUD
Reply With Quote #3

Quote:
Originally Posted by bigdaddy424 View Post
timeleft code by xpaw
timezones from ai
PHP Code:
#include <amxmodx>
#include <engine>
#include <nvault>

#define UPDATE_TIME    1.0
#define ENTITY_CLASS    "env_host_timeleft"

new g_szHostname64 ];
new 
g_pointerTimelimit;

const 
SERVER_TIMEZONE //GMT+1

enum TIMETABLE HOUR_DIFFTIMEZONE[38] }
new 
UTC_TimeDifferences[][TIMETABLE] =
{
    { -
12"Baker Island, Howland Island" },
    { -
11"Niue, American Samoa" },
    { -
10"Hawaii, French Polynesia" },
    { -
9"Alaska" },
    { -
8"Pacific Time Zone" },
    { -
7"Mountain Time Zone" },
    { -
6"Central Time Zone" },
    { -
5"Eastern Time Zone" },
    { -
4"Atlantic Time Zone" },
    { -
3"Argentina, Brazil" },
    { -
2"Fernando de Noronha, South Georgia" },
    { -
1"Cape Verde, Azores" },
    { 
0"Greenwich Mean Time" },
    { 
1"Central European Time" },
    { 
2"Eastern European Time" },
    { 
3"Moscow Time" },
    { 
4"Armenia, Azerbaijan" },
    { 
5"Pakistan, Maldives" },
    { 
6"Bangladesh, Bhutan" },
    { 
7"Indochina Time" },
    { 
8"China, Philippines" },
    { 
9"Japan, South Korea" },
    { 
10"Australia Eastern Time" },
    { 
11"Vanuatu, New Caledonia" },
    { 
12"New Zealand, Fiji" }
}


new 
vaultplayer_local_time[MAX_PLAYERS 1], bool:show_clock[MAX_PLAYERS 1]

public 
plugin_init()
{
    
register_plugin"Hostname Timeleft""1.0""xPaw" );

    
g_pointerTimelimit    get_cvar_pointer"mp_timelimit" );

    
// Give delay to load configs...
    
set_task2.5"checkTimeleft" );

    
register_clcmd("say timezone""clcmd_timezone")
    
register_clcmd("say clock""clcmd_clock")

    
vault nvault_open("timezone")
}

public 
plugin_end()
    
nvault_close(vault)

public 
checkTimeleft( ) {
    
register_thinkENTITY_CLASS"fwdThink_Updater" );
    
    
// initialize thinking entity...
    
new iEntityTimer create_entity"info_target" );
    
entity_set_stringiEntityTimerEV_SZ_classnameENTITY_CLASS );
    
entity_set_floatiEntityTimerEV_FL_nextthinkget_gametime() + UPDATE_TIME );
}

public 
fwdThink_UpdateriEntity ) {
    if( 
get_pcvar_floatg_pointerTimelimit ) ) {
        static 
iHoursiMinutesiSeconds;
        
        
iSeconds    get_timeleft( );
        
iMinutes    iSeconds 60;
        
iHours        iMinutes 60;
        
iSeconds    iSeconds iMinutes 60;
        
iMinutes    iMinutes iHours 60;
        
        
        if( 
iHours )
            
formatexg_szHostname63"^n(Timeleft %d:%02d:%02d)"iHoursiMinutesiSeconds );
        else 
formatexg_szHostname63"^n(Timeleft %d:%02d)"iMinutesiSeconds )
    } 
    else 
formatexg_szHostname63"^n(No time limit)");
    
entity_set_floatiEntityEV_FL_nextthinkget_gametime() + UPDATE_TIME );
}

public 
client_authorized(id, const authid[])
{
    
player_local_time[id] = nvault_get(vaultauthid)
    
set_task(1.0"update_time"id, .flags="b")
}

public 
client_putinserver(id)
    
show_clock[id] = true

public client_disconnected(id)
{
    new 
authid[32]
    
get_user_authid(idauthidcharsmax(authid))
    
nvault_set(vaultauthidfmt("%d"player_local_time[id]))
    
show_clock[id] = false
    remove_task
(id)
}

public 
clcmd_timezone(id)
{
    new 
menu menu_create("Select Timezone""menu_handler")
    for (new 
0sizeof(UTC_TimeDifferences); i++)
        
menu_additem(menufmt("%s%s \d%d"player_local_time[id] == UTC_TimeDifferences[i][HOUR_DIFF] ? "\y" "\w"UTC_TimeDifferences[i][TIMEZONE], UTC_TimeDifferences[i][HOUR_DIFF]))
    
menu_display(idmenu)
}

public 
menu_handler(idmenuitem)
{
    
menu_destroy(menu)
    
player_local_time[id] = UTC_TimeDifferences[item][HOUR_DIFF]
}

public 
clcmd_clock(id)
    
show_clock[id] = !show_clock[id]

public 
update_time(id)
{
    if (
show_clock[id])
    {
        static 
time_text[16], systime
        systime 
get_systime(id) + floatround((player_local_time[id] - SERVER_TIMEZONE) * 3600.0)
        
format_time(time_textcharsmax(time_text), "%I:%M:%S %p"systime)
        
set_hudmessage(.red=251, .green=126, .blue=20, .x=0.015, .y=0.175, .holdtime=1.0, .channel=2)
        
show_hudmessage(id"%s%s"time_textg_szHostname)
    }

Hey !
I appreciate your help bigdaddy424, then I try to compile the code, I get multiple errors, I'll attach a photo:
Attached Thumbnails
Click image for larger version

Name:	compiling error.jpg
Views:	25
Size:	89.2 KB
ID:	203600  
tiltedShrimp is offline
tiltedShrimp
Member
Join Date: Feb 2024
Old 03-05-2024 , 17:17   Re: [REQUEST][HL] timeleft, system clock HUD
Reply With Quote #4

Quote:
Originally Posted by tiltedShrimp View Post
Hey !
I appreciate your help bigdaddy424, then I try to compile the code, I get multiple errors, I'll attach a photo:
EDIT: the mistake was on my end for compiling errors, the plugin is EXACTLY what I was searching for and works like a charm, thank you so much bigdaddy424, you're a Legend !
tiltedShrimp is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 03-05-2024 , 18:47   Re: [REQUEST][HL] timeleft, system clock HUD
Reply With Quote #5

to be honest all of my work i do does involve functions that are part of unofficial releases because i find it much simpler and sometimes people end up ignoring just because im not referencing 1.8.2
__________________
bigdaddy424 is offline
tiltedShrimp
Member
Join Date: Feb 2024
Old 03-05-2024 , 19:05   Re: [REQUEST][HL] timeleft, system clock HUD
Reply With Quote #6

Quote:
Originally Posted by bigdaddy424 View Post
to be honest all of my work i do does involve functions that are part of unofficial releases because i find it much simpler and sometimes people end up ignoring just because im not referencing 1.8.2
Makes sense buddy 👍
tiltedShrimp is offline
tiltedShrimp
Member
Join Date: Feb 2024
Old 03-06-2024 , 11:52   Re: [REQUEST][HL] timeleft, system clock HUD
Reply With Quote #7

Update:
Reopening the thread. I discovered an issue with the plugin, the one provided by bigdaddy424. I've set the "const SERVER_TIMEZONE = " to "0" to correspond my local time since it says "server timezone", so I figured it would be correct to adjust it to my local time, but other, foreign players seem to get the same timezone, the plugin doesn't adjust for them automatically. Would it be possible to make it so the plugin automatically selects the appropriate timezone for everyone? Or maybe scan player's pc system time and display that for him?

Last edited by tiltedShrimp; 03-07-2024 at 15:11.
tiltedShrimp is offline
tedaimlocks
Member
Join Date: Jan 2024
Old 03-06-2024 , 13:09   Re: [REQUEST][HL] timeleft, system clock HUD
Reply With Quote #8

the default timezone would be where the server location is hosted, and you could try to use geoip to get the players country and display their timezone

https://forums.alliedmods.net/showthread.php?t=257898
tedaimlocks is offline
tiltedShrimp
Member
Join Date: Feb 2024
Old 03-06-2024 , 13:39   Re: [REQUEST][HL] timeleft, system clock HUD
Reply With Quote #9

Quote:
Originally Posted by tedaimlocks View Post
the default timezone would be where the server location is hosted, and you could try to use geoip to get the players country and display their timezone

https://forums.alliedmods.net/showthread.php?t=257898
Hey tedaimlocks !
Thank you for your insight and suggestion, it really makes sense to utilize GeoIP in someway for the timezones to be set automatically, I already use a few plugins which utilizes GeoIP, for example, GHW Connect Messages, which pushes a message when someone connect to a server with they country that they are located at.

Sadly when it comes to coding or creating a plugin, my knowledge is seriously limited, Im only really capable of editing the simplest parameters within an already working plugin ... If you know a way to make it work, I'd really appreciate you landing me hand !

Last edited by tiltedShrimp; 03-07-2024 at 15:12.
tiltedShrimp is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-07-2024 , 11:05   Re: [REQUEST][HL] timeleft, system clock HUD
Reply With Quote #10

something like this?
__________________

Last edited by georgik57; 03-07-2024 at 11:09.
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
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 17:36.


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