Member
|
03-05-2024
, 16:23
Re: [REQUEST][HL] timeleft, system clock HUD
|
#3
|
Quote:
Originally Posted by bigdaddy424
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_szHostname[ 64 ];
new g_pointerTimelimit;
const SERVER_TIMEZONE = 1 //GMT+1
enum TIMETABLE { HOUR_DIFF, TIMEZONE[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 vault, player_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_task( 2.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_think( ENTITY_CLASS, "fwdThink_Updater" );
// initialize thinking entity...
new iEntityTimer = create_entity( "info_target" );
entity_set_string( iEntityTimer, EV_SZ_classname, ENTITY_CLASS );
entity_set_float( iEntityTimer, EV_FL_nextthink, get_gametime() + UPDATE_TIME );
}
public fwdThink_Updater( iEntity ) {
if( get_pcvar_float( g_pointerTimelimit ) ) {
static iHours, iMinutes, iSeconds;
iSeconds = get_timeleft( );
iMinutes = iSeconds / 60;
iHours = iMinutes / 60;
iSeconds = iSeconds - iMinutes * 60;
iMinutes = iMinutes - iHours * 60;
if( iHours )
formatex( g_szHostname, 63, "^n(Timeleft %d:%02d:%02d)", iHours, iMinutes, iSeconds );
else formatex( g_szHostname, 63, "^n(Timeleft %d:%02d)", iMinutes, iSeconds )
}
else formatex( g_szHostname, 63, "^n(No time limit)");
entity_set_float( iEntity, EV_FL_nextthink, get_gametime() + UPDATE_TIME );
}
public client_authorized(id, const authid[])
{
player_local_time[id] = nvault_get(vault, authid)
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(id, authid, charsmax(authid))
nvault_set(vault, authid, fmt("%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 i = 0; i < sizeof(UTC_TimeDifferences); i++)
menu_additem(menu, fmt("%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(id, menu)
}
public menu_handler(id, menu, item)
{
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_text, charsmax(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_text, g_szHostname)
}
}
|
Hey !
I appreciate your help bigdaddy424, then I try to compile the code, I get multiple errors, I'll attach a photo:
|
|